Skip to content

Commit 74fc04f

Browse files
committed
Updated build system
1 parent aa2acfb commit 74fc04f

File tree

8 files changed

+247
-205
lines changed

8 files changed

+247
-205
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*******************************************************************************
44

55
=== 0.5.5 ===
6+
- Updated build system.
67

78
=== 0.5.4 ===
89
* Split all interface code into lsp-r3d-iface.

Makefile

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
# along with lsp-r3d-base-lib. If not, see <https://www.gnu.org/licenses/>.
2020
#
2121

22+
# Command-line flag to silence nested $(MAKE).
23+
ifneq ($(VERBOSE),1)
24+
.SILENT:
25+
endif
26+
2227
# Location
2328
BASEDIR := $(CURDIR)
2429
MODULES := $(BASEDIR)/modules
@@ -44,76 +49,76 @@ DISTSRC = $(DISTSRC_PATH)/$(ARTIFACT_NAME)
4449
.PHONY: all compile install uninstall depend clean
4550

4651
compile all install uninstall depend:
47-
@$(CHK_CONFIG)
48-
@$(MAKE) -s -C "$(BASEDIR)/src" $(@) CONFIG="$(CONFIG)" DESTDIR="$(DESTDIR)"
52+
$(CHK_CONFIG)
53+
$(MAKE) -C "$(BASEDIR)/src" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" DESTDIR="$(DESTDIR)"
4954

5055
clean:
51-
@echo "Cleaning build directory $(BUILDDIR)"
52-
@-rm -rf $(BUILDDIR)
53-
@echo "Clean OK"
56+
echo "Cleaning build directory $(BUILDDIR)"
57+
-rm -rf $(BUILDDIR)
58+
echo "Clean OK"
5459

5560
# Module-related tasks
5661
.PHONY: fetch tree prune
5762
fetch:
58-
@$(CHK_CONFIG)
59-
@echo "Fetching desired source code dependencies"
60-
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" $(@) BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
61-
@echo "Fetch OK"
63+
$(CHK_CONFIG)
64+
echo "Fetching desired source code dependencies"
65+
$(MAKE) -f "$(BASEDIR)/make/modules.mk" $(@) VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
66+
echo "Fetch OK"
6267

6368
tree:
64-
@echo "Fetching all possible source code dependencies"
65-
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" $(@) BASEDIR="$(BASEDIR)" TREE="1"
66-
@echo "Fetch OK"
69+
echo "Fetching all possible source code dependencies"
70+
$(MAKE) -f "$(BASEDIR)/make/modules.mk" $(@) VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" TREE="1"
71+
echo "Fetch OK"
6772

6873
prune: clean
69-
@echo "Pruning the whole project tree"
70-
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" prune BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
71-
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" prune BASEDIR="$(BASEDIR)" TREE="1"
72-
@-rm -rf "$(CONFIG)"
73-
@echo "Prune OK"
74+
echo "Pruning the whole project tree"
75+
$(MAKE) -f "$(BASEDIR)/make/modules.mk" prune VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" CONFIG="$(CONFIG)"
76+
$(MAKE) -f "$(BASEDIR)/make/modules.mk" prune VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" TREE="1"
77+
-rm -rf "$(CONFIG)"
78+
echo "Prune OK"
7479

7580
# Configuration-related targets
7681
.PHONY: config help chkconfig
7782

7883
testconfig:
79-
@$(MAKE) -s -f "$(BASEDIR)/make/configure.mk" $(@) CONFIG="$(CONFIG)" TEST="1" $(MAKEFLAGS)
84+
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" TEST="1" -$(MAKEFLAGS)
8085

8186
config:
82-
@$(MAKE) -s -f "$(BASEDIR)/make/configure.mk" $(@) CONFIG="$(CONFIG)" $(MAKEFLAGS)
87+
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)" CONFIG="$(CONFIG)" -$(MAKEFLAGS)
8388

