1 # Bottom part of Makefile for the UCW Libraries
2 # (c) 1997--2007 Martin Mares <mj@ucw.cz>
6 runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)))
8 run/.tree-stamp: $(o)/config.mk
10 $(Q)mkdir -p run $(addprefix run/, cf $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS))
11 $(Q)touch run/.tree-stamp
13 # Miscellaneous targets
16 datafiles: $(DATAFILES)
18 configs: $(addprefix run/cf/,$(CONFIGS))
21 etags `find . -name "*.[ch]"`
23 # Black magic with dependencies. It would be more correct to make "depend.new"
24 # a prerequisite for "depend", but "depend.new" often has the same timestamp
25 # as "depend" which would confuse make a lot and either force remaking anyway
26 # or (as in current versions of GNU make) erroneously skipping the remaking.
31 $(Q)if [ -s $(o)/depend.new ] ; then $(s)/build/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
35 # Rules for directories
38 $(Q)mkdir -p $(@D) && touch $@
40 # Rules for configuration files
42 run/cf/%: $(s)/cf/% $(o)/config.mk $(s)/build/genconf
44 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
46 $(o)/%.cf: $(s)/%.cf $(o)/config.mk $(s)/build/genconf
48 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
49 $(Q)cp $@ run/cf/$(basename $(@F))
57 ifdef CONFIG_INSTALL_API
58 $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a)
63 $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
64 $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
66 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
68 $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
69 $(Q)mkdir -p $(o)/pkgconfig
70 $(Q)$(call symlink,$@,$(o)/pkgconfig)
72 # Rules for public API
74 ifdef CONFIG_INSTALL_API
76 API_ROOT:=$(shell pwd)/run
77 INSTALL_RUNDIRS+=include lib/pkgconfig
78 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
80 $(o)/%/.include-stamp:
81 $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
84 run/lib/pkgconfig/%.pc: # RHS supplied in the sub-makefile
86 $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
92 # Rules for compiling C
94 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
96 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
98 $(o)/%.o: %.c $(o)/autoconf.h
100 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
102 %.o: %.c $(o)/autoconf.h
104 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
106 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
108 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
110 $(o)/%.oo: %.c $(o)/autoconf.h
112 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
114 %.oo: %.c $(o)/autoconf.h
116 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
118 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
120 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
124 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
126 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
128 $(o)/%.test: $(s)/%.t $(s)/build/tester
130 $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
138 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
139 $(Q)$(call symlink,$@,run/$(BINDIR))
141 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
143 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
145 $(Q)$(call symlink,$@,run/$(BINDIR))
147 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
149 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
151 $(Q)$(call symlink,$@,run/$(BINDIR))
153 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
155 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
157 $(Q)$(call symlink,$@,run/$(BINDIR))
159 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
161 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
163 $(Q)$(call symlink,$@,run/$(BINDIR))
168 $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
170 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
173 $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
175 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
177 # Rules for data files
181 $(DATAFILES): $(o)/%: $(s)/%
184 $(Q)$(call symlink,$@,run/$(DATADIR))
186 # Default installation target
189 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)
191 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
192 # in GNU Make rules with targets in not-yet-existing directories are ignored
193 # when searching for implicit rules and thence targets considered intermediate.
196 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install