OSDN Git Service

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