diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-22T14·54+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-22T14·54+0100 |
commit | b8e9efc476abc248a17c9e9cd117f3d53e4a7f63 (patch) | |
tree | 3529e1c6b88983e26290d4c72aa0d3274aeb6375 /Makefile.lib | |
parent | 709cbe4e76e7b0f1b8abddbeb7714e194f6f8a02 (diff) |
New non-recursive, plain Make-based build system
Diffstat (limited to 'Makefile.lib')
-rw-r--r-- | Makefile.lib | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Makefile.lib b/Makefile.lib new file mode 100644 index 000000000000..d681cf7412a2 --- /dev/null +++ b/Makefile.lib @@ -0,0 +1,63 @@ +default: all + +here = $(dir $(lastword $(MAKEFILE_LIST))) + +LIBS = + +QUIET = @ + +%.o: %.cc + $(QUIET) g++ -o $@ -c $^ -g -fPIC $(CXXFLAGS) $($@_CXXFLAGS) + +%.o: %.c + $(QUIET) gcc -o $@ -c $^ -g -fPIC $(CFLAGS) $($@_CFLAGS) + + +# Generate Make rules for libraries. +libs_list := + +define LIBS_template = + _d := $$($(1)_DIR) + _objs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(basename $$(src)).o) + _libs := $$(foreach lib, $$($(1)_LIBS), $$(lib).a) + _lib := $$(_d)$(1).a + + $$(_lib): $$(_objs) + $(QUIET) ar crs $$@ $$? + + # Propagate CXXFLAGS to the individual object files. + $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) + + clean_list += $$(_lib) $$(_objs) + libs_list += $$(_lib) +endef + + +# Generate Make rules for programs. +programs_list := + +define PROGRAMS_template = + _d := $$($(1)_DIR) + _objs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(basename $$(src)).o) + _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)$$(lib).a) + _prog := $$(_d)$(1) + + $$(_prog): $$(_objs) $$(_libs) + $(QUIET) g++ -o $$@ $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS)) + + # Propagate CXXFLAGS to the individual object files. + $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) + + clean_list += $$(_prog) $$(_objs) + programs_list += $$(_prog) +endef + + +# Cleaning stuff. +clean_list := + +clean: + rm -fv $(clean_list) + +dryclean: + @echo $(clean_list) |