OSDN Git Service

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