OSDN Git Service

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