Make variable names more regular

This commit is contained in:
Eelco Dolstra 2014-02-01 12:20:06 +01:00
parent 35107038f7
commit ec1738589a
8 changed files with 43 additions and 42 deletions

View file

@ -1,10 +1,10 @@
clean_files := clean-files :=
clean: clean:
$(suppress) rm -fv -- $(clean_files) $(suppress) rm -fv -- $(clean-files)
dryclean: dryclean:
@for i in $(clean_files); do if [ -e $$i ]; then echo $$i; fi; done | sort @for i in $(clean-files); do if [ -e $$i ]; then echo $$i; fi; done | sort
print-top-help += \ print-top-help += \
echo " clean: Delete generated files"; \ echo " clean: Delete generated files"; \

12
dist.mk
View file

@ -1,15 +1,15 @@
ifdef PACKAGE_NAME ifdef PACKAGE_NAME
dist_name = $(PACKAGE_NAME)-$(PACKAGE_VERSION) dist-name = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
dist_files := dist-files :=
dist: $(dist_name).tar.bz2 dist: $(dist-name).tar.bz2
$(dist_name).tar.bz2: $(dist_files) $(dist-name).tar.bz2: $(dist-files)
$(suppress) tar cvfj $@ $(dist_files) --transform 's,^,$(dist_name)/,' $(suppress) tar cvfj $@ $(dist-files) --transform 's,^,$(dist-name)/,'
clean_files += $(dist_name).tar.bz2 clean-files += $(dist-name).tar.bz2
print-top-help += echo " dist: Generate a source distribution"; print-top-help += echo " dist: Generate a source distribution";

View file

@ -22,8 +22,8 @@ define build-jar =
install: $$($(1)_INSTALL_PATH) install: $$($(1)_INSTALL_PATH)
jars_list += $$($(1)_PATH) jars-list += $$($(1)_PATH)
clean_files += $$($(1)_PATH) clean-files += $$($(1)_PATH)
endef endef

37
lib.mk
View file

@ -6,9 +6,10 @@ default: all
# Initialise some variables. # Initialise some variables.
bin_SCRIPTS := bin-scripts :=
noinst_SCRIPTS := noinst-scripts :=
man-pages := man-pages :=
install-tests :=
OS = $(shell uname -s) OS = $(shell uname -s)
@ -64,24 +65,24 @@ define include-sub-makefile =
include $(1) include $(1)
endef endef
$(foreach mf, $(SUBS), $(eval $(call include-sub-makefile, $(mf)))) $(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf))))
# Instantiate stuff. # Instantiate stuff.
$(foreach lib, $(LIBS), $(eval $(call build-library,$(lib)))) $(foreach lib, $(libraries), $(eval $(call build-library,$(lib))))
$(foreach prog, $(PROGRAMS), $(eval $(call build-program,$(prog)))) $(foreach prog, $(programs), $(eval $(call build-program,$(prog))))
$(foreach jar, $(JARS), $(eval $(call build-jar,$(jar)))) $(foreach jar, $(jars), $(eval $(call build-jar,$(jar))))
$(foreach script, $(bin_SCRIPTS), $(eval $(call install-program-in,$(script),$(bindir)))) $(foreach script, $(bin-scripts), $(eval $(call install-program-in,$(script),$(bindir))))
$(foreach script, $(bin_SCRIPTS), $(eval programs_list += $(script))) $(foreach script, $(bin-scripts), $(eval programs-list += $(script)))
$(foreach script, $(noinst_SCRIPTS), $(eval programs_list += $(script))) $(foreach script, $(noinst-scripts), $(eval programs-list += $(script)))
$(foreach template, $(template_files), $(eval $(call instantiate-template,$(template)))) $(foreach template, $(template-files), $(eval $(call instantiate-template,$(template))))
$(foreach test, $(INSTALL_TESTS), $(eval $(call run-install-test,$(test)))) $(foreach test, $(install-tests), $(eval $(call run-install-test,$(test))))
$(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file)))))) $(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file))))))
.PHONY: default all man help .PHONY: default all man help
all: $(programs_list) $(libs_list) $(jars_list) $(man-pages) all: $(programs-list) $(libs-list) $(jars-list) $(man-pages)
man: $(man-pages) man: $(man-pages)
@ -94,23 +95,23 @@ ifdef man-pages
@echo " man: Generate manual pages" @echo " man: Generate manual pages"
endif endif
@$(print-top-help) @$(print-top-help)
ifdef programs_list ifdef programs-list
@echo "" @echo ""
@echo "The following programs can be built:" @echo "The following programs can be built:"
@echo "" @echo ""
@for i in $(programs_list); do echo " $$i"; done @for i in $(programs-list); do echo " $$i"; done
endif endif
ifdef libs_list ifdef libs-list
@echo "" @echo ""
@echo "The following libraries can be built:" @echo "The following libraries can be built:"
@echo "" @echo ""
@for i in $(libs_list); do echo " $$i"; done @for i in $(libs-list); do echo " $$i"; done
endif endif
ifdef jars_list ifdef jars-list
@echo "" @echo ""
@echo "The following JARs can be built:" @echo "The following JARs can be built:"
@echo "" @echo ""
@for i in $(jars_list); do echo " $$i"; done @for i in $(jars-list); do echo " $$i"; done
endif endif
@echo "" @echo ""
@echo "The following variables control the build:" @echo "The following variables control the build:"

