OSDN Git Service

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