OSDN Git Service

Stupid typo
[uclinux-h8/uclibc-ng.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
5 #
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Library General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option) any
9 # later version.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Library General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Makefile for uClibc
20 #
21 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
22 # other sundry sources.  Files within this library are copyright by their
23 # respective copyright holders.
24
25
26 #--------------------------------------------------------------
27 # You shouldn't need to mess with anything beyond this point...
28 #--------------------------------------------------------------
29 noconfig_targets := menuconfig config oldconfig randconfig \
30         defconfig allyesconfig allnoconfig clean distclean \
31         release tags TAGS
32 TOPDIR=./
33 include Rules.mak
34
35 DIRS = extra ldso libc libcrypt libresolv libnsl libutil libm libpthread
36
37 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
38
39 all: headers subdirs shared utils finished
40
41 # In this section, we need .config
42 -include .config.cmd
43
44 shared:
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 else
55         @echo
56         @echo Not building shared libraries...
57         @echo
58 endif
59
60 finished: shared
61         @echo
62         @echo Finally finished compiling...
63         @echo
64
65 #
66 # Target for uClinux distro
67 #
68 romfs:
69 ifeq ($(strip $(HAVE_SHARED)),y)
70         install -d $(ROMFSDIR)/lib
71         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
72                 $(ROMFSDIR)/lib
73         cp -a lib/*.so.* $(ROMFSDIR)/lib
74         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
75             set -x -e; \
76             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
77                         $(ROMFSDIR)/lib; \
78         fi;
79 endif
80
81 include/bits/uClibc_config.h: .config
82         @if [ ! -x ./extra/config/conf ] ; then \
83             make -C extra/config conf; \
84         fi;
85         rm -rf include/bits
86         mkdir -p include/bits
87         @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
88
89 headers: include/bits/uClibc_config.h
90         rm -f include/asm;
91         @if [ "$(TARGET_ARCH)" = "powerpc" ];then \
92             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
93         elif [ "$(TARGET_ARCH)" = "mips" ];then \
94             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
95         elif [ "$(TARGET_ARCH)" = "mipsel" ];then \
96             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
97             cd $(shell pwd)/libc/sysdeps/linux; \
98             ln -fs mips mipsel; \
99             cd $(shell pwd)/ldso/ldso; \
100             ln -fs mips mipsel; \
101             cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
102             ln -fs mips mipsel; \
103         elif [ "$(TARGET_ARCH)" = "cris" ];then \
104                 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
105         else \
106             if [ "$(UCLIBC_HAS_MMU)" != "y" ]; then \
107                 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
108                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
109                 else \
110                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
111                 fi; \
112             else \
113                 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
114             fi; \
115         fi;
116         @if [ ! -f include/asm/unistd.h ] ; then \
117             set -e; \
118             echo " "; \
119             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
120             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or UCLIBC_HAS_MMU"; \
121             echo "correctly when you configured uClibc.  Please fix these settings."; \
122             echo " "; \
123             false; \
124         fi;
125         rm -f include/linux include/scsi
126         ln -fs $(KERNEL_SOURCE)/include/linux include/linux
127         ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
128         @cd include/bits; \
129         set -e; \
130         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
131                 ln -fs $$i .; \
132         done; \
133         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
134                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
135                         ln -fs $$i .; \
136                 done; \
137         fi
138         @cd include/sys; \
139         set -e; \
140         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
141                 ln -fs $$i .; \
142         done; \
143         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
144                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
145                         ln -fs $$i .; \
146                 done; \
147         fi
148         @cd $(TOPDIR); \
149         set -x -e; \
150         rm -f include/bits/sysnum.h; \
151         TOPDIR=. CC=$(CC) /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h
152         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
153
154 subdirs: $(patsubst %, _dir_%, $(DIRS))
155
156 $(patsubst %, _dir_%, $(DIRS)) : dummy
157         $(MAKE) -C $(patsubst _dir_%, %, $@)
158
159 tags:
160         ctags -R
161
162 install: install_dev install_runtime install_toolchain install_utils finished2
163
164
165 # Installs header files and development library links.
166 install_dev:
167         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
168         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
169         install -d $(PREFIX)$(DEVEL_PREFIX)/include
170         -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
171         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
172         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
173             chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
174         done;
175         -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
176         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
177 ifeq ($(strip $(HAVE_SHARED)),y)
178         -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
179         # If we build shared libraries then the static libs are PIC...
180         # Make _pic.a symlinks to make mklibs.py and similar tools happy.
181         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
182                 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
183         done
184 endif
185
186
187 # Installs run-time libraries and helper apps onto the host system
188 # allowing cross development.  If you want to deploy to a target 
189 # system, use the "install_target" target instead... 
190 install_runtime:
191 ifeq ($(strip $(HAVE_SHARED)),y)
192         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
193         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
194         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
195                 $(PREFIX)$(DEVEL_PREFIX)/lib
196         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
197         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
198             set -x -e; \
199             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
200                         $(PREFIX)$(DEVEL_PREFIX)/lib; \
201         fi;
202         #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
203         #    install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
204         #    ln -sf $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
205         #               $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
206         #fi;
207 endif
208
209 install_toolchain:
210         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
211         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
212         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
213         install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
214         $(MAKE) -C extra/gcc-uClibc install
215
216 ifeq ($(strip $(HAVE_SHARED)),y)
217 utils: $(TOPDIR)ldso/util/ldd
218         $(MAKE) -C ldso utils
219 else
220 utils: dummy
221 endif
222
223 install_utils: utils
224 ifeq ($(strip $(HAVE_SHARED)),y)
225         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
226         install -m 755 ldso/util/ldd \
227                 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
228         ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
229                 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
230         # For now, don't bother with readelf since surely the host
231         # system has binutils, or we couldn't have gotten this far...
232         #install -m 755 ldso/util/readelf \
233         #       $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
234         #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
235         #       $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
236         @if [ -x ldso/util/ldconfig ] ; then \
237             set -x -e; \
238             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
239             install -m 755 ldso/util/ldconfig \
240                     $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
241             ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
242                     $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
243         fi;
244 endif
245
246 # Installs run-time libraries and helper apps in preparation for
247 # deploying onto a target system, but installed below wherever
248 # $PREFIX is set to, allowing you to package up the result for
249 # deployment onto your target system.
250 install_target:
251 ifeq ($(strip $(HAVE_SHARED)),y)
252         install -d $(PREFIX)$(TARGET_PREFIX)/lib
253         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
254         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
255                 $(PREFIX)$(TARGET_PREFIX)/lib
256         cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
257         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
258             set -x -e; \
259             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
260                         $(PREFIX)$(TARGET_PREFIX)/lib; \
261         fi;
262         #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
263         #    install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
264         #    ln -sf $(PREFIX)$(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
265         #               $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
266         #fi;
267 endif
268
269 install_target_utils:
270 ifeq ($(strip $(HAVE_SHARED)),y)
271         @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
272         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
273         install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
274         install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
275         @if [ -x ldso/util/ldconfig.target ] ; then \
276             set -x -e; \
277             install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
278             install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
279             install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
280         fi;
281 endif
282 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
283         @$(MAKE) -C libc/misc/wchar iconv.target
284         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
285         install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
286 endif
287
288 finished2:
289         @echo
290         @echo Finished installing...
291         @echo
292
293 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
294
295 all: menuconfig
296
297 # configuration
298 # ---------------------------------------------------------------------------
299
300 extra/config/conf:
301         make -C extra/config conf
302         -@if [ ! -f .config ] ; then \
303                 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
304         fi
305
306 extra/config/mconf:
307         make -C extra/config ncurses conf mconf
308         -@if [ ! -f .config ] ; then \
309                 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
310         fi
311
312 menuconfig: extra/config/mconf
313         rm -rf include/bits
314         mkdir -p include/bits
315         @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
316
317 config: extra/config/conf
318         rm -rf include/bits
319         mkdir -p include/bits
320         @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
321
322 oldconfig: extra/config/conf
323         rm -rf include/bits
324         mkdir -p include/bits
325         @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
326
327 randconfig: extra/config/conf
328         rm -rf include/bits
329         mkdir -p include/bits
330         @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
331
332 allyesconfig: extra/config/conf
333         rm -rf include/bits
334         mkdir -p include/bits
335         @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
336
337 allnoconfig: extra/config/conf
338         rm -rf include/bits
339         mkdir -p include/bits
340         @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
341
342 defconfig: extra/config/conf
343         rm -rf include/bits
344         mkdir -p include/bits
345         @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
346
347
348 clean:
349         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
350         @rm -rf tmp lib include/bits libc/tmp _install
351         $(MAKE) -C test clean
352         $(MAKE) -C ldso clean
353         $(MAKE) -C libc/misc/internals clean
354         $(MAKE) -C libc/misc/wchar clean
355         $(MAKE) -C libc/unistd clean
356         $(MAKE) -C libc/sysdeps/linux/common clean
357         $(MAKE) -C extra/gcc-uClibc clean
358         $(MAKE) -C extra/locale clean
359         @set -e; \
360         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
361                 rm -f include/sys/$$i; \
362         done; \
363         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
364                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
365                         rm -f include/sys/$$i; \
366                 done; \
367         fi;
368         @rm -f include/linux include/scsi include/asm
369         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
370             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
371         fi;
372         @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
373             $(MAKE) -C libc/sysdeps/linux/mips clean; \
374             rm -f ldso/ldso/mipsel; \
375             rm -f libc/sysdeps/linux/mipsel; \
376             rm -f libpthread/linuxthreads/sysdeps/mipsel; \
377         fi;
378
379 distclean: clean
380         rm -f .config .config.old .config.cmd
381         $(MAKE) -C extra clean
382
383 release: distclean
384         cd ..;                                  \
385         rm -rf uClibc-$(VERSION);               \
386         cp -a uClibc uClibc-$(VERSION);         \
387         find uClibc-$(VERSION)/ -type d         \
388             -name .\#* -exec rm -rf {} \; ;     \
389                                                 \
390         tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
391
392 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
393
394 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig
395
396