OSDN Git Service

Fix bug 430 and reduce ldso size with 1KB :). Not sure if I need to use fstat64,...
[uclinux-h8/uclibc-ng.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later
9 # version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Library General Public License for more details.
15 #
16 # You should have received a copy of the GNU Library General
17 # Public License along with this program; if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 # Boston, MA 02111-1307 USA
20
21
22 #--------------------------------------------------------------
23 # You shouldn't need to mess with anything beyond this point...
24 #--------------------------------------------------------------
25 noconfig_targets := menuconfig config oldconfig randconfig \
26         defconfig allyesconfig allnoconfig clean distclean \
27         release tags TAGS
28 TOPDIR=./
29 include Rules.mak
30
31 DIRS = ldso libc libcrypt libresolv libnsl libutil libm libpthread librt
32 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
33         DIRS += libintl
34 endif
35
36 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
37
38 all: headers pregen subdirs shared finished
39
40 # In this section, we need .config
41 -include .config.cmd
42
43 shared: subdirs
44 ifeq ($(strip $(HAVE_SHARED)),y)
45         $(SECHO)
46         $(SECHO) Building shared libraries ...
47         $(SECHO)
48         @$(MAKE) -C libc shared
49         @$(MAKE) -C ldso shared
50         @$(MAKE) -C libcrypt shared
51         @$(MAKE) -C libresolv shared
52         @$(MAKE) -C libnsl shared
53         @$(MAKE) -C libutil shared
54         @$(MAKE) -C libm shared
55         @$(MAKE) -C libpthread shared
56         @$(MAKE) -C librt shared
57 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
58         @$(MAKE) -C libintl shared
59 endif
60 else
61         $(SECHO)
62         $(SECHO) Not building shared libraries ...
63         $(SECHO)
64 endif
65
66 finished: shared
67         $(SECHO)
68         $(SECHO) Finally finished compiling ...
69         $(SECHO)
70
71 include/bits/uClibc_config.h: .config
72         @if [ ! -x ./extra/config/conf ] ; then \
73             $(MAKE) -C extra/config conf; \
74         fi;
75         $(RM) -r include/bits
76         $(INSTALL) -d include/bits
77         @./extra/config/conf -o extra/Configs/Config.in
78
79 # For the moment, we have to keep re-running this target 
80 # because the fix includes scripts rely on pre-processers 
81 # in order to generate the headers correctly :(.  That 
82 # means we can't use the $(HOSTCC) in order to get the 
83 # correct output.
84 ifeq ($(strip $(ARCH_HAS_MMU)),y)
85 export header_extra_args = 
86 else
87 export header_extra_args = -n
88 endif
89 headers: include/bits/uClibc_config.h
90         @$(SHELL_SET_X); \
91         ./extra/scripts/fix_includes.sh \
92                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
93                 $(header_extra_args)
94         @cd include/bits; \
95         set -e; \
96         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
97                 $(LN) -fs $$i .; \
98         done; \
99         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
100                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
101                         $(LN) -fs $$i .; \
102                 done; \
103         fi
104         @cd include/sys; \
105         set -e; \
106         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
107                 $(LN) -fs $$i .; \
108         done; \
109         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
110                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
111                         $(LN) -fs $$i .; \
112                 done; \
113         fi
114         @cd $(TOPDIR); \
115         set -e; \
116         $(SHELL_SET_X); \
117         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
118         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
119                 $(RM) include/bits/sysnum.h.new; \
120         else \
121                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
122         fi
123         $(MAKE) -C libc/sysdeps/linux/common headers
124         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
125
126 # Command used to download source code
127 WGET:=wget --passive-ftp
128
129 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
130
131 pregen: headers
132 ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
133         (cd extra/locale; \
134         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
135         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
136         fi );
137 endif
138 ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
139         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
140         $(MAKE) -C extra/locale pregen
141 endif
142
143
144 subdirs: $(patsubst %, _dir_%, $(DIRS))
145 $(patsubst %, _dir_%, $(DIRS)): headers
146         $(MAKE) -C $(patsubst _dir_%, %, $@)
147
148 tags:
149         ctags -R
150
151 install: install_runtime install_dev finished2
152
153
154 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
155
156 # Installs header files and development library links.
157 install_dev:
158         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
159         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
160         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
161         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
162                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
163         else \
164                 extra_exclude="" ; \
165         fi ; \
166         tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
167                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
168 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
169         # Remove floating point related headers since float support is disabled.
170         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
171         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
173         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
174         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
175 endif
176 ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
177         # Remove wide char headers since wide char support is disabled.
178         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
179         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
180 endif
181 ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
182         # Remove iconv header since locale support is disabled.
183         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
184 endif
185 ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
186         # Remove printf header since custom print specifier support is disabled.
187         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
188 endif
189 ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
190         # Remove xlocale header since extended locale support is disabled.
191         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
192 endif
193 ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
194         # Remove libintl header since gettext support is disabled.
195         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
196 endif
197 ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
198         # Remove regex headers since regex support is disabled.
199         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
200         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
201 endif
202 ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
203         # Remove wordexp header since wordexp support is disabled.
204         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
205 endif
206 ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
207         # Remove ftw header since ftw support is disabled.
208         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
209 endif
210 ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
211         # Remove glob header since glob support is disabled.
212         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
213 endif
214 ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
215         # Remove getopt header since gnu getopt support is disabled.
216         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
217 endif
218 ifneq ($(strip $(HAS_SHADOW)),y)
219         # Remove getopt header since shadow password support is disabled.
220         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
221 endif
222         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
223             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
224         done;
225         -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
226         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
227 ifeq ($(strip $(HAVE_SHARED)),y)
228         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
229         sed -e 's/lib\///'` ; do \
230                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
231                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
232         done;
233 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
234         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
235                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
236 endif
237 #       # If we build shared libraries then the static libs are PIC...
238 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
239         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
240                 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
241                         | sed -e 's/\.a$$/_pic.a/'`; \
242         done;
243         # Ugh!!! Remember that libdl.a and libdl_pic.a are different.  Since
244         # libdl is pretty small, and not likely to benefit from mklibs.py and
245         # similar, lets just remove libdl_pic.a and avoid the issue
246         rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
247 endif
248
249
250 # Installs run-time libraries
251 install_runtime:
252 ifeq ($(strip $(HAVE_SHARED)),y)
253         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
254         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
255                 $(PREFIX)$(RUNTIME_PREFIX)lib
256         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
257         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
258             set -e; \
259                 $(SHELL_SET_X); \
260             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
261                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
262         fi;
263 endif
264
265 .PHONY: utils
266 ifeq ($(strip $(HAVE_SHARED)),y)
267 utils:
268         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
269 else
270 utils: dummy
271 endif
272
273 # Installs helper applications, such as 'ldd' and 'ldconfig'
274 install_utils: utils
275         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
276 #ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
277 #       @$(MAKE) -C libc/misc/wchar iconv.target
278 #       $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
279 #       $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
280 #endif
281
282 finished2:
283         $(SECHO)
284         $(SECHO) Finished installing ...
285         $(SECHO)
286
287 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
288
289 all: menuconfig
290
291 # configuration
292 # ---------------------------------------------------------------------------
293 extra/config/conf:
294         $(MAKE) -C extra/config conf
295
296 extra/config/mconf:
297         $(MAKE) -C extra/config ncurses mconf
298
299 menuconfig: extra/config/mconf
300         $(RM) -r include/bits
301         $(INSTALL) -d include/bits
302         @./extra/config/mconf extra/Configs/Config.in
303
304 config: extra/config/conf
305         $(RM) -r include/bits
306         $(INSTALL) -d include/bits
307         @./extra/config/conf extra/Configs/Config.in
308
309 oldconfig: extra/config/conf
310         $(RM) -r include/bits
311         $(INSTALL) -d include/bits
312         @./extra/config/conf -o extra/Configs/Config.in
313
314 randconfig: extra/config/conf
315         $(RM) -r include/bits
316         $(INSTALL) -d include/bits
317         @./extra/config/conf -r extra/Configs/Config.in
318
319 allyesconfig: extra/config/conf
320         $(RM) -r include/bits
321         $(INSTALL) -d include/bits
322         @./extra/config/conf -y extra/Configs/Config.in
323         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
324         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
325         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
326         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
327         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
328         @./extra/config/conf -o extra/Configs/Config.in
329
330 allnoconfig: extra/config/conf
331         $(RM) -r include/bits
332         $(INSTALL) -d include/bits
333         @./extra/config/conf -n extra/Configs/Config.in
334
335 defconfig: extra/config/conf
336         $(RM) -r include/bits
337         $(INSTALL) -d include/bits
338         @./extra/config/conf -d extra/Configs/Config.in
339
340 clean:
341         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
342         @$(RM) -r tmp lib include/bits libc/tmp _install
343         $(RM) libc/obj.* headers
344         $(MAKE) -C test clean
345         $(MAKE) -C ldso clean
346         $(MAKE) -C libc/misc/internals clean
347         $(MAKE) -C libc/misc/wchar clean
348         $(MAKE) -C libc/unistd clean
349         $(MAKE) -C libc/sysdeps/linux/common clean
350         $(MAKE) -C extra/locale clean
351         $(MAKE) -C utils clean
352         @set -e; \
353         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
354                 $(RM) include/sys/$$i; \
355         done; \
356         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
357                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
358                         $(RM) include/sys/$$i; \
359                 done; \
360         fi;
361         @$(RM) include/linux include/asm*
362         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
363             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
364         fi;
365
366 distclean: clean
367         $(RM) .config .config.old .config.cmd
368         $(MAKE) -C extra clean
369
370 release: distclean
371         cd ..;                                  \
372         $(RM) -r uClibc-$(VERSION);             \
373         cp -dRf uClibc uClibc-$(VERSION);       \
374         find uClibc-$(VERSION)/ -type f         \
375             -name .\#* -exec $(RM) -r {} \; ;   \
376         find uClibc-$(VERSION)/ -type d         \
377             -name .svn -exec $(RM) -r {} \; ;   \
378                                                 \
379         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
380
381 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
382
383 check:
384         $(MAKE) -C test
385
386 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig