]> mj.ucw.cz Git - libucw.git/blob - build/Makebottom
Doc. system: Renamed doc utilities to match local conventions.
[libucw.git] / build / Makebottom
1 # Bottom part of Makefile for the UCW Libraries
2 # (c) 1997--2007 Martin Mares <mj@ucw.cz>
3
4 # The run tree
5
6 runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)))
7
8 run/.tree-stamp: $(o)/config.mk
9         $(M)Creating runtree
10         $(Q)mkdir -p run $(addprefix run/, $(CONFIG_DIR) $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS))
11         $(Q)touch run/.tree-stamp
12
13 # Miscellaneous targets
14
15 programs: $(PROGS)
16 datafiles: $(DATAFILES)
17 tests: $(TESTS)
18 configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS))
19 docs: runtree $(DOCS) $(DOC_INDICES)
20
21 tags:
22         etags `find . -name "*.[ch]"`
23
24 # Black magic with dependencies. It would be more correct to make "depend.new"
25 # a prerequisite for "depend", but "depend.new" often has the same timestamp
26 # as "depend" which would confuse make a lot and either force remaking anyway
27 # or (as in current versions of GNU make) erroneously skipping the remaking.
28
29 -include $(o)/depend
30
31 $(o)/depend: force
32         $(Q)if [ -s $(o)/depend.new ] ; then $(s)/build/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
33
34 force:
35
36 # Rules for directories
37
38 %.dir-stamp:
39         $(Q)mkdir -p $(@D) && touch $@
40
41 # Rules for configuration files
42
43 run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_DIR)/% $(o)/config.mk $(s)/build/genconf
44         $(M)CF $<
45         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
46
47 $(o)/%.cf: $(s)/%.cf $(o)/config.mk $(s)/build/genconf
48         $(M)CF $<
49         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
50         $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F))
51
52 # Rules for libraries
53
54 %.a:
55         $(M)AR $@
56         $(Q)rm -f $@
57         $(Q)ar rcs $@ $^
58 ifdef CONFIG_INSTALL_API
59         $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a)
60 endif
61
62 %.so:
63         $(M)LD $@
64         $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
65         $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX))
66
67 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
68         $(M)PC $<
69         $(Q)DEPS="$(shell $(s)/build/lib-deps $^)" LIBDIR=$(@D) $(s)/build/genconf $< $@ $(o)/config.mk
70         $(Q)mkdir -p $(o)/pkgconfig
71         $(Q)$(call symlink,$@,$(o)/pkgconfig)
72
73 # Rules for public API
74
75 ifdef CONFIG_INSTALL_API
76
77 ifdef CONFIG_LOCAL
78 # Need an absolute path
79 API_ROOT:=$(shell pwd)/run
80 API_LIBDIR=$(API_ROOT)/lib
81 API_INCDIR=$(API_ROOT)/include
82 else
83 API_LIBDIR=$(INSTALL_LIB_DIR)
84 API_INCDIR=$(INSTALL_INCLUDE_DIR)
85 endif
86 INSTALL_RUNDIRS+=include lib/pkgconfig
87 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
88
89 $(o)/%/.include-stamp:
90         $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
91         $(Q)touch $@
92
93 run/lib/pkgconfig/%.pc:         # RHS supplied in the sub-makefile
94         $(M)PC-API $@
95         $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_LIBDIR)@;s@^incdir=.*@incdir=$(API_INCDIR)@"
96
97 else
98 api:
99 endif
100
101 # Rules for compiling C
102
103 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
104         $(M)CC $<
105         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
106
107 $(o)/%.o: %.c $(o)/autoconf.h
108         $(M)CC $<
109         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
110
111 %.o: %.c $(o)/autoconf.h
112         $(M)CC $<
113         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
114
115 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
116         $(M)CC-SO $<
117         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
118
119 $(o)/%.oo: %.c $(o)/autoconf.h
120         $(M)CC-SO $<
121         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
122
123 %.oo: %.c $(o)/autoconf.h
124         $(M)CC-SO $<
125         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
126
127 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
128         $(M)CC-TEST $<
129         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
130
131 # Rules for testing
132
133 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
134         $(M)LD-TEST $@
135         $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
136
137 $(o)/%.test: $(s)/%.t $(s)/build/tester
138         $(M)TEST $@
139         $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
140
141 # Rules for binaries
142
143 BINDIR=bin
144
145 $(o)/%: $(o)/%.o
146         $(M)LD $@
147         $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(s)/build/lib-flags $^) $(LIBS)
148         $(Q)$(call symlink,$@,run/$(BINDIR))
149
150 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
151         $(M)PP $<
152         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
153         $(Q)chmod +x $@
154         $(Q)$(call symlink,$@,run/$(BINDIR))
155
156 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
157         $(M)PP $<
158         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
159         $(Q)chmod +x $@
160         $(Q)$(call symlink,$@,run/$(BINDIR))
161
162 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
163         $(M)PP $<
164         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
165         $(Q)chmod +x $@
166         $(Q)$(call symlink,$@,run/$(BINDIR))
167
168 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
169         $(M)PP $<
170         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
171         $(Q)chmod +x $@
172         $(Q)$(call symlink,$@,run/$(BINDIR))
173
174 PERL_MODULE_DIR=UCW
175
176 $(o)/%.pm: $(s)/%.pm
177         $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
178         $(Q)cp $^ $@
179         $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
180
181 $(o)/%.pm: %.pm
182         $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
183         $(Q)cp $^ $@
184         $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
185
186 # Rules for data files
187
188 DATADIR=lib
189
190 $(DATAFILES): $(o)/%: $(s)/%
191         $(M)DATA $<
192         $(Q)cp $^ $@
193         $(Q)$(call symlink,$@,run/$(DATADIR))
194
195 # Rules for documentation
196
197 $(o)/%.html: $(o)/%.txt
198         $(M)"DOC-HTML $<"
199         $(Q)asciidoc -e -f $(s)/build/asciidoc.conf -f $(s)/build/asciidoc-xhtml.conf -f /etc/asciidoc/asciidoc.conf -f /etc/asciidoc/xhtml11.conf $<
200
201 $(patsubst %.html,%.txt,$(DOC_INDICES)): $(o)/%.txt:
202         $(M)"DOC-DEFS $@"
203         $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new
204         $(Q)$(s)/build/doc-defs $(DOC_HEAD) $@ $(DOC_LIST)
205
206 #FIXME: this one outputs .deflist too. How do I specify that one run of the rule has multiple target files?
207 $(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt
208         $(M)"DOC-EXT $<"
209         $(Q)$(s)/build/doc-extract $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@)
210
211 # Default installation target
212
213 default-install:
214         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)
215
216 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
217 # in GNU Make rules with targets in not-yet-existing directories are ignored
218 # when searching for implicit rules and thence targets considered intermediate.
219 .SECONDARY:
220
221 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install