aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-01-09 16:12:02 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-01-09 16:12:02 +0100
commit55c9a40613fefda6622aa9acd22cce4006fd1077 (patch)
treecd592d5836af42feeeca64ac3ebb77037b93a076 /mk
parent259086de841d155f7951c2cc50f799a4631aa512 (diff)
Move stuff to top-level
This makes it easier to use with "git subtree".
Diffstat (limited to 'mk')
-rw-r--r--mk/clean.mk7
-rw-r--r--mk/dist.mk14
-rw-r--r--mk/install.mk53
-rw-r--r--mk/jars.mk29
-rw-r--r--mk/lib.mk110
-rw-r--r--mk/libraries.mk104
-rw-r--r--mk/patterns.mk8
-rw-r--r--mk/programs.mk62
-rw-r--r--mk/templates.mk10
-rw-r--r--mk/tests.mk29
10 files changed, 0 insertions, 426 deletions
diff --git a/mk/clean.mk b/mk/clean.mk
deleted file mode 100644
index 7dba76c5d..000000000
--- a/mk/clean.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-clean_files :=
-
-clean:
- $(QUIET) rm -fv -- $(clean_files)
-
-dryclean:
- @for i in $(clean_files); do if [ -e $$i ]; then echo $$i; fi; done | sort
diff --git a/mk/dist.mk b/mk/dist.mk
deleted file mode 100644
index 444c58b3f..000000000
--- a/mk/dist.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-ifdef PACKAGE_NAME
-
-dist_name = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
-
-dist_files :=
-
-dist: $(dist_name).tar.bz2
-
-$(dist_name).tar.bz2: $(dist_files)
- $(QUIET) tar cvfj $@ $(dist_files) --transform 's,^,$(dist_name)/,'
-
-clean_files += $(dist_name).tar.bz2
-
-endif
diff --git a/mk/install.mk b/mk/install.mk
deleted file mode 100644
index c5eb8eb37..000000000
--- a/mk/install.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-# Add a rule for creating $(1) as a directory. This template may be
-# called multiple times for the same directory.
-define create-dir =
- ifndef $(1)_SEEN
- $(1)_SEEN = 1
- $(1):
- $(QUIET) install -d $(1)
- endif
-endef
-
-
-# Add a rule for installing file $(1) as file $(2) with mode $(3).
-# The directory containing $(2) will be created automatically.
-define install-file-as =
-
- install: $(2)
-
- $$(eval $$(call create-dir,$$(dir $(2))))
-
- $(2): $(1) | $$(dir $(2))
- $(QUIET) install -m $(3) $(1) $(2)
-
-endef
-
-
-# Add a rule for installing file $(1) in directory $(2) with mode
-# $(3). The directory will be created automatically.
-define install-file-in =
- $$(eval $$(call install-file-as,$(1),$(2)/$$(notdir $(1)),$(3)))
-endef
-
-
-define install-program-in =
- $$(eval $$(call install-file-in,$(1),$(2),0755))
-endef
-
-
-define install-data-in =
- $$(eval $$(call install-file-in,$(1),$(2),0644))
-endef
-
-
-# Install a symlink from $(2) to $(1). Note that $(1) need not exist.
-define install-symlink =
-
- install: $(2)
-
- $$(eval $$(call create-dir,$$(dir $(2))))
-
- $(2): | $$(dir $(2))
- $(QUIET) ln -sfn $(1) $(2)
-
-endef
diff --git a/mk/jars.mk b/mk/jars.mk
deleted file mode 100644
index 5d459c0a9..000000000
--- a/mk/jars.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-define build-jar =
- $(1)_NAME ?= $(1)
-
- _d := $$(strip $$($(1)_DIR))
-
- $(1)_PATH := $$(_d)/$$($(1)_NAME).jar
-
- $(1)_TMPDIR := $$(_d)/.$$($(1)_NAME).jar.tmp
-
- $$($(1)_PATH): $$($(1)_SOURCES)
- @rm -rf $$($(1)_TMPDIR)
- @mkdir -p $$($(1)_TMPDIR)
- $(QUIET) javac $(GLOBAL_JAVACFLAGS) $$($(1)_JAVACFLAGS) -d $$($(1)_TMPDIR) $$($(1)_SOURCES)
- $(QUIET) jar cf $$($(1)_PATH) -C $$($(1)_TMPDIR) .
- @rm -rf $$($(1)_TMPDIR)
-
- $(1)_INSTALL_DIR ?= $$(libdir)/java
-
- $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).jar
-
- $$(eval $$(call install-file-as, $$($(1)_PATH), $$($(1)_INSTALL_PATH), 0644))
-
- install: $$($(1)_INSTALL_PATH)
-
- jars_list += $$($(1)_PATH)
-
- clean_files += $$($(1)_PATH)
-
-endef
diff --git a/mk/lib.mk b/mk/lib.mk
deleted file mode 100644
index 2d8ceef55..000000000
--- a/mk/lib.mk
+++ /dev/null
@@ -1,110 +0,0 @@
-default: all
-
-
-# Get rid of default suffixes. FIXME: is this a good idea?
-.SUFFIXES:
-
-
-# Initialise some variables.
-QUIET = @
-bin_SCRIPTS :=
-noinst_SCRIPTS :=
-
-
-# Default installation paths.
-prefix ?= /usr/local
-libdir ?= $(prefix)/lib
-bindir ?= $(prefix)/bin
-libexecdir ?= $(prefix)/libexec
-datadir ?= $(prefix)/share
-localstatedir ?= $(prefix)/var
-sysconfdir ?= $(prefix)/etc
-
-
-# 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
- GLOBAL_JAVACFLAGS += -g
-endif
-
-
-# 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))
-
-
-include mk/clean.mk
-include mk/dist.mk
-include mk/install.mk
-include mk/libraries.mk
-include mk/programs.mk
-include mk/jars.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 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))))
-
-
-all: $(programs_list) $(libs_list) $(jars_list)
-
-
-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
-ifdef jars_list
- @echo ""
- @echo "The following JARs can be built:"
- @echo ""
- @for i in $(jars_list); do echo " $$i"; done
-endif
diff --git a/mk/libraries.mk b/mk/libraries.mk
deleted file mode 100644
index bc258b799..000000000
--- a/mk/libraries.mk
+++ /dev/null
@@ -1,104 +0,0 @@
-libs_list :=
-
-# Build a library with symbolic name $(1). The library is defined by
-# various variables prefixed by ‘$(1)_’:
-#
-# - $(1)_NAME: the name of the library (e.g. ‘libfoo’); defaults to
-# $(1).
-#
-# - $(1)_DIR: the directory where the (non-installed) library will be
-# placed.
-#
-# - $(1)_SOURCES: the source files of the library.
-#
-# - $(1)_CXXFLAGS: additional C++ compiler flags.
-#
-# - $(1)_LIBS: the symbolic names of other libraries on which this
-# library depends.
-#
-# - $(1)_ALLOW_UNDEFINED: if set, the library is allowed to have
-# undefined symbols. Has no effect for static libraries.
-#
-# - $(1)_LDFLAGS: additional linker flags.
-#
-# - $(1)_LDFLAGS_PROPAGATED: additional linker flags, also propagated
-# to the linking of programs/libraries that use this library.
-#
-# - $(1)_FORCE_INSTALL: if defined, the library will be installed even
-# if it's not needed (i.e. dynamically linked) by a program.
-#
-# - $(1)_INSTALL_DIR: the directory where the library will be
-# installed. Defaults to $(libdir).
-#
-# - BUILD_SHARED_LIBS: if equal to ‘1’, a dynamic library will be
-# built, otherwise a static library.
-define build-library =
- $(1)_NAME ?= $(1)
- _d := $$(strip $$($(1)_DIR))
- _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src))
- $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
- _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
-
- $(1)_INSTALL_DIR ?= $$(libdir)
-
- $(1)_LDFLAGS_USE :=
- $(1)_LDFLAGS_USE_INSTALLED :=
-
- ifeq ($(BUILD_SHARED_LIBS), 1)
-
- ifndef $(1)_ALLOW_UNDEFINED
- $(1)_LDFLAGS += -z defs
- endif
-
- $(1)_PATH := $$(_d)/$$($(1)_NAME).so
-
- $$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
- $(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
-
- $(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
-
- $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).so
-
- _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
-
- $$(eval $$(call create-dir,$$($(1)_INSTALL_DIR)))
-
- $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
- $(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
-
- $(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
-
- ifdef $(1)_FORCE_INSTALL
- install: $$($(1)_INSTALL_PATH)
- endif
-
- else
-
- $(1)_PATH := $$(_d)/$$($(1)_NAME).a
-
- $$($(1)_PATH): $$($(1)_OBJS)
- $(QUIET) ar crs $$@ $$?
-
- $(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)
-
- $(1)_INSTALL_PATH := $$(libdir)/$$($(1)_NAME).a
-
- endif
-
- $(1)_LDFLAGS_USE += $$($(1)_LDFLAGS_PROPAGATED)
- $(1)_LDFLAGS_USE_INSTALLED += $$($(1)_LDFLAGS_PROPAGATED)
-
- # Propagate CXXFLAGS to the individual object files.
- $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
-
- # Make each object file depend on the common dependencies.
- $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS)))
-
- # Include .dep files, if they exist.
- $(1)_DEPS := $$(addsuffix .dep, $$(basename $$(_srcs)))
- -include $$($(1)_DEPS)
-
- libs_list += $$($(1)_PATH)
- clean_files += $$(_d)/*.a $$(_d)/*.so $$(_d)/*.o $$(_d)/*.dep $$($(1)_DEPS) $$($(1)_OBJS)
- dist_files += $$(_srcs)
-endef
diff --git a/mk/patterns.mk b/mk/patterns.mk
deleted file mode 100644
index 77e172136..000000000
--- a/mk/patterns.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-%.o: %.cc
- $(QUIET) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
-
-%.o: %.cpp
- $(QUIET) $(CXX) -o $@ -c $< $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
-
-%.o: %.c
- $(QUIET) $(CC) -o $@ -c $< $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP
diff --git a/mk/programs.mk b/mk/programs.mk
deleted file mode 100644
index 52e55598c..000000000
--- a/mk/programs.mk
+++ /dev/null
@@ -1,62 +0,0 @@
-programs_list :=
-
-# Build a program with symbolic name $(1). The program is defined by
-# various variables prefixed by ‘$(1)_’:
-#
-# - $(1)_DIR: the directory where the (non-installed) program will be
-# placed.
-#
-# - $(1)_SOURCES: the source files of the program.
-#
-# - $(1)_LIBS: the symbolic names of libraries on which this program
-# depends.
-#
-# - $(1)_LDFLAGS: additional linker flags.
-#
-# - $(1)_INSTALL_DIR: the directory where the program will be
-# installed; defaults to $(bindir).
-define build-program =
- _d := $$($(1)_DIR)
- _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src))
- $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
- _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
- $(1)_PATH := $$(_d)/$(1)
-
- $$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
- $(QUIET) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
-
- $(1)_INSTALL_DIR ?= $$(bindir)
- $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1)
-
- $$(eval $$(call create-dir,$$($(1)_INSTALL_DIR)))
-
- install: $$($(1)_INSTALL_PATH)
-
- ifeq ($(BUILD_SHARED_LIBS), 1)
-
- _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
-
- $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
- $(QUIET) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
-
- else
-
- $$($(1)_INSTALL_PATH): $$($(1)_PATH) | $$($(1)_INSTALL_DIR)
- install -t $$($(1)_INSTALL_DIR) $$<
-
- endif
-
- # Propagate CXXFLAGS to the individual object files.
- $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
-
- # Make each object file depend on the common dependencies.
- $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS)))
-
- # Include .dep files, if they exist.
- $(1)_DEPS := $$(addsuffix .dep, $$(basename $$(_srcs)))
- -include $$($(1)_DEPS)
-
- programs_list += $$($(1)_PATH)
- clean_files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/*.dep $$($(1)_DEPS) $$($(1)_OBJS)
- dist_files += $$(_srcs)
-endef
diff --git a/mk/templates.mk b/mk/templates.mk
deleted file mode 100644
index fa91e2509..000000000
--- a/mk/templates.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-# Create the file $(1) from $(1).in by running config.status (which
-# substitutes all ‘@var@’ variables set by the configure script).
-define instantiate-template =
-
- clean_files += $(1)
-
-endef
-
-%: %.in
- $(QUIET) ./config.status --quiet --file $@
diff --git a/mk/tests.mk b/mk/tests.mk
deleted file mode 100644
index 8a3bff66e..000000000
--- a/mk/tests.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Run program $1 as part of ‘make installcheck’.
-define run-install-test =
-
- installcheck: $1
-
- # Run the test in its own directory to mimick Automake behaviour.
- $1.run: $1 $(_PREV_TEST)
-
- _installcheck_list += $1
-
-endef
-
-installcheck: install
- @total=0; failed=0; for i in $(_installcheck_list); do \
- total=$$((total + 1)); \
- echo "running test $$i"; \
- if (cd $$(dirname $$i) && $(TESTS_ENVIRONMENT) $$(basename $$i)); then \
- echo "PASS: $$i"; \
- else \
- echo "FAIL: $$i"; \
- failed=$$((failed + 1)); \
- fi; \
- done; \
- if [ "$$failed" != 0 ]; then \
- echo "$$failed out of $$total tests failed "; \
- exit 1; \
- fi
-
-.PHONY: check installcheck