View file

@ -1,4 +1,4 @@
libs_list := libs-list :=
ifeq ($(OS), Darwin) ifeq ($(OS), Darwin)
SO_EXT = dylib SO_EXT = dylib
@ -110,7 +110,7 @@ define build-library =
$(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn)))
-include $$($(1)_DEPS) -include $$($(1)_DEPS)
libs_list += $$($(1)_PATH) libs-list += $$($(1)_PATH)
clean_files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) clean-files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS)
dist_files += $$(_srcs) dist-files += $$(_srcs)
endef endef

View file

@ -1,4 +1,4 @@
programs_list := programs-list :=
# Build a program with symbolic name $(1). The program is defined by # Build a program with symbolic name $(1). The program is defined by
# various variables prefixed by $(1)_: # various variables prefixed by $(1)_:
@ -56,7 +56,7 @@ define build-program =
$(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn)))
-include $$($(1)_DEPS) -include $$($(1)_DEPS)
programs_list += $$($(1)_PATH) programs-list += $$($(1)_PATH)
clean_files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) clean-files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS)
dist_files += $$(_srcs) dist-files += $$(_srcs)
endef endef

View file

@ -1,10 +1,10 @@
template_files := template-files :=
# Create the file $(1) from $(1).in by running config.status (which # Create the file $(1) from $(1).in by running config.status (which
# substitutes all @var@ variables set by the configure script). # substitutes all @var@ variables set by the configure script).
define instantiate-template = define instantiate-template =
clean_files += $(1) clean-files += $(1)
endef endef

View file

@ -6,15 +6,15 @@ define run-install-test =
# Run the test in its own directory to mimick Automake behaviour. # Run the test in its own directory to mimick Automake behaviour.
$1.run: $1 $(_PREV_TEST) $1.run: $1 $(_PREV_TEST)
_installcheck_list += $1 _installcheck-list += $1
endef endef
installcheck: install installcheck: install
@total=0; failed=0; for i in $(_installcheck_list); do \ @total=0; failed=0; for i in $(_installcheck-list); do \
total=$$((total + 1)); \ total=$$((total + 1)); \
echo "running test $$i"; \ echo "running test $$i"; \
if (cd $$(dirname $$i) && $(TESTS_ENVIRONMENT) $$(basename $$i)); then \ if (cd $$(dirname $$i) && $(tests-environment) $$(basename $$i)); then \
echo "PASS: $$i"; \ echo "PASS: $$i"; \
else \ else \
echo "FAIL: $$i"; \ echo "FAIL: $$i"; \