diff options
Diffstat (limited to 'Makefile.lib')
-rw-r--r-- | Makefile.lib | 201 |
1 files changed, 0 insertions, 201 deletions
diff --git a/Makefile.lib b/Makefile.lib deleted file mode 100644 index be2b19591ee5..000000000000 --- a/Makefile.lib +++ /dev/null @@ -1,201 +0,0 @@ -default: all - - -# Include Autoconf variables. -Makefile.config: Makefile.config.in - ./config.status --file $@ - -include Makefile.config - - -# Installing stuff. -define create-dir = - ifndef $(1)_SEEN - $(1)_SEEN = 1 - $(1): - install -d $(1) - endif -endef - -define install-file-in = - - install:: $(1)/$(notdir $(2)) - - $$(eval $$(call create-dir,$(1))) - - $(1)/$(notdir $(2)): $(2) | $(1) - install -t $(1) $(2) - -endef - - -# Include all sub-Makefiles. -define include_sub_makefile = - d := $$(patsubst %/, %, $$(dir $(1))) - include $(1) -endef - -$(foreach mf, $(SUBS), $(eval $(call include_sub_makefile, $(mf)))) - - -# Initialise some variables. -clean_list := -dist_files := -QUIET = @ - - -# Pass -fPIC if we're building dynamic libraries. -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. -ifeq ($(BUILD_DEBUG), 1) - GLOBAL_CFLAGS += -g - GLOBAL_CXXFLAGS += -g -endif - - -# Pattern rules. - -%.o: %.cc - $(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 - - -# Generate Make rules for libraries. -libs_list := - -define LIBS_template = - $(1)_NAME ?= $(1) - _d := $$(strip $$($(1)_DIR)) - _srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src)) - $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) - _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) - - $(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_DIR := $$(libdir) - - $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).so - - _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) - - $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) - install -d $$($(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))) - - 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))) - - include $$(wildcard $$(_d)/*.dep) - - libs_list += $$($(1)_PATH) - clean_list += $$(_d)/*.a $$(_d)/*.so $$(_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)) - $(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))) - - include $$(wildcard $$(_d)/*.dep) - - programs_list += $$($(1)_PATH) - clean_list += $$($(1)_PATH) $$(_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) |