-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
122 lines (107 loc) · 4.83 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
122
#!/usr/bin/make -f
#
# Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
# (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
#
# This file is part of room-raider
#
# room-raider 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.
#
# room-raider 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 room-raider. If not, see <https://www.gnu.org/licenses/>.
#
# Location
BASEDIR := $(CURDIR)
MODULES := $(BASEDIR)/modules
BUILDDIR := $(BASEDIR)/.build
CONFIG := $(BASEDIR)/.config.mk
PLUGINS := $(BASEDIR)/plugins.mk
PROJECT := $(BASEDIR)/project.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 depend clean
compile all install uninstall depend:
@$(CHK_CONFIG)
@$(MAKE) -s -C "$(BASEDIR)/src" $(@) CONFIG="$(CONFIG)" PLUGINS="$(PLUGINS)" DESTDIR="$(DESTDIR)" ARTIFACT_VARS="$(ARTIFACT_VARS)"
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) -s -f "$(BASEDIR)/make/modules.mk" $(@) BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)" MODULES="$(MODULES)"
@echo "Fetch OK"
tree:
@echo "Fetching all possible source code dependencies"
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" $(@) BASEDIR="$(BASEDIR)" TREE="1"
@echo "Fetch OK"
prune: clean
@echo "Pruning the whole project tree"
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" prune BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" prune BASEDIR="$(BASEDIR)" TREE="1"
@-rm -rf "$(CONFIG)"
@-rm -rf "$(MODULES)"
@echo "Prune OK"
# Configuration-related targets
.PHONY: config help chkconfig
testconfig:
@$(MAKE) -s -f "$(BASEDIR)/make/configure.mk" $(@) CONFIG="$(CONFIG)" PLUGINS="$(PLUGINS)" TEST="1" $(MAKEFLAGS)
config:
@$(MAKE) -s -f "$(BASEDIR)/make/configure.mk" $(@) CONFIG="$(CONFIG)" PLUGINS="$(PLUGINS)" $(MAKEFLAGS)
# Release-related targets
.PHONY: distsrc
distsrc:
@echo "Building source code archive"
@mkdir -p "$(DISTSRC)/modules"
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" tree BASEDIR="$(BASEDIR)" MODDIR="$(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 -exec rm -rf {}
@find "$(DISTSRC)" -iname '.gitignore' | xargs -exec rm -rf {}
@tar -C $(DISTSRC_PATH) -czf "$(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(ARTIFACT_NAME)"
@echo "Created archive: $(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz"
@ln -sf "$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(BUILDDIR)/$(ARTIFACT_NAME)-src.tar.gz"
@echo "Created symlink: $(BUILDDIR)/$(ARTIFACT_NAME)-src.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 " depend Update build dependencies for current project"
@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) -s -f "$(BASEDIR)/make/configure.mk" $(@)
@echo ""