OSDN Git Service

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