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
56 ifdef CONFIG_INSTALL_API
57 $(Q)$(call symlink,$@,run/lib)
62 $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
63 $(Q)$(call symlink,$@,run/lib)
65 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
67 $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
68 $(Q)mkdir -p $(o)/pkgconfig
69 $(Q)$(call symlink,$@,$(o)/pkgconfig)
71 # Rules for public API
73 ifdef CONFIG_INSTALL_API
75 API_ROOT:=$(shell pwd)/run
76 INSTALL_RUNDIRS+=include lib/pkgconfig
77 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
79 $(o)/%/.include-stamp:
80 $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
83 run/lib/pkgconfig/%.pc: # RHS supplied in the sub-makefile
85 $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
91 # Rules for compiling C
93 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
95 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
97 $(o)/%.o: %.c $(o)/autoconf.h
99 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
101 %.o: %.c $(o)/autoconf.h
103 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
105 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
107 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
109 $(o)/%.oo: %.c $(o)/autoconf.h
111 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
113 %.oo: %.c $(o)/autoconf.h
115 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
117 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
119 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
123 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
125 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
127 $(o)/%.test: $(s)/%.t $(s)/build/tester
129 $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
137 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
138 $(Q)$(call symlink,$@,run/$(BINDIR))
140 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
142 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
144 $(Q)$(call symlink,$@,run/$(BINDIR))
146 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
148 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
150 $(Q)$(call symlink,$@,run/$(BINDIR))
152 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
154 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
156 $(Q)$(call symlink,$@,run/$(BINDIR))
158 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
160 $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
162 $(Q)$(call symlink,$@,run/$(BINDIR))
167 $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
169 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
172 $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
174 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
176 # Rules for data files
180 $(DATAFILES): $(o)/%: $(s)/%
183 $(Q)$(call symlink,$@,run/$(DATADIR))
185 # Default installation target
188 SH_EXTRA_RUNDIRS="$(sort $(EXTRA_RUNDIRS))" SH_INSTALL_RUNDIRS="$(sort $(INSTALL_RUNDIRS))" SH_CONFIGS="$(sort $(CONFIGS))" $(s)/build/installer $(INSTALL_DIR)
190 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
191 # in GNU Make rules with targets in not-yet-existing directories are ignored
192 # when searching for implicit rules and thence targets considered intermediate.
195 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install