OSDN Git Service

- do not delete the libs i keep for size-comparison
[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 $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
119         $(hcompile.u)
120
121 # Installs kernel header files (linux/*, asm/*, asm-generic/*).
122 install_kernel_headers: headers
123         top_builddir=$(top_builddir) \
124         $(top_srcdir)extra/scripts/install_kernel_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
125
126 # Installs header files.
127 install_headers: headers $(top_builddir)extra/scripts/unifdef
128         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
129         top_builddir=$(top_builddir) \
130         $(top_srcdir)extra/scripts/install_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
131         printf '#ifndef _LIBC_INTERNAL_H\n#define _LIBC_INTERNAL_H 1\n#endif\n' > \
132                 $(PREFIX)$(DEVEL_PREFIX)include/libc-internal.h
133         echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
134                 $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
135         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
136         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/_lfs_64.h
137         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_uintmaxtostr.h
138         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_sigaction.h
139         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_stat.h
140 ifneq ($(UCLIBC_HAS_FLOATS),y)
141         # Remove floating point related headers since float support is disabled.
142         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
143         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
144         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
145         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
146         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
147         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
148 endif
149 ifneq ($(UCLIBC_HAS_FENV),y)
150         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fenv.h \
151                 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenv.h \
152                 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenvinline.h
153 endif
154 ifneq ($(UCLIBC_HAS_WCHAR),y)
155         # Remove wide char headers since wide char support is disabled.
156         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
157         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
158 endif
159 ifneq ($(UCLIBC_HAS_LOCALE),y)
160         # Remove iconv header since locale support is disabled.
161         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
162 endif
163 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
164         # Remove printf header since custom print specifier support is disabled.
165         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
166 endif
167 ifneq ($(UCLIBC_HAS_XLOCALE),y)
168         # Remove xlocale header since extended locale support is disabled.
169         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
170 endif
171 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
172         # Remove libintl header since gettext support is disabled.
173         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
174 endif
175 ifneq ($(UCLIBC_HAS_REGEX),y)
176         # Remove regex headers since regex support is disabled.
177         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
178         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
179 endif
180 ifneq ($(UCLIBC_HAS_WORDEXP),y)
181         # Remove wordexp header since wordexp support is disabled.
182         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
183 endif
184 ifneq ($(UCLIBC_HAS_FTW),y)
185         # Remove ftw header since ftw support is disabled.
186         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
187 endif
188 ifneq ($(UCLIBC_HAS_GLOB),y)
189         # Remove glob header since glob support is disabled.
190         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
191 endif
192 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
193 ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
194         # Remove getopt header since gnu getopt support is disabled.
195         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
196 endif
197 endif
198 ifneq ($(UCLIBC_HAS_SHADOW),y)
199         # Remove shadow header since shadow password support is disabled.
200         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
201 endif
202 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
203         # Remove thread_db header since thread debug support is disabled.
204         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
205 endif
206 ifneq ($(UCLIBC_HAS_THREADS),y)
207         # Remove pthread headers since thread support is disabled.
208         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
209         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
210         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
211 endif
212 ifneq ($(HAVE_SHARED),y)
213         # Remove dlfcn header if we don't have shared libraries.
214         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dlfcn.h
215         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/dlfcn.h
216 endif
217 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
218         # Remove this as it is only used internally.
219         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tls.h
220 endif
221
222 # Installs development library links.
223 install_dev: install_headers
224         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
225         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
226 ifeq ($(HAVE_SHARED),y)
227         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
228         sed -e 's/lib\///'` ; do \
229                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
230                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
231         done
232         if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
233                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
234                 sed -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
235                     -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
236                     -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
237                     $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
238         fi
239 ifeq ($(UCLIBC_HAS_THREADS),y)
240 ifneq ($(LINUXTHREADS_OLD),y)
241         if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) ] ; then \
242                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
243                 cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
244                 echo "GROUP ( $(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) $(DEVEL_PREFIX)lib/libpthread_nonshared.a )" \
245                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
246         fi
247 endif
248 endif
249 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
250         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
251                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
252 endif
253 ifeq ($(DOPIC),y)
254 #       # If we build shared libraries then the static libs are PIC...
255 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
256         if [ -d lib ] ; then \
257                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
258                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
259                                 | sed -e 's/\.a$$/_pic.a/'`; \
260                 done ; \
261         fi
262 endif
263 endif
264 ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
265         for file in lib/lib*.gdb; do \
266                 if test -f $$file; then \
267                         $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \
268                         $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \
269                           $(PREFIX)$(DEVEL_PREFIX)lib; \
270                 fi; \
271         done
272 endif
273
274 # Installs run-time libraries
275 install_runtime:
276 ifeq ($(HAVE_SHARED),y)
277         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
278         $(INSTALL) -m 644 lib/lib*-$(VERSION).so \
279                 $(PREFIX)$(RUNTIME_PREFIX)lib
280         cd lib && $(TAR) -cf - *.so.* | $(TAR) -xf - -C $(PREFIX)$(RUNTIME_PREFIX)lib
281         @if [ -x lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so ] ; then \
282                 set -e; \
283                 $(SHELL_SET_X); \
284                 $(INSTALL) -m 755 lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so \
285                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
286         fi
287 endif
288
289 utils:
290         $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
291
292 # Installs helper applications, such as 'ldd' and 'ldconfig'
293 install_utils: utils
294         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install
295
296 else # ifeq ($(HAVE_DOT_CONFIG),y)
297
298 all: menuconfig
299
300 headers:
301         @echo "Need to make a config file first, run: make menuconfig"
302         @false
303
304 endif # ifeq ($(HAVE_DOT_CONFIG),y)
305
306 include/bits:
307         $(INSTALL) -d include/bits
308
309 # configuration
310 # ---------------------------------------------------------------------------
311 extra/config/conf extra/config/mconf: include/bits
312         $(Q)$(MAKE) -C extra/config $(notdir $@)
313
314 menuconfig: extra/config/mconf include/bits
315         $(Q)./extra/config/mconf extra/Configs/Config.in
316
317 config: extra/config/conf include/bits
318         $(Q)./extra/config/conf extra/Configs/Config.in
319
320 oldconfig: extra/config/conf include/bits
321         $(Q)./extra/config/conf -o extra/Configs/Config.in
322
323 silentoldconfig: extra/config/conf include/bits
324         $(Q)./extra/config/conf -s extra/Configs/Config.in
325
326 randconfig: extra/config/conf include/bits
327         $(Q)./extra/config/conf -r extra/Configs/Config.in
328
329 allyesconfig: extra/config/conf include/bits
330         $(Q)./extra/config/conf -y extra/Configs/Config.in
331         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
332         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
333         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
334         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
335         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
336         $(Q)./extra/config/conf -o extra/Configs/Config.in
337
338 allnoconfig: extra/config/conf include/bits
339         $(Q)./extra/config/conf -n extra/Configs/Config.in
340
341 defconfig: extra/config/conf include/bits
342         $(Q)./extra/config/conf -d extra/Configs/Config.in
343
344 clean:
345         $(Q)$(RM) -r lib include/bits
346         $(RM) ldso/*/*.a libpthread/*/*.a libc/*.a libcrypt/*.a libintl/*.a \
347                 libm/*.a libnsl/*.a libpthread/*.a libresolv/*.a librt/*.a \
348                 libutil/*.a lib/*.a \
349                 include/fpu_control.h include/dl-osinfo.h include/hp-timing.h
350         $(MAKE) objclean-y headers_clean-y
351         $(MAKE) -s -C test clean
352         $(MAKE) -C utils utils_clean
353         @set -e; \
354         for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
355                 $(RM) include/sys/$$i; \
356         done; \
357         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
358                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
359                         $(RM) include/sys/$$i; \
360                 done; \
361         fi
362         @$(RM) include/linux include/asm*
363         $(RM) $(top_builddir)extra/scripts/unifdef
364
365 distclean: clean
366         -find . \( -name core -o -name \*.orig -o -name \*~ \) -exec $(RM) {} \;
367         $(RM) .config .config.old .config.cmd
368         $(RM) extra/locale/*.tgz
369         $(MAKE) -C extra/config distclean
370
371 dist release:
372         $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
373         svn -q export . ../uClibc-$(VERSION)
374         $(TAR) cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
375         du -b ../uClibc-$(VERSION).tar.bz2
376
377 test check:
378         $(Q)$(MAKE) -C test