OSDN Git Service

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