OSDN Git Service

Ok... here's the summary:
[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 libutil libm libpthread
36
37 ifdef include_config
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 libutil shared
51         @$(MAKE) -C libm shared
52         @$(MAKE) -C libpthread shared
53 else
54         @echo
55         @echo Not building shared libraries...
56         @echo
57 endif
58
59 finished: shared
60         @echo
61         @echo Finally finished compiling...
62         @echo
63
64 #
65 # Target for uClinux distro
66 #
67 romfs:
68 ifeq ($(strip $(HAVE_SHARED)),y)
69         install -d $(ROMFSDIR)/lib
70         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
71                 $(ROMFSDIR)/lib
72         cp -a lib/*.so.* $(ROMFSDIR)/lib
73         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
74             set -x -e; \
75             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
76                         $(ROMFSDIR)/lib; \
77         fi;
78 endif
79
80 include/bits/uClibc_config.h: .config
81         @if [ ! -x ./extra/config/conf ] ; then \
82             make -C extra/config; \
83         fi;
84         rm -rf include/bits
85         mkdir -p include/bits
86         @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
87
88 headers: include/bits/uClibc_config.h
89         rm -f include/asm;
90         @if [ "$(TARGET_ARCH)" = "powerpc" ];then \
91             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
92         elif [ "$(TARGET_ARCH)" = "mips" ];then \
93             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
94         elif [ "$(TARGET_ARCH)" = "mipsel" ];then \
95             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
96             cd $(shell pwd)/libc/sysdeps/linux; \
97             ln -fs mips mipsel; \
98             cd $(shell pwd)/ldso/ldso; \
99             ln -fs mips mipsel; \
100             cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
101             ln -fs mips mipsel; \
102         elif [ "$(TARGET_ARCH)" = "cris" ];then \
103                 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
104         else \
105             if [ "$(UCLIBC_HAS_MMU)" != "y" ]; then \
106                 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
107                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
108                 else \
109                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
110                 fi; \
111             else \
112                 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
113             fi; \
114         fi;
115         @if [ ! -f include/asm/unistd.h ] ; then \
116             set -e; \
117             echo " "; \
118             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
119             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or UCLIBC_HAS_MMU"; \
120             echo "correctly when you configured uClibc.  Please fix these settings."; \
121             echo " "; \
122             false; \
123         fi;
124         rm -f include/linux include/scsi
125         ln -fs $(KERNEL_SOURCE)/include/linux include/linux
126         ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
127         @cd include/bits; \
128         set -e; \
129         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
130                 ln -fs $$i .; \
131         done; \
132         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
133                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
134                         ln -fs $$i .; \
135                 done; \
136         fi
137         @cd include/sys; \
138         set -e; \
139         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
140                 ln -fs $$i .; \
141         done; \
142         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
143                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
144                         ln -fs $$i .; \
145                 done; \
146         fi
147         @cd $(TOPDIR); \
148         set -x -e; \
149         rm -f include/bits/sysnum.h; \
150         TOPDIR=. CC=$(CC) /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h
151         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
152
153 subdirs: $(patsubst %, _dir_%, $(DIRS))
154
155 $(patsubst %, _dir_%, $(DIRS)) : dummy
156         $(MAKE) -C $(patsubst _dir_%, %, $@)
157
158 tags:
159         ctags -R
160
161 install: install_dev install_runtime install_toolchain install_utils finished2
162
163
164 # Installs header files and development library links.
165 install_dev:
166         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
167         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
168         install -d $(PREFIX)$(DEVEL_PREFIX)/include
169         -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
170         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
171         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
172             chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
173         done;
174         -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
175         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
176 ifeq ($(strip $(HAVE_SHARED)),y)
177         -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
178         # If we build shared libraries then the static libs are PIC...
179         # Make _pic.a symlinks to make mklibs.py and similar tools happy.
180         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
181                 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
182         done
183 endif
184
185
186 # Installs run-time libraries and helper apps onto the host system
187 # allowing cross development.  If you want to deploy to a target 
188 # system, use the "install_target" target instead... 
189 install_runtime:
190 ifeq ($(strip $(HAVE_SHARED)),y)
191         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
192         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
193         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
194                 $(PREFIX)$(DEVEL_PREFIX)/lib
195         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
196         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
197             set -x -e; \
198             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
199                         $(PREFIX)$(DEVEL_PREFIX)/lib; \
200             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
201             ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
202                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
203         fi;
204 endif
205
206 install_toolchain:
207         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
208         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
209         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
210         install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
211         $(MAKE) -C extra/gcc-uClibc install
212
213 ifeq ($(strip $(HAVE_SHARED)),y)
214 utils: $(TOPDIR)ldso/util/ldd
215         $(MAKE) -C ldso utils
216 else
217 utils: dummy
218 endif
219
220 install_utils: utils
221 ifeq ($(strip $(HAVE_SHARED)),y)
222         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
223         install -m 755 ldso/util/ldd \
224                 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
225         ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
226                 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
227         # For now, don't bother with readelf since surely the host
228         # system has binutils, or we couldn't have gotten this far...
229         #install -m 755 ldso/util/readelf \
230         #       $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
231         #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
232         #       $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
233         @if [ -x ldso/util/ldconfig ] ; then \
234             set -x -e; \
235             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
236             install -m 755 ldso/util/ldconfig \
237                     $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
238             ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
239                     $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
240         fi;
241 endif
242
243 # Installs run-time libraries and helper apps in preparation for
244 # deploying onto a target system, but installed below wherever
245 # $PREFIX is set to, allowing you to package up the result for
246 # deployment onto your target system.
247 install_target:
248 ifeq ($(strip $(HAVE_SHARED)),y)
249         install -d $(PREFIX)$(TARGET_PREFIX)/lib
250         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
251         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
252                 $(PREFIX)$(TARGET_PREFIX)/lib
253         cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
254         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
255             set -x -e; \
256             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
257                         $(PREFIX)$(TARGET_PREFIX)/lib; \
258             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
259             ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
260                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
261         fi;
262 endif
263
264 install_target_utils:
265 ifeq ($(strip $(HAVE_SHARED)),y)
266         @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
267         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
268         install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
269         install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
270         @if [ -x ldso/util/ldconfig.target ] ; then \
271             set -x -e; \
272             install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
273             install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
274             install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
275         fi;
276 endif
277 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
278         @$(MAKE) -C libc/misc/wchar iconv.target
279         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
280         install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
281 endif
282
283 finished2:
284         @echo
285         @echo Finished installing...
286         @echo
287
288 else # ifdef include_config
289
290 all: menuconfig
291
292 ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
293 # Targets which don't need .config
294
295 # configuration
296 # ---------------------------------------------------------------------------
297
298 extra/config/conf extra/config/mconf:
299         make -C extra/config
300         -@if [ ! -f .config ] ; then \
301                 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
302         fi
303
304 menuconfig: extra/config/mconf
305         make -C extra/config/lxdialog
306         rm -rf include/bits
307         mkdir -p include/bits
308         @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
309
310 config: extra/config/conf
311         rm -rf include/bits
312         mkdir -p include/bits
313         @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
314
315 oldconfig: extra/config/conf
316         rm -rf include/bits
317         mkdir -p include/bits
318         @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
319
320 randconfig: extra/config/conf
321         rm -rf include/bits
322         mkdir -p include/bits
323         @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
324
325 allyesconfig: extra/config/conf
326         rm -rf include/bits
327         mkdir -p include/bits
328         @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
329
330 allnoconfig: extra/config/conf
331         rm -rf include/bits
332         mkdir -p include/bits
333         @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
334
335 defconfig: extra/config/conf
336         rm -rf include/bits
337         mkdir -p include/bits
338         @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
339
340
341 clean:
342         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
343         @rm -rf tmp lib include/bits libc/tmp _install
344         $(MAKE) -C test clean
345         $(MAKE) -C ldso clean
346         $(MAKE) -C libc/misc/internals clean
347         $(MAKE) -C libc/misc/wchar clean
348         $(MAKE) -C libc/unistd clean
349         $(MAKE) -C libc/sysdeps/linux/common clean
350         $(MAKE) -C extra clean
351         @set -e; \
352         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
353                 rm -f include/sys/$$i; \
354         done; \
355         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
356                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
357                         rm -f include/sys/$$i; \
358                 done; \
359         fi;
360         @rm -f include/linux include/scsi include/asm
361         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
362             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
363         fi;
364         @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
365             $(MAKE) -C libc/sysdeps/linux/mips clean; \
366             rm -f ldso/ldso/mipsel; \
367             rm -f libc/sysdeps/linux/mipsel; \
368             rm -f libpthread/linuxthreads/sysdeps/mipsel; \
369         fi;
370
371 distclean: clean
372         rm -f .config .config.old .config.cmd
373
374 release: distclean
375         cd ..;                                  \
376         rm -rf uClibc-$(VERSION);               \
377         cp -a uClibc uClibc-$(VERSION);         \
378         find uClibc-$(VERSION)/ -type d         \
379             -name .\#* -exec rm -rf {} \; ;     \
380                                                 \
381         tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
382
383 endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
384 endif # ifdef include_config
385
386 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig
387
388