OSDN Git Service

Use HOSTCC for seting up the syscall list
[uclinux-h8/uClibc.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         @echo
46         @echo Building shared libraries ...
47         @echo
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         @echo
62         @echo Not building shared libraries ...
63         @echo
64 endif
65
66 finished: shared
67         @echo
68         @echo Finally finished compiling ...
69         @echo
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 headers: include/bits/uClibc_config.h
80 ifeq ($(strip $(ARCH_HAS_MMU)),y)
81         @set -x; ./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH)
82 else
83         @set -x; ./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) -n
84 endif
85         @cd include/bits; \
86         set -e; \
87         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
88                 $(LN) -fs $$i .; \
89         done; \
90         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
91                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
92                         $(LN) -fs $$i .; \
93                 done; \
94         fi
95         @cd include/sys; \
96         set -e; \
97         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
98                 $(LN) -fs $$i .; \
99         done; \
100         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
101                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
102                         $(LN) -fs $$i .; \
103                 done; \
104         fi
105         @cd $(TOPDIR); \
106         set -x -e; \
107         TOPDIR=. CC="$(HOSTCC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
108         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
109                 $(RM) include/bits/sysnum.h.new; \
110         else \
111                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
112         fi
113         $(MAKE) -C libc/sysdeps/linux/common headers
114         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
115         touch headers
116
117 # Command used to download source code
118 WGET:=wget --passive-ftp
119
120 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
121
122 pregen: headers
123 ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
124         (cd extra/locale; \
125         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
126         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
127         fi );
128 endif
129 ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
130         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
131         $(MAKE) -C extra/locale pregen
132 endif
133
134
135 subdirs: $(patsubst %, _dir_%, $(DIRS))
136 $(patsubst %, _dir_%, $(DIRS)): headers
137         $(MAKE) -C $(patsubst _dir_%, %, $@)
138
139 tags:
140         ctags -R
141
142 install: install_runtime install_dev finished2
143
144
145 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
146
147 # Installs header files and development library links.
148 install_dev:
149         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
150         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
151         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
152         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
153 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
154         # Remove floating point related headers since float support is disabled.
155         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
156         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
157         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
158         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
160 endif
161 ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
162         # Remove wide char headers since wide char support is disabled.
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
164         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
165 endif
166 ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
167         # Remove iconv header since locale support is disabled.
168         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
169 endif
170 ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
171         # Remove printf header since custom print specifier support is disabled.
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
173 endif
174 ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
175         # Remove xlocale header since extended locale support is disabled.
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
177 endif
178 ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
179         # Remove libintl header since gettext support is disabled.
180         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
181 endif
182 ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
183         # Remove regex headers since regex support is disabled.
184         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
185         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
186 endif
187 ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
188         # Remove wordexp header since wordexp support is disabled.
189         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
190 endif
191 ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
192         # Remove ftw header since ftw support is disabled.
193         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
194 endif
195 ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
196         # Remove glob header since glob support is disabled.
197         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
198 endif
199 ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
200         # Remove getopt header since gnu getopt support is disabled.
201         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
202 endif
203 ifneq ($(strip $(HAS_SHADOW)),y)
204         # Remove getopt header since shadow password support is disabled.
205         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
206 endif
207         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
208             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
209         done;
210         -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs $(RM) -r;
211         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
212 ifeq ($(strip $(HAVE_SHARED)),y)
213         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
214         sed -e 's/lib\///'` ; do \
215                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
216                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
217         done;
218 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
219         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
220                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
221 endif
222 #       # If we build shared libraries then the static libs are PIC...
223 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
224         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
225                 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
226                         | sed -e 's/\.a$$/_pic.a/'`; \
227         done;
228 endif
229
230
231 # Installs run-time libraries
232 install_runtime:
233 ifeq ($(strip $(HAVE_SHARED)),y)
234         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
235         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
236                 $(PREFIX)$(RUNTIME_PREFIX)lib
237         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
238         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
239             set -x -e; \
240             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
241                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
242         fi;
243 endif
244
245 .PHONY: utils
246 ifeq ($(strip $(HAVE_SHARED)),y)
247 utils:
248         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
249 else
250 utils: dummy
251 endif
252
253 # Installs helper applications, such as 'ldd' and 'ldconfig'
254 install_utils: utils
255         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
256 #ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
257 #       @$(MAKE) -C libc/misc/wchar iconv.target
258 #       $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
259 #       $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
260 #endif
261
262 finished2:
263         @echo
264         @echo Finished installing ...
265         @echo
266
267 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
268
269 all: menuconfig
270
271 # configuration
272 # ---------------------------------------------------------------------------
273 extra/config/conf:
274         $(MAKE) -C extra/config conf
275
276 extra/config/mconf:
277         $(MAKE) -C extra/config ncurses mconf
278
279 menuconfig: extra/config/mconf
280         $(RM) -r include/bits
281         $(INSTALL) -d include/bits
282         @./extra/config/mconf extra/Configs/Config.in
283
284 config: extra/config/conf
285         $(RM) -r include/bits
286         $(INSTALL) -d include/bits
287         @./extra/config/conf extra/Configs/Config.in
288
289 oldconfig: extra/config/conf
290         $(RM) -r include/bits
291         $(INSTALL) -d include/bits
292         @./extra/config/conf -o extra/Configs/Config.in
293
294 randconfig: extra/config/conf
295         $(RM) -r include/bits
296         $(INSTALL) -d include/bits
297         @./extra/config/conf -r extra/Configs/Config.in
298
299 allyesconfig: extra/config/conf
300         $(RM) -r include/bits
301         $(INSTALL) -d include/bits
302         @./extra/config/conf -y extra/Configs/Config.in
303         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
304         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
305         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
306         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
307         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
308         @./extra/config/conf -o extra/Configs/Config.in
309
310 allnoconfig: extra/config/conf
311         $(RM) -r include/bits
312         $(INSTALL) -d include/bits
313         @./extra/config/conf -n extra/Configs/Config.in
314
315 defconfig: extra/config/conf
316         $(RM) -r include/bits
317         $(INSTALL) -d include/bits
318         @./extra/config/conf -d extra/Configs/Config.in
319
320
321 clean:
322         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
323         @$(RM) -r tmp lib include/bits libc/tmp _install
324         $(RM) libc/obj.* headers
325         $(MAKE) -C test clean
326         $(MAKE) -C ldso clean
327         $(MAKE) -C libc/misc/internals clean
328         $(MAKE) -C libc/misc/wchar clean
329         $(MAKE) -C libc/unistd clean
330         $(MAKE) -C libc/sysdeps/linux/common clean
331         $(MAKE) -C extra/locale clean
332         @set -e; \
333         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
334                 $(RM) include/sys/$$i; \
335         done; \
336         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
337                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
338                         $(RM) include/sys/$$i; \
339                 done; \
340         fi;
341         @$(RM) include/linux include/asm*
342         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
343             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
344         fi;
345
346 distclean: clean
347         $(RM) .config .config.old .config.cmd
348         $(MAKE) -C extra clean
349
350 release: distclean
351         cd ..;                                  \
352         $(RM) -r uClibc-$(VERSION);             \
353         cp -dRf uClibc uClibc-$(VERSION);       \
354         find uClibc-$(VERSION)/ -type f         \
355             -name .\#* -exec $(RM) -r {} \; ;   \
356         find uClibc-$(VERSION)/ -type d         \
357             -name CVS  -exec $(RM) -r {} \; ;   \
358                                                 \
359         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
360
361 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
362
363 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig