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
52 ifdef CONFIG_INSTALL_API
53 $(Q)$(call symlink,$@,run/lib)
58 $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
59 $(Q)$(call symlink,$@,run/lib)
61 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
63 $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
64 $(Q)mkdir -p $(o)/pkgconfig
65 $(Q)$(call symlink,$@,$(o)/pkgconfig)
67 # Rules for public API
69 ifdef CONFIG_INSTALL_API
71 API_ROOT:=$(shell pwd)/run
72 INSTALL_RUNDIRS+=include lib/pkgconfig
73 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
75 $(o)/%/.include-stamp:
76 $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
79 run/lib/pkgconfig/%.pc: # RHS supplied in the sub-makefile
81 $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
87 # Rules for compiling C
89 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
91 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
93 $(o)/%.o: %.c $(o)/autoconf.h
95 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
97 %.o: %.c $(o)/autoconf.h
99 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
101 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
103 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
105 $(o)/%.oo: %.c $(o)/autoconf.h
107 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
109 %.oo: %.c $(o)/autoconf.h
111 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
113 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
115 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
119 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
121 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
123 $(o)/%.test: $(s)/%.t $(s)/build/tester
125 $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
133 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
134 $(Q)$(call symlink,$@,run/$(BINDIR))
136 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
138 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
140 $(Q)$(call symlink,$@,run/$(BINDIR))
142 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
144 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
146 $(Q)$(call symlink,$@,run/$(BINDIR))
148 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
150 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
152 $(Q)$(call symlink,$@,run/$(BINDIR))
154 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
156 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
158 $(Q)$(call symlink,$@,run/$(BINDIR))
163 $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
165 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
168 $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
170 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
172 # Rules for data files
176 $(DATAFILES): $(o)/%: $(s)/%
179 $(Q)$(call symlink,$@,run/$(DATADIR))
181 # Default installation target
184 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)
186 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
187 # in GNU Make rules with targets in not-yet-existing directories are ignored
188 # when searching for implicit rules and thence targets considered intermediate.
191 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install