8489
# Release-related targets
8590
.PHONY: distsrc
8691
distsrc:
87-
@echo "Building source code archive"
88-
@mkdir -p "$(DISTSRC)/modules"
89-
@$(MAKE) -s -f "$(BASEDIR)/make/modules.mk" tree BASEDIR="$(BASEDIR)" MODULES="$(DISTSRC)/modules" TREE="1"
90-
@cp -R $(BASEDIR)/include $(BASEDIR)/make $(BASEDIR)/src "$(DISTSRC)/"
91-
@cp $(BASEDIR)/CHANGELOG $(BASEDIR)/COPYING* $(BASEDIR)/Makefile $(BASEDIR)/*.mk "$(DISTSRC)/"
92-
@find "$(DISTSRC)" -iname '.git' | xargs -exec rm -rf {}
93-
@find "$(DISTSRC)" -iname '.gitignore' | xargs -exec rm -rf {}
94-
@tar -C $(DISTSRC_PATH) -czf "$(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(ARTIFACT_NAME)"
95-
@echo "Created archive: $(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz"
96-
@ln -sf "$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(BUILDDIR)/$(ARTIFACT_NAME)-src.tar.gz"
97-
@echo "Created symlink: $(BUILDDIR)/$(ARTIFACT_NAME)-src.tar.gz"
98-
@rm -rf $(DISTSRC_PATH)
99-
@echo "Build OK"
92+
echo "Building source code archive"
93+
mkdir -p "$(DISTSRC)/modules"
94+
$(MAKE) -f "$(BASEDIR)/make/modules.mk" tree VERBOSE="$(VERBOSE)" BASEDIR="$(BASEDIR)" MODULES="$(DISTSRC)/modules" TREE="1"
95+
cp -R $(BASEDIR)/include $(BASEDIR)/make $(BASEDIR)/src "$(DISTSRC)/"
96+
cp $(BASEDIR)/CHANGELOG $(BASEDIR)/COPYING* $(BASEDIR)/Makefile $(BASEDIR)/*.mk "$(DISTSRC)/"
97+
find "$(DISTSRC)" -iname '.git' | xargs -exec rm -rf {}
98+
find "$(DISTSRC)" -iname '.gitignore' | xargs -exec rm -rf {}
99+
tar -C $(DISTSRC_PATH) -czf "$(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(ARTIFACT_NAME)"
100+
echo "Created archive: $(BUILDDIR)/$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz"
101+
ln -sf "$(ARTIFACT_NAME)-$(ARTIFACT_VERSION)-src.tar.gz" "$(BUILDDIR)/$(ARTIFACT_NAME)-src.tar.gz"
102+
echo "Created symlink: $(BUILDDIR)/$(ARTIFACT_NAME)-src.tar.gz"
103+
rm -rf $(DISTSRC_PATH)
104+
echo "Build OK"
100105

101106
# Help
102107
help:
103-
@echo "Available targets:"
104-
@echo " all Build all binaries"
105-
@echo " clean Clean all build files and configuration file"
106-
@echo " config Configure build"
107-
@echo " depend Update build dependencies for current project"
108-
@echo " distsrc Make tarball with source code for packagers"
109-
@echo " fetch Fetch all desired source code dependencies from git"
110-
@echo " help Print this help message"
111-
@echo " info Output build configuration"
112-
@echo " install Install all binaries into the system"
113-
@echo " prune Cleanup build and all fetched dependencies from git"
114-
@echo " tree Fetch all possible source code dependencies from git"
115-
@echo " to make source code portable between machines"
116-
@echo " uninstall Uninstall binaries"
117-
@echo ""
118-
@$(MAKE) -s -f "$(BASEDIR)/make/configure.mk" $(@)
119-
@echo ""
108+
echo "Available targets:"
109+
echo " all Build all binaries"
110+
echo " clean Clean all build files and configuration file"
111+
echo " config Configure build"
112+
echo " depend Update build dependencies for current project"
113+
echo " distsrc Make tarball with source code for packagers"
114+
echo " fetch Fetch all desired source code dependencies from git"
115+
echo " help Print this help message"
116+
echo " info Output build configuration"
117+
echo " install Install all binaries into the system"
118+
echo " prune Cleanup build and all fetched dependencies from git"
119+
echo " tree Fetch all possible source code dependencies from git"
120+
echo " to make source code portable between machines"
121+
echo " uninstall Uninstall binaries"
122+
echo ""
123+
$(MAKE) -f "$(BASEDIR)/make/configure.mk" $(@) VERBOSE="$(VERBOSE)"
124+
echo ""

make/configure.mk

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# You should have received a copy of the GNU Lesser General Public License
1818
# along with lsp-r3d-base-lib. If not, see <https://www.gnu.org/licenses/>.
1919
#
20+
ifneq ($(VERBOSE),1)
21+
.SILENT:
22+
endif
2023

2124
# Definitions
2225
PREFIX := /usr/local
@@ -168,39 +171,39 @@ CONFIG_VARS = \
168171
.PHONY: $(CONFIG_VARS)
169172

170173
prepare:
171-
@echo "Configuring build..."
172-
@echo "# Project settings" > "$(CONFIG)"
174+
echo "Configuring build..."
175+
echo "# Project settings" > "$(CONFIG)"
173176

174177
$(CONFIG_VARS): prepare
175-
@echo "$(@)=$($(@))" >> "$(CONFIG)"
178+
echo "$(@)=$($(@))" >> "$(CONFIG)"
176179

177180
config: $(CONFIG_VARS)
178-
@echo "Configured OK"
181+
echo "Configured OK"
179182

180183
help: | toolvars sysvars
181-
@echo ""
182-
@echo "List of variables for each dependency:"
183-
@echo " <ARTIFACT>_BIN location to put all binaries when building artifact"
184-
@echo " <ARTIFACT>_BRANCH git branch used to checkout source code"
185-
@echo " <ARTIFACT>_CFLAGS C/C++ flags to access headers of the artifact"
186-
@echo " <ARTIFACT>_DESC Full description of the artifact"
187-
@echo " <ARTIFACT>_INC path to include files of the artifact"
188-
@echo " <ARTIFACT>_LDFLAGS linker flags to link with artifact"
189-
@echo " <ARTIFACT>_MFLAGS artifact-specific compilation flags"
190-
@echo " <ARTIFACT>_NAME the artifact name used in pathnames"
191-
@echo " <ARTIFACT>_OBJ path to output object file for artifact"
192-
@echo " <ARTIFACT>_PATH location of the source code of the artifact"
193-
@echo " <ARTIFACT>_SRC path to source code files of the artifact"
194-
@echo " <ARTIFACT>_TEST location of test files of the artifact"
195-
@echo " <ARTIFACT>_TYPE artifact usage type"
196-
@echo " - src - use sources and headers from git"
197-
@echo " - hdr - use headers only from git"
198-
@echo " - pkg - use pkgconfig for configuration"
199-
@echo " - lib - use system headers and -l<libname> flags"
200-
@echo " - opt - use optional configuration"
201-
@echo " <ARTIFACT>_URL location of the artifact git repoisitory"
202-
@echo " <ARTIFACT>_VERSION version of the artifact used for building"
203-
@echo ""
204-
@echo "Artifacts used for build:"
205-
@echo " $(DEPENDENCIES)"
184+
echo ""
185+
echo "List of variables for each dependency:"
186+
echo " <ARTIFACT>_BIN location to put all binaries when building artifact"
187+
echo " <ARTIFACT>_BRANCH git branch used to checkout source code"
188+
echo " <ARTIFACT>_CFLAGS C/C++ flags to access headers of the artifact"
189+
echo " <ARTIFACT>_DESC Full description of the artifact"
190+
echo " <ARTIFACT>_INC path to include files of the artifact"
191+
echo " <ARTIFACT>_LDFLAGS linker flags to link with artifact"
192+
echo " <ARTIFACT>_MFLAGS artifact-specific compilation flags"
193+
echo " <ARTIFACT>_NAME the artifact name used in pathnames"
194+
echo " <ARTIFACT>_OBJ path to output object file for artifact"
195+
echo " <ARTIFACT>_PATH location of the source code of the artifact"
196+
echo " <ARTIFACT>_SRC path to source code files of the artifact"
197+
echo " <ARTIFACT>_TEST location of test files of the artifact"
198+
echo " <ARTIFACT>_TYPE artifact usage type"
199+
echo " - src - use sources and headers from git"
200+
echo " - hdr - use headers only from git"
201+
echo " - pkg - use pkgconfig for configuration"
202+
echo " - lib - use system headers and -l<libname> flags"
203+
echo " - opt - use optional configuration"
204+
echo " <ARTIFACT>_URL location of the artifact git repoisitory"
205+
echo " <ARTIFACT>_VERSION version of the artifact used for building"
206+
echo ""
207+
echo "Artifacts used for build:"
208+
echo " $(DEPENDENCIES)"
206209

make/modules.mk

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# You should have received a copy of the GNU Lesser General Public License
1818
# along with lsp-r3d-base-lib. If not, see <https://www.gnu.org/licenses/>.
1919
#
20+
ifneq ($(VERBOSE),1)
21+
.SILENT:
22+
endif
2023

2124
BASEDIR := $(CURDIR)
2225
DEPLIST := $(BASEDIR)/dependencies.mk
@@ -64,27 +67,27 @@ ALL_PATHS = $(foreach dep, $(ALL_SRC_MODULES) $(ALL_HDR_MODULES), $($(
6467
.PHONY: fetch prune clean
6568

6669
$(ALL_SRC_MODULES) $(ALL_HDR_MODULES):
67-
@echo "Cloning $($(@)_URL) -> $($(@)_PATH) [$($(@)_BRANCH)]"
68-
@test -f "$($(@)_PATH)/.git/config" || $(GIT) clone "$($(@)_URL)" "$($(@)_PATH)"
69-
@$(GIT) -C "$($(@)_PATH)" reset --hard
70-
@$(GIT) -C "$($(@)_PATH)" fetch origin --force
71-
@$(GIT) -C "$($(@)_PATH)" fetch origin '+refs/heads/*:refs/tags/*' --force
72-
@$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout origin/$($(@)_BRANCH) || \
73-
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout refs/tags/$($(@)_BRANCH) || \
74-
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout origin/$($(@)_NAME)-$($(@)_BRANCH) || \
75-
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout refs/tags/$($(@)_NAME)-$($(@)_BRANCH)
70+
echo "Cloning $($(@)_URL) -> $($(@)_PATH) [$($(@)_BRANCH)]"
71+
test -f "$($(@)_PATH)/.git/config" || $(GIT) clone "$($(@)_URL)" "$($(@)_PATH)"
72+
$(GIT) -C "$($(@)_PATH)" reset --hard
73+
$(GIT) -C "$($(@)_PATH)" fetch origin --force
74+
$(GIT) -C "$($(@)_PATH)" fetch origin '+refs/heads/*:refs/tags/*' --force
75+
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout -B "$($(@)_BRANCH)" "origin/$($(@)_BRANCH)" || \
76+
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout "refs/tags/$($(@)_BRANCH)" || \
77+
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout -B "$($(@)_NAME)-$($(@)_BRANCH)" "origin/$($(@)_NAME)-$($(@)_BRANCH)" || \
78+
$(GIT) -c advice.detachedHead=false -C "$($(@)_PATH)" checkout "refs/tags/$($(@)_NAME)-$($(@)_BRANCH)"
7679

7780
$(ALL_PATHS):
78-
@echo "Removing $(notdir $(@))"
79-
@-rm -rf $(@)
81+
echo "Removing $(notdir $(@))"
82+
-rm -rf $(@)
8083

8184
fetch: $(SRC_MODULES) $(HDR_MODULES)
8285

8386
tree: $(ALL_SRC_MODULES) $(ALL_HDR_MODULES)
8487

8588
clean:
86-
@echo rm -rf "$($(ARTIFACT_VARS)_BIN)/$(ARTIFACT_NAME)"
87-
@-rm -rf "$($(ARTIFACT_VARS)_BIN)/$(ARTIFACT_NAME)"
89+
echo rm -rf "$($(ARTIFACT_VARS)_BIN)/$(ARTIFACT_NAME)"
90+
-rm -rf "$($(ARTIFACT_VARS)_BIN)/$(ARTIFACT_NAME)"
8891

8992
prune: $(ALL_PATHS)
9093

0 commit comments

Comments
 (0)