about summary refs log tree commit diff
path: root/mk/lib.mk
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-12-10T14·54+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-12-10T14·54+0100
commit49a385096e08b42277b7105d5d8d1e0e62b6b7a4 (patch)
tree91b5ca200905ecf88d827752ba8b5a14fe1c9be7 /mk/lib.mk
Initial commit (imported from the Nix repo)
Diffstat (limited to 'mk/lib.mk')
-rw-r--r--mk/lib.mk67
1 files changed, 67 insertions, 0 deletions
diff --git a/mk/lib.mk b/mk/lib.mk
new file mode 100644
index 000000000000..60b6815e9e2e
--- /dev/null
+++ b/mk/lib.mk
@@ -0,0 +1,67 @@
+default: all
+
+
+# Include Autoconf variables.
+template_files += Makefile.config
+include Makefile.config
+
+
+# Get rid of default suffixes. FIXME: is this a good idea?
+.SUFFIXES:
+
+
+# Initialise some variables.
+QUIET = @
+bin_SCRIPTS :=
+noinst_SCRIPTS :=
+
+
+# Pass -fPIC if we're building dynamic libraries.
+BUILD_SHARED_LIBS = 1
+
+ifeq ($(BUILD_SHARED_LIBS), 1)
+  GLOBAL_CFLAGS += -fPIC
+  GLOBAL_CXXFLAGS += -fPIC
+  GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
+endif
+
+
+# Pass -g if we want debug info.
+BUILD_DEBUG = 1
+
+ifeq ($(BUILD_DEBUG), 1)
+  GLOBAL_CFLAGS += -g
+  GLOBAL_CXXFLAGS += -g
+endif
+
+
+include mk/clean.mk
+include mk/dist.mk
+include mk/install.mk
+include mk/libraries.mk
+include mk/programs.mk
+include mk/patterns.mk
+include mk/templates.mk
+include mk/tests.mk
+
+
+# Include all sub-Makefiles.
+define include-sub-makefile =
+  d := $$(patsubst %/, %, $$(dir $(1)))
+  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))))
+$(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))))
+
+
+all: $(programs_list) $(libs_list)