nix-super/Makefile.lib
Eelco Dolstra 9a14d5e2f3 Automatically regenerate Makefile.config
And move some stuff around.
2013-11-22 16:59:09 +01:00

89 lines
2.1 KiB
Text

# Include Autoconf variables.
Makefile.config: Makefile.config.in
./config.status
include Makefile.config
clean_list :=
dist_files :=
QUIET = @
%.o: %.cc
$(QUIET) $(CXX) -o $@ -c $< -g -fPIC $(CXXFLAGS) $($@_CXXFLAGS) -MMD -MF $(basename $@).dep -MP
%.o: %.c
$(QUIET) $(CC) -o $@ -c $< -g -fPIC $(CFLAGS) $($@_CFLAGS) -MMD -MF $(basename $@).dep -MP
# Generate Make rules for libraries.
libs_list :=
define LIBS_template =
_d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(src))
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
_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)))
include $$(wildcard $$(_d)/*.dep)
libs_list += $$(_lib)
clean_list += $$(_d)*.a $$(_d)*.o $$(_d)*.dep
dist_files += $$(_srcs)
endef
$(foreach lib, $(LIBS), $(eval $(call LIBS_template,$(lib))))
# Generate Make rules for programs.
programs_list :=
define PROGRAMS_template =
_d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)$$(src))
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
_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)))
include $$(wildcard $$(_d)/*.dep)
programs_list += $$(_prog)
clean_list += $$(_prog) $$(_d)*.o $$(_d)*.dep
dist_files += $$(_srcs)
endef
$(foreach prog, $(PROGRAMS), $(eval $(call PROGRAMS_template,$(prog))))
# Distributing stuff.
dist_name = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
dist:
@echo $(dist_files)
$(QUIET) tar cvfj $(dist_name).tar.bz2 $(dist_files) --transform 's,^,$(dist_name)/,'
# Cleaning stuff.
clean:
rm -fv $(clean_list)
dryclean:
@echo $(clean_list)
all: $(programs_list)