2013-12-10 15:54:34 +01:00
|
|
|
default: all
|
|
|
|
|
|
|
|
|
|
|
|
# Get rid of default suffixes. FIXME: is this a good idea?
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
|
|
|
|
# Initialise some variables.
|
2014-02-01 12:20:06 +01:00
|
|
|
bin-scripts :=
|
|
|
|
noinst-scripts :=
|
2014-01-31 15:33:12 +01:00
|
|
|
man-pages :=
|
2014-02-01 12:20:06 +01:00
|
|
|
install-tests :=
|
2014-02-01 14:22:08 +01:00
|
|
|
dist-files :=
|
2014-01-09 22:14:34 +01:00
|
|
|
OS = $(shell uname -s)
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
|
2013-12-17 12:13:48 +01: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
|
2014-01-31 15:33:12 +01:00
|
|
|
mandir ?= $(prefix)/share/man
|
2013-12-17 12:13:48 +01:00
|
|
|
|
|
|
|
|
2013-12-10 15:54:34 +01:00
|
|
|
# Pass -fPIC if we're building dynamic libraries.
|
2013-12-17 12:13:48 +01:00
|
|
|
BUILD_SHARED_LIBS ?= 1
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
ifeq ($(BUILD_SHARED_LIBS), 1)
|
|
|
|
GLOBAL_CFLAGS += -fPIC
|
|
|
|
GLOBAL_CXXFLAGS += -fPIC
|
2014-01-09 22:14:34 +01:00
|
|
|
ifneq ($(OS), Darwin)
|
2014-04-03 17:35:16 +02:00
|
|
|
ifneq ($(OS), SunOS)
|
2014-01-09 22:14:34 +01:00
|
|
|
GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
|
2014-04-03 17:35:16 +02:00
|
|
|
endif
|
2014-01-09 22:14:34 +01:00
|
|
|
endif
|
2014-03-03 15:19:04 +01:00
|
|
|
SET_RPATH_TO_LIBS ?= 1
|
2013-12-10 15:54:34 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-09-04 19:35:24 +02:00
|
|
|
# On MacOS X, some boost libraries have an -mt suffix
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
ifndef NIX_STORE
|
|
|
|
BOOST_SUFFIX = -mt
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2013-12-10 15:54:34 +01:00
|
|
|
# Pass -g if we want debug info.
|
2013-12-17 12:13:48 +01:00
|
|
|
BUILD_DEBUG ?= 1
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
ifeq ($(BUILD_DEBUG), 1)
|
|
|
|
GLOBAL_CFLAGS += -g
|
|
|
|
GLOBAL_CXXFLAGS += -g
|
2013-12-18 16:40:48 +01:00
|
|
|
GLOBAL_JAVACFLAGS += -g
|
2013-12-10 15:54:34 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-02-01 11:31:25 +01:00
|
|
|
include mk/functions.mk
|
2014-01-10 22:31:38 +01:00
|
|
|
include mk/tracing.mk
|
2013-12-10 15:54:34 +01:00
|
|
|
include mk/clean.mk
|
|
|
|
include mk/install.mk
|
|
|
|
include mk/libraries.mk
|
|
|
|
include mk/programs.mk
|
2013-12-18 16:40:48 +01:00
|
|
|
include mk/jars.mk
|
2013-12-10 15:54:34 +01:00
|
|
|
include mk/patterns.mk
|
|
|
|
include mk/templates.mk
|
|
|
|
include mk/tests.mk
|
|
|
|
|
|
|
|
|
|
|
|
# Include all sub-Makefiles.
|
2014-02-04 11:02:49 +01:00
|
|
|
define include-sub-makefile
|
2013-12-12 11:24:03 +01:00
|
|
|
d := $$(patsubst %/,%,$$(dir $(1)))
|
2013-12-10 15:54:34 +01:00
|
|
|
include $(1)
|
|
|
|
endef
|
|
|
|
|
2014-02-01 12:20:06 +01:00
|
|
|
$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf))))
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Instantiate stuff.
|
2014-02-01 12:20:06 +01:00
|
|
|
$(foreach lib, $(libraries), $(eval $(call build-library,$(lib))))
|
|
|
|
$(foreach prog, $(programs), $(eval $(call build-program,$(prog))))
|
|
|
|
$(foreach jar, $(jars), $(eval $(call build-jar,$(jar))))
|
|
|
|
$(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))))
|
2014-01-31 15:33:12 +01:00
|
|
|
$(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file))))))
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
|
2014-02-01 14:22:08 +01:00
|
|
|
include mk/dist.mk
|
|
|
|
|
|
|
|
|
2014-02-01 11:47:34 +01:00
|
|
|
.PHONY: default all man help
|
2014-01-31 15:33:12 +01:00
|
|
|
|
2014-02-01 12:20:06 +01:00
|
|
|
all: $(programs-list) $(libs-list) $(jars-list) $(man-pages)
|
2014-01-31 15:33:12 +01:00
|
|
|
|
|
|
|
man: $(man-pages)
|
2013-12-12 11:27:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo "The following targets are available:"
|
|
|
|
@echo ""
|
|
|
|
@echo " default: Build default targets"
|
2014-01-31 15:33:12 +01:00
|
|
|
ifdef man-pages
|
|
|
|
@echo " man: Generate manual pages"
|
|
|
|
endif
|
2014-02-01 11:47:34 +01:00
|
|
|
@$(print-top-help)
|
2014-02-01 12:20:06 +01:00
|
|
|
ifdef programs-list
|
2013-12-12 11:27:47 +01:00
|
|
|
@echo ""
|
|
|
|
@echo "The following programs can be built:"
|
|
|
|
@echo ""
|
2014-02-01 12:20:06 +01:00
|
|
|
@for i in $(programs-list); do echo " $$i"; done
|
2013-12-12 11:27:47 +01:00
|
|
|
endif
|
2014-02-01 12:20:06 +01:00
|
|
|
ifdef libs-list
|
2013-12-12 11:27:47 +01:00
|
|
|
@echo ""
|
|
|
|
@echo "The following libraries can be built:"
|
|
|
|
@echo ""
|
2014-02-01 12:20:06 +01:00
|
|
|
@for i in $(libs-list); do echo " $$i"; done
|
2013-12-12 11:27:47 +01:00
|
|
|
endif
|
2014-02-01 12:20:06 +01:00
|
|
|
ifdef jars-list
|
2013-12-18 16:40:48 +01:00
|
|
|
@echo ""
|
|
|
|
@echo "The following JARs can be built:"
|
|
|
|
@echo ""
|
2014-02-01 12:20:06 +01:00
|
|
|
@for i in $(jars-list); do echo " $$i"; done
|
2013-12-18 16:40:48 +01:00
|
|
|
endif
|
2014-02-01 11:47:34 +01:00
|
|
|
@echo ""
|
|
|
|
@echo "The following variables control the build:"
|
|
|
|
@echo ""
|
|
|
|
@echo " BUILD_SHARED_LIBS ($(BUILD_SHARED_LIBS)): Whether to build shared libraries"
|
|
|
|
@echo " BUILD_DEBUG ($(BUILD_DEBUG)): Whether to include debug symbols"
|
|
|
|
@echo " CC ($(CC)): C compiler to be used"
|
|
|
|
@echo " CFLAGS: Flags for the C compiler"
|
|
|
|
@echo " CXX ($(CXX)): C++ compiler to be used"
|
|
|
|
@echo " CXXFLAGS: Flags for the C++ compiler"
|
|
|
|
@$(print-var-help)
|