]> mj.ucw.cz Git - libucw.git/blob - build/Makebottom
3475df019c75ce72aa34cf4840c6228d959548d8
[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/, 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 # Rules for libraries
51
52 %.a:
53         $(M)AR $@
54         $(Q)rm -f $@
55         $(Q)ar rcs $@ $^
56 ifdef CONFIG_INSTALL_API
57         $(Q)$(call symlink,$@,run/lib)
58 endif
59
60 %.so:
61         $(M)LD $@
62         $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $^
63         $(Q)$(call symlink,$@,run/lib)
64
65 $(o)/%.pc: $(s)/%.pc $(o)/%.$(LS)
66         $(M)PC $<
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)
70
71 # Rules for public API
72
73 ifdef CONFIG_INSTALL_API
74
75 API_ROOT:=$(shell pwd)/run
76 INSTALL_RUNDIRS+=include lib/pkgconfig
77 api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS)))
78
79 $(o)/%/.include-stamp:
80         $(Q)$(s)/build/install-includes $(<D) run/include/$(IDST) $(?F)
81         $(Q)touch $@
82
83 run/lib/pkgconfig/%.pc:         # RHS supplied in the sub-makefile
84         $(M)PC-API $@
85         $(Q)sed <$< >$@ "s@^libdir=.*@libdir=$(API_ROOT)/lib@;s@^incdir=.*@incdir=$(API_ROOT)/include@"
86
87 else
88 api:
89 endif
90
91 # Rules for compiling C
92
93 $(o)/%.o: $(s)/%.c $(o)/autoconf.h
94         $(M)CC $<
95         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
96
97 $(o)/%.o: %.c $(o)/autoconf.h
98         $(M)CC $<
99         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
100
101 %.o: %.c $(o)/autoconf.h
102         $(M)CC $<
103         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $<
104
105 $(o)/%.oo: $(s)/%.c $(o)/autoconf.h
106         $(M)CC-SO $<
107         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
108
109 $(o)/%.oo: %.c $(o)/autoconf.h
110         $(M)CC-SO $<
111         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
112
113 %.oo: %.c $(o)/autoconf.h
114         $(M)CC-SO $<
115         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $<
116
117 $(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h
118         $(M)CC-TEST $<
119         $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $<
120
121 # Rules for testing
122
123 $(o)/%-t: $(o)/%-tt.o $(LIBSH)
124         $(M)LD-TEST $@
125         $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(shell $(s)/build/lib-flags $^) $(LIBS)
126
127 $(o)/%.test: $(s)/%.t $(s)/build/tester
128         $(M)TEST $@
129         $(Q)$(s)/build/tester $< && touch $@
130
131 # Rules for binaries
132
133 BINDIR=bin
134
135 $(o)/%: $(o)/%.o
136         $(M)LD $@
137         $(Q)$(CC) $(LDFLAGS) -o $@ $(shell $(s)/build/lib-flags $^) $(LIBS)
138         $(Q)$(call symlink,$@,run/$(BINDIR))
139
140 $(o)/%: $(s)/%.sh $(o)/config.mk $(s)/build/genconf
141         $(M)PP $<
142         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
143         $(Q)chmod +x $@
144         $(Q)$(call symlink,$@,run/$(BINDIR))
145
146 $(o)/%: %.sh $(o)/config.mk $(s)/build/genconf
147         $(M)PP $<
148         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
149         $(Q)chmod +x $@
150         $(Q)$(call symlink,$@,run/$(BINDIR))
151
152 $(o)/%: $(s)/%.pl $(o)/config.mk $(s)/build/genconf
153         $(M)PP $<
154         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
155         $(Q)chmod +x $@
156         $(Q)$(call symlink,$@,run/$(BINDIR))
157
158 $(o)/%: %.pl $(o)/config.mk $(s)/build/genconf
159         $(M)PP $<
160         $(Q)$(s)/build/genconf $< $@ $(o)/config.mk
161         $(Q)chmod +x $@
162         $(Q)$(call symlink,$@,run/$(BINDIR))
163
164 $(o)/%.pm: $(s)/%.pm
165         $(M)PM $<
166         $(Q)cp $^ $@
167         $(Q)$(call symlink,$@,run/lib/perl5/Sherlock)
168
169 $(o)/%.pm: %.pm
170         $(M)PM $<
171         $(Q)cp $^ $@
172         $(Q)$(call symlink,$@,run/lib/perl5/Sherlock)
173
174 # Rules for data files
175
176 DATADIR=lib
177
178 $(DATAFILES): $(o)/%: $(s)/%
179         $(M)DATA $<
180         $(Q)cp $^ $@
181         $(Q)$(call symlink,$@,run/$(DATADIR))
182
183 # Default installation target
184
185 default-install:
186         SH_EXTRA_RUNDIRS="$(sort $(EXTRA_RUNDIRS))" SH_INSTALL_RUNDIRS="$(sort $(INSTALL_RUNDIRS))" SH_CONFIGS="$(sort $(CONFIGS))" $(s)/build/installer $(INSTALL_DIR)
187
188 # Don't delete intermediate targets. There shouldn't be any, but due to bugs
189 # in GNU Make rules with targets in not-yet-existing directories are ignored
190 # when searching for implicit rules and thence targets considered intermediate.
191 .SECONDARY:
192
193 .PHONY: all clean distclean runtree programs api datafiles force tags configs dust install default-install