]> mj.ucw.cz Git - eval.git/blob - build/Makebottom
Added configuration file for libucw modules.
[eval.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/, cf $(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/cf/,$(CONFIGS))
19
20 tags:
21         etags `find . -name "*.[ch]"`
22
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.
27
28 -include $(o)/depend
29
30 $(o)/depend: force
31         $(Q)if [ -s $(o)/depend.new ] ; then $(s)/build/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi
32
33 force:
34
35 # Rules for directories
36
37 %.dir-stamp:
38         $(Q)mkdir -p $(@D) && touch $@
39
40 # Rules for configuration files
41
42 run/cf/%: custom/cf/% $(o)/config.mk $(s)/build/genconf
43         $(M)CF $<
44         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
45
46 run/cf/%: $(s)/cf/% $(o)/config.mk $(s)/build/genconf
47         $(M)CF $<
48         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
49
50 $(o)/%.cf: $(s)/%.cf
51         $(M)CF $<
52         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
53         $(Q)cp $@ run/cf/$(basename $(@F))
54
55 # Rules for libraries
56
57 %.a:
58         $(M)AR $@
59         $(Q)rm -f $@
60         $(Q)ar rcs $@ $^
61 ifdef CONFIG_INSTALL_API
62         $(Q)$(call symlink,$@,run/lib)
63 endif
64
65 %.so:
66         $(M)LD $@
67         $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
68         $(Q)$(call symlink,$@,run/lib)
69
70 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
71         $(M)PC $<
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)
75
76 # Rules for public API
77
78 ifdef CONFIG_INSTALL_API
79
80 API_ROOT:=$(shell pwd)/run
81 INSTALL_RUNDIRS+=include lib/pkgconfig
82 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
83
84 $(o)/%/.include-stamp:
85         $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
86         $(Q)touch $@
87
88 run/lib/pkgconfig/%.pc:         # RHS supplied in the sub-makefile
89         $(M)PC-API $@
90         $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
91
92 else
93 api:
94 endif
95
96 # Rules for compiling C
97
98 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
99         $(M)CC $<
100         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
101
102 $(o)/%.o: %.c $(o)/autoconf.h
103         $(M)CC $<
104         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
105
106 %.o: %.c $(o)/autoconf.h
107         $(M)CC $<
108         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
109
110 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
111         $(M)CC-SO $<
112         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
113
114 $(o)/%.oo: %.c $(o)/autoconf.h
115         $(M)CC-SO $<
116         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
117
118 %.oo: %.c $(o)/autoconf.h
119         $(M)CC-SO $<
120         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
121
122 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
123         $(M)CC-TEST $<
124         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
125
126 # Rules for testing
127
128 $(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS)
129         $(M)LD-TEST $@
130         $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
131
132 $(o)/%.test: $(s)/%.t $(s)/build/tester
133         $(M)TEST $@
134         $(Q)$(s)/build/tester --rundir=run $(TESTERFLAGS) $< && touch $@
135
136 # Rules for binaries
137
138 BINDIR=bin
139
140 $(o)/%: $(o)/%.o
141         $(M)LD $@
142         $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
143         $(Q)$(call symlink,$@,run/$(BINDIR))
144
145 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
146         $(M)PP $<
147         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
148         $(Q)chmod +x $@
149         $(Q)$(call symlink,$@,run/$(BINDIR))
150
151 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
152         $(M)PP $<
153         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
154         $(Q)chmod +x $@
155         $(Q)$(call symlink,$@,run/$(BINDIR))
156
157 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
158         $(M)PP $<
159         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
160         $(Q)chmod +x $@
161         $(Q)$(call symlink,$@,run/$(BINDIR))
162
163 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
164         $(M)PP $<
165         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
166         $(Q)chmod +x $@
167         $(Q)$(call symlink,$@,run/$(BINDIR))
168
169 PERL_MODULE_DIR=UCW
170
171 $(o)/%.pm: $(s)/%.pm
172         $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)"
173         $(Q)cp $^ $@
174         $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
175
176 $(o)/%.pm: %.pm
177         $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)"
178         $(Q)cp $^ $@
179         $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR))
180
181 # Rules for data files
182
183 DATADIR=lib
184
185 $(DATAFILES): $(o)/%: $(s)/%
186         $(M)DATA $<
187         $(Q)cp $^ $@
188         $(Q)$(call symlink,$@,run/$(DATADIR))
189
190 # Default installation target
191
192 default-install:
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)
194
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.
198 .SECONDARY:
199
200 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install