-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
121 lines (105 loc) · 4.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/make -f
#
# Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
# (C) 2024 Vladimir Sadovnikov <[email protected]>
#
# This file is part of lsp-dsp-units
#
# lsp-dsp-units is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# lsp-dsp-units is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with lsp-dsp-units. If not, see <https://www.gnu.org/licenses/>.
#
# Command-line flag to silence nested $(MAKE).
ifneq ($(VERBOSE),1)
.SILENT:
endif
# Location
BASEDIR := $(CURDIR)
MODULES := $(BASEDIR)/modules
BUILDDIR := $(BASEDIR)/.build
CONFIG := $(BASEDIR)/.config.mk
# Basic initialization
# Checks
ifeq ("$(wildcard $(CONFIG))", "")
CONFIGURED = 0
else
CONFIGURED = 1
endif
include $(BASEDIR)/project.mk
# Setup paths
CHK_CONFIG = test -f "$(CONFIG)" || (echo "System not properly configured. Please launch 'make config' first" && exit 1)
DISTSRC_PATH = $(BUILDDIR)/distsrc
DISTSRC = $(DISTSRC_PATH)/$(ARTIFACT_NAME)
.DEFAULT_GOAL := all
.PHONY: all compile install uninstall clean
compile all install uninstall:
$(CHK_CONFIG)
$(MAKE) -C "$(BASEDIR)/src" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" DESTDIR="$(DESTDIR)"
clean:
echo "Cleaning build directory $(BUILDDIR)"
-rm -rf $(BUILDDIR)
echo "Clean OK"
# Module-related tasks
.PHONY: fetch tree prune
fetch:
$(CHK_CONFIG)
echo "Fetching desired source code dependencies"
$(MAKE) -f "$(BASEDIR)/make/modules.mk" $(@) VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
echo "Fetch OK"
tree:
echo "Fetching all possible source code dependencies"
$(MAKE) -f "$(BASEDIR)/make/modules.mk" $(@) VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" TREE="1"
echo "Fetch OK"
prune: clean
echo "Pruning the whole project tree"
$(MAKE) -f "$(BASEDIR)/make/modules.mk" prune VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
$(MAKE) -f "$(BASEDIR)/make/modules.mk" prune VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" TREE="1"
-rm -rf "$(CONFIG)"
echo "Prune OK"
# Configuration-related targets
.PHONY: config help chkconfig
testconfig:
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" TEST="1" -$(MAKEFLAGS)
config:
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" -$(MAKEFLAGS)
# Release-related targets
.PHONY: distsrc
distsrc:
echo "Building source code archive"
mkdir -p "$(DISTSRC)/modules"
$(MAKE) -f "$(BASEDIR)/make/modules.mk" tree VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" MODULES="$(DISTSRC)/modules" TREE="1"
cp -R $(BASEDIR)/include $(BASEDIR)/make $(BASEDIR)/src "$(DISTSRC)/"
cp $(BASEDIR)/CHANGELOG $(BASEDIR)/COPYING* $(BASEDIR)/Makefile $(BASEDIR)/*.mk "$(DISTSRC)/"
find "$(DISTSRC)" -iname '.git' | xargs rm -rf {}
find "$(DISTSRC)" -iname '.gitignore' | xargs rm -rf {}
tar -C $(DISTSRC_PATH) -czf "$(BUILDDIR)/$(ARTIFACT_NAME)-src-$(ARTIFACT_VERSION).tar.gz" "$(ARTIFACT_NAME)"
echo "Created archive: $(BUILDDIR)/$(ARTIFACT_NAME)-src-$(ARTIFACT_VERSION).tar.gz"
rm -rf $(DISTSRC_PATH)
echo "Build OK"
# Help
help:
echo "Available targets:"
echo " all Build all binaries"
echo " clean Clean all build files and configuration file"
echo " config Configure build"
echo " distsrc Make tarball with source code for packagers"
echo " fetch Fetch all desired source code dependencies from git"
echo " help Print this help message"
echo " info Output build configuration"
echo " install Install all binaries into the system"
echo " prune Cleanup build and all fetched dependencies from git"
echo " tree Fetch all possible source code dependencies from git"
echo " to make source code portable between machines"
echo " uninstall Uninstall binaries"
echo ""
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)"
echo ""