OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / Makefile
1 ##############################################################################
2 #
3 #       Makefile -- Master makefile for all libraries.
4 #
5
6 .EXPORT_ALL_VARIABLES:
7
8 all:
9
10 ##############################################################################
11 #
12 # Include architecture specific build rules.
13 #
14
15 _reldir = .
16 include lib.mak
17
18 ##############################################################################
19
20 dir_base = $(LIBCDIR)
21
22 ifeq ($(LIBCDIR),libc)
23 .PHONY:
24 libm: $(LIBCDIR)
25 dir_base += libm
26 lib_libm = *.a
27 inc_libm = *.h,.
28 endif
29
30 .PHONY: libcrypt_old
31 libcrypt_old: $(LIBCDIR)
32 ifeq ($(LIBCDIR),libc)
33 dir_base += libcrypt_old
34 else
35 dir_$(CONFIG_LIB_LIBCRYPT_OLD) += libcrypt_old
36 endif
37 lib_libcrypt_old = libcrypt_old.a
38 inc_libcrypt_old = *.h,.
39
40 dir_$(CONFIG_LIB_ADNS) += adns
41 lib_adns = src/libadns.a
42
43 dir_$(CONFIG_LIB_FLEX) += flex
44 lib_flex = build/*.a
45 inc_flex = build/FlexLexer.h,.
46
47 dir_$(CONFIG_LIB_LIBSSL)+= libssl
48 lib_libssl = build/*.so* build/*.a
49 inc_libssl = build/include/*,.
50
51 dir_$(CONFIG_LIB_LIBGMP) += libgmp
52 lib_libgmp = build/install/lib/*.a
53 inc_libgmp = build/install/include/*.h,.
54
55 dir_$(CONFIG_LIB_LIBG) += libg
56 lib_libg = *.a
57
58 dir_$(CONFIG_LIB_LIBPAM) += libpam
59 lib_libpam = build/libpam*/.libs/*.a build/libpam*/.libs/*.so
60 inc_libpam = */include/security/*.h,security
61
62 dir_$(CONFIG_LIB_LIBPCAP) += libpcap
63 lib_libpcap = *.a
64 inc_libpcap = \
65         pcap*.h,. \
66         pcap/*.h,pcap \
67         net/bpf.h,net
68
69 dir_$(CONFIG_LIB_ZLIB) += zlib
70 lib_zlib = libz.a* libz.so*
71 inc_zlib = *.h,. \
72
73 dir_$(CONFIG_LIB_LIBBZ2) += libbzip2
74 lib_libbzip2 = libbz2.a* libbz2.so*
75 inc_libbzip2 = bzlib.h,.
76
77 dir_$(CONFIG_LIB_LIBATM) += libatm
78 lib_libatm = \
79         src/lib/.libs/*.a \
80         src/lib/*.so* \
81         src/lib/*.a
82 inc_libatm = src/include/atm*.h,.
83
84 dir_$(CONFIG_LIB_LIBNET) += Libnet
85
86 dir_$(CONFIG_LIB_LIBNETOLD) += libnet
87 lib_libnet = *.a
88 inc_libnet = *.h,.
89
90 dir_$(CONFIG_LIB_LIBJPEG) += libjpeg
91 lib_libjpeg = *.a
92 inc_libjpeg = *.h,.
93
94 dir_$(CONFIG_LIB_LIBUPNP) += libupnp
95 lib_libupnp = upnp/bin/*.so*
96 inc_libupnp = upnp/inc/upnp,.
97
98 dir_$(CONFIG_LIB_EXPAT) += expat
99 lib_expat = *.a *.so*
100 inc_expat = lib/expat.h,.
101
102 dir_$(CONFIG_LIB_LIBKRB5) += libkrb5
103 dep_libkrb5 = termcap
104 lib_libkrb5 = build/lib/*.so
105 inc_libkrb5 = \
106         build/include/com_err.h,. \
107         build/include/krb5/*.h,. \
108         build/include/gssapi/*.h,.
109
110 dir_$(CONFIG_LIB_CYRUSSASL) += libcyrussasl
111 dep_libcyrussasl = libkrb5
112 lib_libcyrussasl = build/lib/.libs/*.so
113 inc_libcyrussasl = \
114         include/*.h,sasl \
115         build/include/*.h,sasl \
116
117 dir_$(CONFIG_LIB_LIBLDAP) += libldap
118 dep_libldap = libcyrussasl
119 lib_libldap = \
120         builddir/libraries/libldap/.libs/*.a \
121         builddir/libraries/liblber/.libs/*.a
122 inc_libldap = \
123         include/*.h,. \
124         builddir/include/*.h,.
125
126 dir_$(CONFIG_LIB_TINYTCL) += tinytcl
127 path_tinytcl = ../user/tinytcl
128 lib_tinytcl = *.a* *.so*
129 inc_tinytcl = *.h,.
130
131 dir_$(CONFIG_LIB_LIBCCMALLOC) += libccmalloc
132
133 dir_$(CONFIG_LIB_ARES) += libares
134 lib_libares = build/*.a
135 inc_libares = ares.h,.
136
137 dir_$(CONFIG_LIB_LIBIDN) += libidn
138 lib_libidn = build/lib/.libs/libidn.a
139 inc_libidn = lib/*.h,.
140
141 dir_$(CONFIG_LIB_LIBLZO) += lzo
142 lib_lzo = build/src/.libs/*.a
143 inc_lzo = include/lzo,.
144
145 dir_$(CONFIG_LIB_LIBPCRE) += pcre
146 lib_pcre = builddir/.libs/*.a
147 inc_pcre = \
148         builddir/pcre.h,. \
149         pcreposix.h,.
150
151 dir_$(CONFIG_LIB_LIBLZMA) += liblzma
152 lib_libzlma = *.a
153
154 dir_$(CONFIG_LIB_OSIP2) += osip2
155 lib_osip2 = build/install/lib/*.a
156 inc_osip2 = build/install/include/osip*2,.
157
158 dir_$(CONFIG_LIB_LIBEFENCE) += libefence
159 lib_libefence = *.a
160
161 dir_$(CONFIG_LIB_TERMCAP) += termcap
162 lib_termcap = *.a
163 inc_termcap = termcap.h,.
164
165 dir_$(CONFIG_LIB_LIBSYSFS) += sysfsutils
166 lib_sysfsutils = build/lib/.libs/*.a
167 inc_sysfsutils = include/*.h,sysfs
168
169 dir_$(CONFIG_LIB_LIBNL) += libnl
170 lib_libnl = build/libnl*-install/lib/*.a* build/libnl*-install/lib/*.so*
171 inc_libnl = build/libnl*-install/include/libnl*/netlink*,.
172
173 dir_$(CONFIG_USER_TCL_LIBTCL) += tcl
174 path_tcl = ../user/tcl
175 lib_tcl = build/*.a
176
177 dir_$(CONFIG_LIB_IPTABLES) += iptables
178 path_iptables = ../user/iptables
179 lib_iptables = install/lib/*.a install/lib/*.so*
180 inc_iptables = install/include/*,.
181
182 dir_$(CONFIG_LIB_LIBIBERTY) += libiberty
183 lib_libiberty = build/*.a
184
185 dir_$(CONFIG_LIB_BFD) += bfd
186 lib_bfd = build/*.a
187 inc_bfd = build/bfd.h,.
188
189 dir_$(CONFIG_LIB_POPT) += popt
190 lib_popt = build/.libs/*.a
191 inc_popt = popt.h,.
192
193 dir_$(CONFIG_LIB_LIBJUDY) += libjudy
194 lib_libjudy = \
195         src/obj/.libs/libJudy.a \
196         src/obj/.libs/libJudy.so
197
198 dir_$(CONFIG_LIB_CLASSPATH) += classpath
199
200 dir_$(CONFIG_LIB_BITVECTOR) += bitvector
201 lib_bitvector = *.so
202 inc_bitvector = *.h,.
203
204 dir_$(CONFIG_LIB_LIBNVRAM) += libnvram
205 lib_libnvram = *.so *.a
206 inc_libnvram = *.h,.
207
208 dir_$(CONFIG_LIB_LIBPNG) += libpng
209 dep_libpng = zlib
210 lib_libpng = *.a
211 inc_libpng = *.h,.
212
213 dir_$(CONFIG_LIB_LIBXML2) += libxml2
214 lib_libxml2 = build/.libs/libxml2.so
215 inc_libxml2 = \
216         include/libxml/*.h,libxml \
217         build/include/libxml/*.h,libxml
218
219 dir_$(CONFIG_LIB_NFNETLINK) += libnfnetlink
220 lib_libnfnetlink = \
221         build/src/.libs/*.a* \
222         build/src/.libs/*.so* \
223         build/libnfnetlink.pc
224 inc_libnfnetlink = include/libnfnetlink,.
225
226 dir_$(CONFIG_LIB_NETFILTER_LOG) += libnetfilter_log
227 dep_libnetfilter_log = libnfnetlink
228 lib_libnetfilter_log = \
229         build/src/.libs/*.a* \
230         build/src/.libs/*.so* \
231         build/libnetfilter_log.pc
232 inc_libnetfilter_log = include/libnetfilter_log,.
233
234 dir_$(CONFIG_LIB_NETFILTER_CONNTRACK) += libnetfilter_conntrack
235 dep_libnetfilter_conntrack = libnfnetlink
236 lib_libnetfilter_conntrack = \
237         build/src/.libs/*.a* \
238         build/src/.libs/*.so* \
239         build/libnetfilter_conntrack.pc
240 inc_libnetfilter_conntrack = include/libnetfilter_conntrack,.
241
242 dir_$(CONFIG_LIB_PWLIB) += pwlib
243 dep_pwlib = STLport
244
245 dir_$(CONFIG_LIB_LIBOPENH323) += libopenh323
246 dep_libopenh323 = pwlib
247
248 dir_$(CONFIG_LIB_MINI_LIBINTL) += mini-libintl 
249 inc_mini-libintl = libintl.h,.
250
251
252 dep_glib = libiconv mini-iconv libffi gettext mini-libintl
253 dep_libusb-compat = libusb
254
255 dep_dbus-glib = dbus glib
256
257 ifdef CONFIG_LIB_JSON_C
258 dep_libubox += json-c
259 endif
260
261 dep_libfuse = mini-iconv libiconv
262
263 inc_libiconv = build/libiconv*-install/include/*.h,.
264 lib_libiconv = build/libiconv*-install/lib/*.a
265
266 inc_glib = build/glib*-install/include/*,.
267 lib_glib = build/glib*-install/lib/*.a \
268                    build/glib*-install/lib/*.so
269
270 inc_libroxml = build/libroxml*-install/usr/include/*,.
271 lib_libroxml = build/libroxml*-install/usr/lib/*.a \
272                        build/libroxml*-install/usr/lib/*.so
273
274 #
275 # dir 6, 7 and 8 reserved for Makefile.local
276 #
277 -include Makefile.local
278
279 # And build libraries in the prop directory last
280 dir_extra += $(ROOTDIR)/prop
281
282 include Makefile.auto
283
284 ##############################################################################
285
286 DIRS_y   = $(sort $(dir_base) $(dir_y) $(dir_extra))
287 DIRS_all = $(dir_$(n)_n) $(dir_$(n)_) $(sort $(dir_base) $(dir_y) $(dir_n) $(dir_) $(dir_extra))
288 DIRPATH = $(if $(path_$(1)),$(path_$(1)),$(1))
289
290 ##############################################################################
291
292 # The dynamic linker library needs to be linked into lib via a different name
293 LD_LIB = $(ROOTDIR)/lib/uClibc/lib/ld-uClibc-0.9.29.so
294 LD_LIB_DEST = $(STAGEDIR)/lib/ld-linux.so.2
295
296 ##############################################################################
297
298 all: base $(DIRS_y)
299
300 define dep
301 .PHONY: $(1)
302 $(1): base $(dep_$(1))
303 endef
304
305 $(foreach d,$(sort $(dir_y) $(dir_n) $(dir_)),$(eval $(call dep,$(d))))
306
307 .PHONY: base
308 base: $(dir_base) basepost
309         @ln -sf $(LD_LIB) $(LD_LIB_DEST)                
310
311 $(dir_base): baseprep
312
313 basepost: $(dir_base)
314
315 .PHONY: baseprep
316 baseprep:
317         mkdir -p $(STAGEDIR)/lib
318         $(MAKE) -j1 -C ../include || exit $$?
319
320 .PHONY: basepost
321 basepost:
322 ifneq ($(findstring uClibc,$(LIBCDIR)),)
323         $(MAKE) -C $(LIBCDIR) install_headers PREFIX=$(STAGEDIR)/ DEVEL_PREFIX=uClibc/
324 endif
325
326 .PHONY: $(dir_extra)
327 $(dir_extra): base $(dir_y)
328
329 # the actual dir target
330 .PHONY: $(DIRS_y)
331 $(DIRS_y):
332         i=$(call DIRPATH,$@); [ ! -d $$i ] || ( touch $$i/.sgbuilt_lib && $(MAKE) $(SUBDIR_SMP_BUILD) -C $$i ) || exit $$?
333         @set -f; \
334         for p in $(lib_$@); do \
335                 set +f; \
336                 for i in $(ROOTDIR)/lib/$(call DIRPATH,$@)/$$p; do \
337                         [ ! -e "$$i" ] && continue; \
338                         [ "`basename $$i`" = CVS ] && continue; \
339                         [ -L "$(STAGEDIR)/lib/`basename $$i`" ] && continue; \
340                         ln -s $$i $(STAGEDIR)/lib/.; \
341                         echo "ln -s $$i $(STAGEDIR)/lib/."; \
342                 done ; \
343         done    
344         @set -f; \
345         for p in $(inc_$@); do \
346                 src=$(ROOTDIR)/lib/$(call DIRPATH,$@)/`expr "$$p" : '\(.*\),.*'` ; \
347                 dst=$(STAGEDIR)/include/`expr "$$p" : '.*,\(.*\)'` ; \
348                 set +f; \
349                 for i in $$src; do \
350                         [ ! -e "$$i" ] && continue; \
351                         [ "`basename $$i`" = CVS ] && continue; \
352                         [ -L "$$dst/`basename $$i`" ] && continue; \
353                         [ -d $$dst ] || mkdir $$dst; \
354                         ln -s $$i $$dst/.; \
355                         echo "ln -s $$i $$dst/."; \
356                 done ; \
357         done
358
359 %_only:
360         touch $(@:_only=)/.sgbuilt_lib && $(MAKE) -j$(HOST_NCPU) $(SUBDIR_SMP_BUILD) -C $(@:_only=)
361
362 %_clean:
363         $(MAKE) -j1 -C $(@:_clean=) clean; rm -f $(@:_clean=)/.sgbuilt_lib; true
364
365 %_romfs:
366         $(MAKE) $(SUBDIR_SMP_BUILD) -C $(@:_romfs=) romfs
367
368 ##############################################################################
369
370 # Not the best place to install these symlinks, but it will do for now
371 romfs:
372         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/passwd /etc/passwd
373         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/group /etc/group
374         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/mtab /etc/mtab
375         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/fstab /etc/fstab
376         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/hosts /etc/hosts
377         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -s /etc/config/resolv.conf /etc/resolv.conf
378         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -e CONFIG_USER_BASH_BASH -s /etc/config/profile /etc/profile
379         $(ROMFSINST) -e CONFIG_USER_FLATFSD_FLATFSD -e CONFIG_USER_TINYLOGIN_SHADOWPASSWDS -s /etc/config/shadow /etc/shadow
380         for i in $(foreach d,$(DIRS_y),$(call DIRPATH,$d)) ; do \
381                 [ ! -d $$i ] || $(MAKE) $(SUBDIR_SMP_BUILD) -C $$i romfs || exit $$? ; \
382         done
383
384 ##############################################################################
385
386 clean:
387         -for i in $(foreach d,$(DIRS_all),$(call DIRPATH,$d)); do \
388                 if [ -f $$i/.sgbuilt_lib ]; then \
389                         $(MAKE) -C $$i clean ; \
390                         rm -f $$i/.sgbuilt_lib; \
391                 fi; \
392         done
393
394 ##############################################################################
395
396 prune:
397         -for i in $(foreach d,$(DIRS_all),$(call DIRPATH,$d)); do \
398                 found=0; \
399                 for j in $(sort $(foreach d,$(DIRS_y),$(call DIRPATH,$d))) ; do \
400                         if [ $$i = $$j ]; then \
401                                 found=1; \
402                         fi; \
403                 done; \
404                 if [ $$found = 0 ]; then \
405                         rm -fr $$i; \
406                 fi; \
407         done
408
409 ##############################################################################