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/%: custom/cf/% $(o)/config.mk $(s)/build/genconf
44 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
46 run/cf/%: $(s)/cf/% $(o)/config.mk $(s)/build/genconf
48 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
52 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
53 $(Q)cp $@ run/cf/$(basename $(@F))
61 ifdef CONFIG_INSTALL_API
62 $(Q)$(call symlink,$@,run/lib)
67 $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
68 $(Q)$(call symlink,$@,run/lib)
70 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
72 $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
73 $(Q)mkdir -p $(o)/pkgconfig
74 $(Q)$(call symlink,$@,$(o)/pkgconfig)
76 # Rules for public API
78 ifdef CONFIG_INSTALL_API
80 API_ROOT:=$(shell pwd)/run
81 INSTALL_RUNDIRS+=include lib/pkgconfig
82 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
84 $(o)/%/.include-stamp:
85 $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
88 run/lib/pkgconfig/%.pc: # RHS supplied in the sub-makefile
90 $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
96 # Rules for compiling C
98 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
100 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
102 $(o)/%.o: %.c $(o)/autoconf.h
104 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
106 %.o: %.c $(o)/autoconf.h
108 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
110 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
112 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
114 $(o)/%.oo: %.c $(o)/autoconf.h
116 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
118 %.oo: %.c $(o)/autoconf.h
120 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
122 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
124 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
128 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
130 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
132 $(o)/%.test: $(s)/%.t $(s)/build/tester
134 $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
142 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
143 $(Q)$(call symlink,$@,run/$(BINDIR))
145 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
147 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
149 $(Q)$(call symlink,$@,run/$(BINDIR))
151 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
153 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
155 $(Q)$(call symlink,$@,run/$(BINDIR))
157 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
159 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
161 $(Q)$(call symlink,$@,run/$(BINDIR))
163 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
165 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
167 $(Q)$(call symlink,$@,run/$(BINDIR))
172 $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
174 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
177 $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
179 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
181 # Rules for data files
185 $(DATAFILES): $(o)/%: $(s)/%
188 $(Q)$(call symlink,$@,run/$(DATADIR))
190 # Default installation target
193 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)
195 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
196 # in GNU Make rules with targets in not-yet-existing directories are ignored
197 # when searching for implicit rules and thence targets considered intermediate.
200 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install