OSDN Git Service

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