2013-12-10 16:54:34 +02:00
|
|
|
|
default: all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get rid of default suffixes. FIXME: is this a good idea?
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialise some variables.
|
|
|
|
|
bin_SCRIPTS :=
|
|
|
|
|
noinst_SCRIPTS :=
|
2014-01-09 23:14:34 +02:00
|
|
|
|
OS = $(shell uname -s)
|
2013-12-10 16:54:34 +02:00
|
|
|
|
|
|
|
|
|
|
2013-12-17 13:13:48 +02:00
|
|
|
|
# Default installation paths.
|
|
|
|
|
prefix ?= /usr/local
|
|
|
|
|
libdir ?= $(prefix)/lib
|
|
|
|
|
bindir ?= $(prefix)/bin
|
|
|
|
|
libexecdir ?= $(prefix)/libexec
|
|
|
|
|
datadir ?= $(prefix)/share
|
|
|
|
|
localstatedir ?= $(prefix)/var
|
|
|
|
|
sysconfdir ?= $(prefix)/etc
|
|
|
|
|
|
|
|
|
|
|
2013-12-10 16:54:34 +02:00
|
|
|
|
# Pass -fPIC if we're building dynamic libraries.
|
2013-12-17 13:13:48 +02:00
|
|
|
|
BUILD_SHARED_LIBS ?= 1
|
2013-12-10 16:54:34 +02:00
|
|
|
|
|
|
|
|
|
ifeq ($(BUILD_SHARED_LIBS), 1)
|
|
|
|
|
GLOBAL_CFLAGS += -fPIC
|
|
|
|
|
GLOBAL_CXXFLAGS += -fPIC
|
2014-01-09 23:14:34 +02:00
|
|
|
|
ifneq ($(OS), Darwin)
|
|
|
|
|
GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
|
|
|
|
|
endif
|
2013-12-10 16:54:34 +02:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pass -g if we want debug info.
|
2013-12-17 13:13:48 +02:00
|
|
|
|
BUILD_DEBUG ?= 1
|
2013-12-10 16:54:34 +02:00
|
|
|
|
|
|
|
|
|
ifeq ($(BUILD_DEBUG), 1)
|
|
|
|
|
GLOBAL_CFLAGS += -g
|
|
|
|
|
GLOBAL_CXXFLAGS += -g
|
2013-12-18 17:40:48 +02:00
|
|
|
|
GLOBAL_JAVACFLAGS += -g
|
2013-12-10 16:54:34 +02:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
2013-12-18 16:01:14 +02:00
|
|
|
|
# Utility function for recursively finding files, e.g.
|
|
|
|
|
# ‘$(call rwildcard, path/to/dir, *.c *.h)’.
|
|
|
|
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
|
|
|
|
|
|
|
|
|
|
2014-01-10 23:31:38 +02:00
|
|
|
|
include mk/tracing.mk
|
2013-12-10 16:54:34 +02:00
|
|
|
|
include mk/clean.mk
|
|
|
|
|
include mk/dist.mk
|
|
|
|
|
include mk/install.mk
|
|
|
|
|
include mk/libraries.mk
|
|
|
|
|
include mk/programs.mk
|
2013-12-18 17:40:48 +02:00
|
|
|
|
include mk/jars.mk
|
2013-12-10 16:54:34 +02:00
|
|
|
|
include mk/patterns.mk
|
|
|
|
|
include mk/templates.mk
|
|
|
|
|
include mk/tests.mk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Include all sub-Makefiles.
|
|
|
|
|
define include-sub-makefile =
|
2013-12-12 12:24:03 +02:00
|
|
|
|
d := $$(patsubst %/,%,$$(dir $(1)))
|
2013-12-10 16:54:34 +02:00
|
|
|
|
include $(1)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
$(foreach mf, $(SUBS), $(eval $(call include-sub-makefile, $(mf))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Instantiate stuff.
|
|
|
|
|
$(foreach lib, $(LIBS), $(eval $(call build-library,$(lib))))
|
|
|
|
|
$(foreach prog, $(PROGRAMS), $(eval $(call build-program,$(prog))))
|
2013-12-18 17:40:48 +02:00
|
|
|
|
$(foreach jar, $(JARS), $(eval $(call build-jar,$(jar))))
|
2013-12-10 16:54:34 +02:00
|
|
|
|
$(foreach script, $(bin_SCRIPTS), $(eval $(call install-program-in,$(script),$(bindir))))
|
|
|
|
|
$(foreach script, $(bin_SCRIPTS), $(eval programs_list += $(script)))
|
|
|
|
|
$(foreach script, $(noinst_SCRIPTS), $(eval programs_list += $(script)))
|
|
|
|
|
$(foreach template, $(template_files), $(eval $(call instantiate-template,$(template))))
|
|
|
|
|
$(foreach test, $(INSTALL_TESTS), $(eval $(call run-install-test,$(test))))
|
|
|
|
|
|
|
|
|
|
|
2013-12-18 17:40:48 +02:00
|
|
|
|
all: $(programs_list) $(libs_list) $(jars_list)
|
2013-12-12 12:27:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
help:
|
|
|
|
|
@echo "The following targets are available:"
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo " default: Build default targets"
|
|
|
|
|
@echo " install: Install into \$$(prefix) (currently set to '$(prefix)')"
|
|
|
|
|
@echo " clean: Delete generated files"
|
|
|
|
|
@echo " dryclean: Show what files would be deleted by 'make clean'"
|
|
|
|
|
ifdef PACKAGE_NAME
|
|
|
|
|
@echo " dist: Generate a source distribution"
|
|
|
|
|
endif
|
|
|
|
|
ifdef programs_list
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "The following programs can be built:"
|
|
|
|
|
@echo ""
|
|
|
|
|
@for i in $(programs_list); do echo " $$i"; done
|
|
|
|
|
endif
|
|
|
|
|
ifdef libs_list
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "The following libraries can be built:"
|
|
|
|
|
@echo ""
|
|
|
|
|
@for i in $(libs_list); do echo " $$i"; done
|
|
|
|
|
endif
|
2013-12-18 17:40:48 +02:00
|
|
|
|
ifdef jars_list
|
|
|
|
|
@echo ""
|
|
|
|
|
@echo "The following JARs can be built:"
|
|
|
|
|
@echo ""
|
|
|
|
|
@for i in $(jars_list); do echo " $$i"; done
|
|
|
|
|
endif
|