OSDN Git Service

- fix generation of sysnum.h for parallel builds, second take.
[uclinux-h8/uClibc.git] / Makefile.in
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
8 #--------------------------------------------------------------
9 # You shouldn't need to mess with anything beyond this point...
10 #--------------------------------------------------------------
11 noconfig_targets := menuconfig config oldconfig silentoldconfig randconfig \
12         defconfig allyesconfig allnoconfig clean distclean \
13         release dist tags
14
15 include $(top_builddir)Rules.mak
16 sub_headers := headers
17
18 ifeq ($(HAVE_DOT_CONFIG),y)
19
20 all: pregen libs
21
22 # In this section, we need .config
23 -include .config.cmd
24
25 include $(top_srcdir)ldso/Makefile.in
26 include $(top_srcdir)libcrypt/Makefile.in
27 include $(top_srcdir)libintl/Makefile.in
28 include $(top_srcdir)libm/Makefile.in
29 include $(top_srcdir)libnsl/Makefile.in
30 include $(top_srcdir)libresolv/Makefile.in
31 include $(top_srcdir)libutil/Makefile.in
32 include $(top_srcdir)libpthread/Makefile.in
33 include $(top_srcdir)librt/Makefile.in
34 include $(top_srcdir)extra/locale/Makefile.in
35
36 # last included to catch all the objects added by others (locales/threads)
37 include $(top_srcdir)libc/Makefile.in
38
39 include/bits/uClibc_config.h: extra/config/conf .config
40         $(Q)$(INSTALL) -d $(dir $@)
41         $(Q)@$< -o $(top_srcdir)extra/Configs/Config.in
42         $(top_srcdir)extra/scripts/conf-header.sh .config > include/bits/uClibc_config.h
43
44
45 # For the moment, we have to keep re-running this target
46 # because the fix includes scripts rely on pre-processers
47 # in order to generate the headers correctly :(.  That
48 # means we can't use the $(HOSTCC) in order to get the
49 # correct output.
50 ifeq ($(ARCH_USE_MMU),y)
51 export header_extra_args =
52 else
53 export header_extra_args = -n
54 endif
55 HEADERS_BITS_COMMON := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common/bits/*.h))
56 HEADERS_BITS_ARCH   := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h))
57 HEADERS_BITS_SUBARCH   := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/*.h))
58 HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_ARCH) $(HEADERS_BITS_SUBARCH),$(HEADERS_BITS_COMMON))
59 headers: include/bits/uClibc_config.h
60         $(Q)$(MAKE) headers-y
61         $(Q)\
62         set -e; \
63         if [ -e libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
64                 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
65         else \
66                 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
67         fi; \
68         for f in dl-osinfo.h hp-timing.h ; do \
69                 $(LN) -fs ../libc/sysdeps/linux/common/$$f include/ ; \
70         done
71         $(Q)\
72         cd include/bits; \
73         set -e; \
74         for i in $(HEADERS_BITS_COMMON) ; do \
75                 $(LN) -fs ../../libc/sysdeps/linux/common/bits/$$i .; \
76         done; \
77         for i in $(HEADERS_BITS_ARCH) ; do \
78                 $(LN) -fs ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$$i .; \
79         done; \
80         for i in $(HEADERS_BITS_SUBARCH) ; do \
81                 $(LN) -fs ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/$$i .; \
82         done
83         $(Q)\
84         cd include/sys; \
85         set -e; \
86         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
87                 $(LN) -fs $$i .; \
88         done; \
89         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
90                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
91                         $(LN) -fs $$i .; \
92                 done; \
93         fi
94 ifeq ($(UCLIBC_HAS_LOCALE),y)
95         $(MAKE) -C extra/locale locale_headers
96 endif
97
98
99 pregen: headers
100         $(Q)\
101         set -e; \
102         cd $(top_builddir); \
103         tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \
104         [ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \
105         KERNEL_HEADERS="${KERNEL_HEADERS}" top_builddir=. CC="$(CC) $(CPU_CFLAGS)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
106         if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \
107                 $(RM) $$tmp; \
108         else \
109                 mv -f $$tmp include/bits/sysnum.h; \
110         fi
111
112
113 install: install_runtime install_dev
114
115
116 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
117
118 # Installs header files.
119 install_headers: headers
120         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
121         printf ".svn\n.cvsignore\nCVS\n" > tar_exclude ; \
122         $(TAR) -chf - -X tar_exclude include \
123                 | $(TAR) -xf - -C $(PREFIX)$(DEVEL_PREFIX)
124         rm -f tar_exclude
125         printf '#ifndef _LIBC_INTERNAL_H\n#define _LIBC_INTERNAL_H 1\n#endif\n' > \
126                 $(PREFIX)$(DEVEL_PREFIX)include/libc-internal.h
127         echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
128                 $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
129         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
130         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/_lfs_64.h
131         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_uintmaxtostr.h
132         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_sigaction.h
133         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_stat.h
134 ifneq ($(UCLIBC_HAS_FLOATS),y)
135         # Remove floating point related headers since float support is disabled.
136         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
137         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
138         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
139         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
140         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
141         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
142 endif
143 ifneq ($(UCLIBC_HAS_FENV),y)
144         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fenv.h \
145                 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenv.h \
146                 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenvinline.h
147 endif
148 ifneq ($(UCLIBC_HAS_WCHAR),y)
149         # Remove wide char headers since wide char support is disabled.
150         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
151         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
152 endif
153 ifneq ($(UCLIBC_HAS_LOCALE),y)
154         # Remove iconv header since locale support is disabled.
155         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
156 endif
157 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
158         # Remove printf header since custom print specifier support is disabled.
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
160 endif
161 ifneq ($(UCLIBC_HAS_XLOCALE),y)
162         # Remove xlocale header since extended locale support is disabled.
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
164 endif
165 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
166         # Remove libintl header since gettext support is disabled.
167         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
168 endif
169 ifneq ($(UCLIBC_HAS_REGEX),y)
170         # Remove regex headers since regex support is disabled.
171         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
173 endif
174 ifneq ($(UCLIBC_HAS_WORDEXP),y)
175         # Remove wordexp header since wordexp support is disabled.
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
177 endif
178 ifneq ($(UCLIBC_HAS_FTW),y)
179         # Remove ftw header since ftw support is disabled.
180         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
181 endif
182 ifneq ($(UCLIBC_HAS_GLOB),y)
183         # Remove glob header since glob support is disabled.
184         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
185 endif
186 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
187 ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
188         # Remove getopt header since gnu getopt support is disabled.
189         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
190 endif
191 endif
192 ifneq ($(UCLIBC_HAS_SHADOW),y)
193         # Remove shadow header since shadow password support is disabled.
194         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
195 endif
196 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
197         # Remove thread_db header since thread debug support is disabled.
198         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
199 endif
200 ifneq ($(UCLIBC_HAS_THREADS),y)
201         # Remove pthread headers since thread support is disabled.
202         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
203         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
204         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
205 endif
206 ifneq ($(HAVE_SHARED),y)
207         # Remove dlfcn header if we don't have shared libraries.
208         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dlfcn.h
209         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/dlfcn.h
210 endif
211 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
212         # Remove this as it is only used internally.
213         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tls.h
214 endif
215         -@for i in `find $(PREFIX)$(DEVEL_PREFIX)include -type d` ; do \
216             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
217         done
218         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)include
219
220 # Installs development library links.
221 install_dev: install_headers
222         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
223         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
224 ifeq ($(HAVE_SHARED),y)
225         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
226         sed -e 's/lib\///'` ; do \
227                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
228                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
229         done
230         if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
231                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
232                 sed -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
233                     -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
234                     -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
235                     $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
236         fi
237 ifeq ($(UCLIBC_HAS_THREADS),y)
238 ifneq ($(LINUXTHREADS_OLD),y)
239         if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) ] ; then \
240                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
241                 cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
242                 echo "GROUP ( $(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) $(DEVEL_PREFIX)lib/libpthread_nonshared.a )" \
243                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
244         fi
245 endif
246 endif
247 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
248         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
249                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
250 endif
251 ifeq ($(DOPIC),y)
252 #       # If we build shared libraries then the static libs are PIC...
253 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
254         if [ -d lib ] ; then \
255                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
256                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
257                                 | sed -e 's/\.a$$/_pic.a/'`; \
258                 done ; \
259         fi
260 endif
261 endif
262 ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
263         for file in lib/lib*.gdb; do \
264                 if test -f $$file; then \
265                         $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \
266                         $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \
267                           $(PREFIX)$(DEVEL_PREFIX)lib; \
268                 fi; \
269         done
270 endif
271
272 # Installs run-time libraries
273 install_runtime:
274 ifeq ($(HAVE_SHARED),y)
275         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
276         $(INSTALL) -m 644 lib/lib*-$(VERSION).so \
277                 $(PREFIX)$(RUNTIME_PREFIX)lib
278         cd lib && $(TAR) -cf - *.so.* | $(TAR) -xf - -C $(PREFIX)$(RUNTIME_PREFIX)lib
279         @if [ -x lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so ] ; then \
280                 set -e; \
281                 $(SHELL_SET_X); \
282                 $(INSTALL) -m 755 lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so \
283                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
284         fi
285 endif
286
287 utils:
288         $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
289
290 # Installs helper applications, such as 'ldd' and 'ldconfig'
291 install_utils: utils
292         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install
293
294 else # ifeq ($(HAVE_DOT_CONFIG),y)
295
296 all: menuconfig
297
298 headers:
299         @echo "Need to make a config file first, run: make menuconfig"
300         @false
301
302 endif # ifeq ($(HAVE_DOT_CONFIG),y)
303
304 include/bits:
305         $(INSTALL) -d include/bits
306
307 # configuration
308 # ---------------------------------------------------------------------------
309 extra/config/conf extra/config/mconf: include/bits
310         $(Q)$(MAKE) -C extra/config $(notdir $@)
311
312 menuconfig: extra/config/mconf include/bits
313         $(Q)./extra/config/mconf extra/Configs/Config.in
314
315 config: extra/config/conf include/bits
316         $(Q)./extra/config/conf extra/Configs/Config.in
317
318 oldconfig: extra/config/conf include/bits
319         $(Q)./extra/config/conf -o extra/Configs/Config.in
320
321 silentoldconfig: extra/config/conf include/bits
322         $(Q)./extra/config/conf -s extra/Configs/Config.in
323
324 randconfig: extra/config/conf include/bits
325         $(Q)./extra/config/conf -r extra/Configs/Config.in
326
327 allyesconfig: extra/config/conf include/bits
328         $(Q)./extra/config/conf -y extra/Configs/Config.in
329         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
330         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
331         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
332         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
333         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
334         $(Q)./extra/config/conf -o extra/Configs/Config.in
335
336 allnoconfig: extra/config/conf include/bits
337         $(Q)./extra/config/conf -n extra/Configs/Config.in
338
339 defconfig: extra/config/conf include/bits
340         $(Q)./extra/config/conf -d extra/Configs/Config.in
341
342 clean:
343         $(Q)$(RM) -r lib include/bits
344         $(RM) lib*/*.a ldso/*/*.a libpthread/*/*.a
345         $(RM) include/fpu_control.h include/dl-osinfo.h include/hp-timing.h
346         $(MAKE) objclean-y headers_clean-y
347         $(MAKE) -s -C test clean
348         $(MAKE) -C utils utils_clean
349         @set -e; \
350         for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
351                 $(RM) include/sys/$$i; \
352         done; \
353         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
354                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
355                         $(RM) include/sys/$$i; \
356                 done; \
357         fi
358         @$(RM) include/linux include/asm*
359
360 distclean: clean
361         -find . \( -name core -o -name \*.orig -o -name \*~ \) -exec $(RM) {} \;
362         $(RM) .config .config.old .config.cmd
363         $(RM) extra/locale/*.tgz
364         $(MAKE) -C extra/config distclean
365
366 dist release:
367         $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
368         svn -q export . ../uClibc-$(VERSION)
369         $(TAR) cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
370         du -b ../uClibc-$(VERSION).tar.bz2
371
372 test check:
373         $(Q)$(MAKE) -C test