# Bottom part of Makefile for the UCW Libraries # (c) 1997--2007 Martin Mares # The run tree runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS))) run/.tree-stamp: $(o)/config.mk $(M)Creating runtree $(Q)mkdir -p run $(addprefix run/, $(CONFIG_DIR) $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS)) $(Q)touch run/.tree-stamp # Miscellaneous targets programs: $(PROGS) datafiles: $(DATAFILES) tests: $(TESTS) configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS)) docs: runtree $(DOCS) $(DOC_INDEXES) tags: etags `find . -name "*.[ch]"` # Black magic with dependencies. It would be more correct to make "depend.new" # a prerequisite for "depend", but "depend.new" often has the same timestamp # as "depend" which would confuse make a lot and either force remaking anyway # or (as in current versions of GNU make) erroneously skipping the remaking. -include $(o)/depend $(o)/depend: force $(Q)if [ -s $(o)/depend.new ] ; then $(s)/build/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi force: # Rules for directories %.dir-stamp: $(Q)mkdir -p $(@D) && touch $@ # Rules for configuration files run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_DIR)/% $(o)/config.mk $(s)/build/genconf $(M)CF $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(o)/%.cf: $(s)/%.cf $(o)/config.mk $(s)/build/genconf $(M)CF $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F)) # Rules for libraries %.a: $(M)AR $@ $(Q)rm -f $@ $(Q)ar rcs $@ $^ ifdef CONFIG_INSTALL_API $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a) endif %.so: $(M)LD $@ $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^ $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX)) $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS) $(M)PC $< $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk $(Q)mkdir -p $(o)/pkgconfig $(Q)$(call symlink,$@,$(o)/pkgconfig) # Rules for public API ifdef CONFIG_INSTALL_API ifdef CONFIG_LOCAL # Need an absolute path API_ROOT:=$(shell pwd)/run API_LIBDIR=$(API_ROOT)/lib API_INCDIR=$(API_ROOT)/include else API_LIBDIR=$(INSTALL_LIB_DIR) API_INCDIR=$(INSTALL_INCLUDE_DIR) endif INSTALL_RUNDIRS+=include lib/pkgconfig api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS))) $(o)/%/.include-stamp: $(Q)$(s)/build/install-includes $($@ "s@^libdir=.*@libdir=$(API_LIBDIR)@;s@^incdir=.*@incdir=$(API_INCDIR)@" else api: endif # Rules for compiling C $(o)/%.o: $(s)/%.c $(o)/autoconf.h $(M)CC $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< $(o)/%.o: %.c $(o)/autoconf.h $(M)CC $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< %.o: %.c $(o)/autoconf.h $(M)CC $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< $(o)/%.oo: $(s)/%.c $(o)/autoconf.h $(M)CC-SO $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< $(o)/%.oo: %.c $(o)/autoconf.h $(M)CC-SO $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< %.oo: %.c $(o)/autoconf.h $(M)CC-SO $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h $(M)CC-TEST $< $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $< # Rules for testing $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS) $(M)LD-TEST $@ $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS) $(o)/%.test: $(s)/%.t $(s)/build/tester $(M)TEST $@ $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@ # Rules for binaries BINDIR=bin $(o)/%: $(o)/%.o $(M)LD $@ $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS) $(Q)$(call symlink,$@,run/$(BINDIR)) $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf $(M)PP $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(Q)chmod +x $@ $(Q)$(call symlink,$@,run/$(BINDIR)) $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf $(M)PP $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(Q)chmod +x $@ $(Q)$(call symlink,$@,run/$(BINDIR)) $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf $(M)PP $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(Q)chmod +x $@ $(Q)$(call symlink,$@,run/$(BINDIR)) $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf $(M)PP $< $(Q)$(s)/build/genconf $< $@ $(o)/config.mk $(Q)chmod +x $@ $(Q)$(call symlink,$@,run/$(BINDIR)) PERL_MODULE_DIR=UCW $(o)/%.pm: $(s)/%.pm $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)" $(Q)cp $^ $@ $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR)) $(o)/%.pm: %.pm $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)" $(Q)cp $^ $@ $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR)) # Rules for data files DATADIR=lib $(DATAFILES): $(o)/%: $(s)/% $(M)DATA $< $(Q)cp $^ $@ $(Q)$(call symlink,$@,run/$(DATADIR)) # Rules for documentation $(o)/%.html: $(o)/%.txt $(M)"AD $< -> $@" $(Q)asciidoc -e -f $(s)/build/asciidoc.conf -f $(s)/build/asciidoc-xhtml.conf -f /etc/asciidoc/asciidoc.conf -f /etc/asciidoc/xhtml11.conf $< $(patsubst %.html,%.txt,$(DOC_INDEXES)): $(o)/%.txt: $(M)"DD -> $@" $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new $(Q)$(s)/build/def-doc.pl $(DOC_HEAD) $@ $(DOC_LIST) #FIXME: this one outputs .deflist too. How do I specify that one run of the rule has multiple target files? $(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt $(M)"ED $< -> $@" $(Q)$(s)/build/extract-doc.pl $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@) # Default installation target default-install: SH_EXTRA_RUNDIRS="$(sort $(EXTRA_RUNDIRS))" SH_INSTALL_RUNDIRS="$(sort $(INSTALL_RUNDIRS))" SH_CONFIGS="$(sort $(CONFIGS))" SH_AUTO_CONFIRM="$(CONFIRM)" $(s)/build/installer $(INSTALL_DIR) # Don't delete intermediate targets. There shouldn't be any, but due to bugs # in GNU Make rules with targets in not-yet-existing directories are ignored # when searching for implicit rules and thence targets considered intermediate. .SECONDARY: .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install