1 # Bottom part of Makefile for the UCW Libraries
2 # (c) 1997--2008 Martin Mares <mj@ucw.cz>
8 runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)) $(addprefix run/$(DOCDIR)/,$(DOC_MODULES)))
10 run/.tree-stamp: $(o)/config.mk
12 $(Q)mkdir -p run $(addprefix run/, $(CONFIG_DIR) $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS))
13 $(Q)touch run/.tree-stamp
15 # Miscellaneous targets
18 datafiles: $(DATAFILES)
20 configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
21 docs: runtree $(DOCS) $(DOC_INDICES)
24 etags `find . -name "*.[ch]"`
26 # Black magic with dependencies. It would be more correct to make "depend.new"
27 # a prerequisite for "depend", but "depend.new" often has the same timestamp
28 # as "depend" which would confuse make a lot and either force remaking anyway
29 # or (as in current versions of GNU make) erroneously skipping the remaking.
34 $(Q)if [ -s $(o)/depend.new ] ; then $(BUILDSYS)/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
38 # Rules for directories
41 $(Q)mkdir -p $(@D) && touch $@
43 # Rules for configuration files
45 run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_SRC_DIR)/% $(o)/config.mk $(BUILDSYS)/genconf
47 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
49 $(o)/%.cf: $(s)/%.cf $(o)/config.mk $(BUILDSYS)/genconf
51 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
52 $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F))
60 ifdef CONFIG_INSTALL_API
61 $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a)
66 $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
67 $(Q)$(call symlink-alias,$@,run/$(SO_RUNDIR),$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
68 $(Q)ln -fs $(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX) run/$(SO_RUNDIR)/$(*F)$(SONAME_INFIX).so
70 # On Darwin, gcc expects shared libraries in *.dylib instead of *.so.
71 # Surprisingly, when a program is run, it suffices to have *.so files.
72 # We don't want to mess up the whole build system with configurable
73 # suffices and we also don't want to incur an overhead on Linux, so we
74 # just create symbolic links on Darwin, if requested.
76 cd $(dir $<) && ln -fs $(notdir $<) $(notdir $@)
78 $(o)/%.pc: $(s)/%.pc $(o)/%$(LV).$(LS)
80 $(Q)DEPS="$(shell $(BUILDSYS)/lib-deps $^)" LIBDIR=$(@D) $(BUILDSYS)/genconf $< $@ $(o)/config.mk
81 $(Q)mkdir -p $(o)/pkgconfig
82 $(Q)$(call symlink,$@,$(o)/pkgconfig)
84 # Rules for public API
86 ifdef CONFIG_INSTALL_API
89 # Need an absolute path
90 API_ROOT:=$(shell pwd)/run
91 API_LIBDIR=$(API_ROOT)/lib
92 API_INCDIR=$(API_ROOT)/include
94 API_LIBDIR=$(INSTALL_LIB_DIR)
95 API_INCDIR=$(INSTALL_INCLUDE_DIR)
97 INSTALL_RUNDIRS+=include lib/pkgconfig
98 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
100 $(o)/%/.include-stamp:
101 $(Q)$(BUILDSYS)/install-includes $(<D) run/include/$(IDST) $(?F)
104 run/lib/pkgconfig/%.pc: # RHS supplied in the sub-makefile
106 $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_LIBDIR)@;s@^incdir=.*@incdir=$(API_INCDIR)@"
112 # Rules for compiling C
114 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
116 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
118 $(o)/%.o: %.c $(o)/autoconf.h
120 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
122 %.o: %.c $(o)/autoconf.h
124 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
126 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
128 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
130 $(o)/%.oo: %.c $(o)/autoconf.h
132 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
134 %.oo: %.c $(o)/autoconf.h
136 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
138 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
140 $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
144 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
146 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
148 $(o)/%.test: $(s)/%.t $(BUILDSYS)/tester
150 $(Q)$(BUILDSYS)/tester --rundir=run $(TESTERFLAGS) $< && touch $@
158 $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS)
159 $(Q)$(call symlink,$@,run/$(BINDIR))
161 $(o)/%: $(s)/%.sh $(o)/config.mk $(BUILDSYS)/genconf
163 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
165 $(Q)$(call symlink,$@,run/$(BINDIR))
167 $(o)/%: %.sh $(o)/config.mk $(BUILDSYS)/genconf
169 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
171 $(Q)$(call symlink,$@,run/$(BINDIR))
173 $(o)/%: $(s)/%.pl $(o)/config.mk $(BUILDSYS)/genconf
175 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
177 $(Q)$(call symlink,$@,run/$(BINDIR))
179 $(o)/%: %.pl $(o)/config.mk $(BUILDSYS)/genconf
181 $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk
183 $(Q)$(call symlink,$@,run/$(BINDIR))
188 $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
190 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
193 $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
195 $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
197 # Rules for data files
201 $(DATAFILES): $(o)/%: $(s)/%
204 $(Q)$(call symlink,$@,run/$(DATADIR))
206 # Rules for documentation
208 $(o)/%.html: $(o)/%.txt $(BUILDSYS)/asciidoc.conf $(BUILDSYS)/asciidoc-xhtml.conf run/$(DOCDIR)/$(DOC_MODULE)/.dir-stamp
210 $(Q)asciidoc -e -f $(BUILDSYS)/asciidoc.conf -f $(BUILDSYS)/asciidoc-xhtml.conf -f $(HOST_PREFIX)/etc/asciidoc/asciidoc.conf -f $(HOST_PREFIX)/etc/asciidoc/xhtml11.conf $<
211 $(Q)$(call symlink,$@,run/$(DOCDIR)/$(DOC_MODULE))
213 # In reality, we do not depend on the .txt files, but on the corresponding .deflist's.
214 # However, the Makefile language cannot express that doc-extract generates both .txt
215 # and .deflist, so we always use the .txt's in dependencies.
216 $(patsubst %.html,%.txt,$(DOC_INDICES)): $(o)/%.txt: $(patsubst %.html,%.txt,$(DOCS)) $(BUILDSYS)/doc-defs
218 $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new
219 $(Q)$(BUILDSYS)/doc-defs $(DOC_HEAD) $@ $(DOC_LIST)
221 $(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt $(BUILDSYS)/doc-extract
223 $(Q)$(BUILDSYS)/doc-extract $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@)
225 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
226 # in GNU Make rules with targets in not-yet-existing directories are ignored
227 # when searching for implicit rules and thence targets considered intermediate.
230 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install docs tests