OSDN Git Service

Always build the utils. Always clean libc/misc, since there is
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000,2001,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 #There are a number of configurable options in "Config"
28 #
29 #--------------------------------------------------------
30
31 TOPDIR=./
32 include Rules.mak
33
34 DIRS = extra ldso libc libcrypt libresolv libutil libm libpthread
35
36 all: headers uClibc_config subdirs shared util finished
37
38 Config:
39         @echo
40         @echo "You didn't read the README, did you... =)"
41         @echo "Choose a configuration file in extras/Config/ and then run"
42         @echo "  ln -s ./extra/Configs/Config.<arch> ./Config"
43         @echo
44         @exit 1
45
46 shared:
47 ifeq ($(strip $(HAVE_SHARED)),true)
48         @$(MAKE) -C libc shared
49         @$(MAKE) -C ldso shared
50         @$(MAKE) -C libcrypt shared
51         @$(MAKE) -C libresolv shared
52         @$(MAKE) -C libutil shared
53         @$(MAKE) -C libm shared
54         @$(MAKE) -C libpthread shared
55 else
56         @echo
57         @echo Not building shared libraries...
58         @echo
59 endif
60
61 util:
62 ifeq ($(strip $(HAVE_SHARED)),true)
63         @$(MAKE) -C ldso utils
64 endif
65
66 finished: shared
67         @echo
68         @echo Finally finished compiling...
69         @echo
70
71 headers: dummy
72         @- find include -type l -exec rm -f {} \;
73         @if [ $(TARGET_ARCH) = "powerpc" ];then \
74             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
75         elif [ $(TARGET_ARCH) = "v850" ];then \
76             ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
77         elif [ $(TARGET_ARCH) = "mips" ];then \
78             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
79         elif [ $(TARGET_ARCH) = "mipsel" ];then \
80             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
81             cd $(PWD)/libc/sysdeps/linux; \
82             ln -fs mips mipsel; \
83             cd $(PWD)/ldso/ldso; \
84             ln -fs mips mipsel; \
85         elif [ $(TARGET_ARCH) = "h8300" ];then \
86             ln -fs $(KERNEL_SOURCE)/include/asm-h8300 include/asm; \
87         else \
88             if [ $(HAS_MMU) != "true" ]; then \
89                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
90                 else \
91                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
92                 fi; \
93         fi;
94         @if [ ! -f include/asm/unistd.h ] ; then \
95             set -e; \
96             echo " "; \
97             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
98             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
99             echo "correctly.  Please edit \`Config' and fix these settings."; \
100             echo " "; \
101             /bin/false; \
102         fi;
103         @if [ $(HAS_MMU) != "true" -a $(TARGET_ARCH) = "i386" ] ; then \
104             set -e; \
105             echo "WARNING: I bet your x86 system really has an MMU, right?"; \
106             echo "         malloc and friends won't work unless you fix \`Config'"; \
107             echo " "; \
108             sleep 10; \
109         fi;
110         @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
111         rm -rf include/bits
112         mkdir -p include/bits
113         @cd include/bits; \
114         set -e; \
115         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
116                 ln -fs $$i .; \
117         done; \
118         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
119                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
120                         ln -fs $$i .; \
121                 done; \
122         fi
123         @cd include/sys; \
124         set -e; \
125         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
126                 ln -fs $$i .; \
127         done; \
128         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
129                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
130                         ln -fs $$i .; \
131                 done; \
132         fi
133         @cd $(TOPDIR); \
134         set -x -e; \
135         rm -f include/bits/syscall.h; \
136         TOPDIR=$(TOPDIR) CC=$(CC) /bin/sh $(TOPDIR)/extra/scripts/gen_bits_syscall_h.sh > include/bits/syscall.h
137         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
138
139 uClibc_config: Makefile Config
140         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > include/bits/uClibc_config.h
141         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> include/bits/uClibc_config.h
142         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> include/bits/uClibc_config.h
143         @echo "#endif" >> include/bits/uClibc_config.h
144         @echo "#define linux 1" >> include/bits/uClibc_config.h 
145         @echo "#define __linux__ 1" >> include/bits/uClibc_config.h 
146         @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
147             echo "#define __UCLIBC_HAS_IPV6__ 1" >> include/bits/uClibc_config.h ; \
148         else \
149             echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
150         fi
151         @if [ "$(HAS_MMU)" = "true" ] ; then \
152             echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
153         else \
154             echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
155         fi
156         @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
157             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
158         else \
159             echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
160         fi
161         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
162             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> include/bits/uClibc_config.h ; \
163         else \
164             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> include/bits/uClibc_config.h ; \
165         fi
166         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
167             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
168             echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> include/bits/uClibc_config.h ; \
169         else \
170             echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
171         fi
172         @if [ "$(HAVE_ELF)" = "false" ] ; then \
173             echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
174         else \
175             echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
176         fi
177         @if [ "$(HAVE_SHARED)" = "false" ] ; then \
178             echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
179         else \
180             echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
181         fi
182         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
183             echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
184         else \
185             echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
186         fi
187         @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
188             echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
189         else \
190             echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
191         fi
192         @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
193             echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> include/bits/uClibc_config.h ; \
194         else \
195             echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> include/bits/uClibc_config.h ; \
196         fi
197         @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
198         @if [ "$(DOLFS)" = "true" ] ; then \
199             echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
200         else \
201             echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
202         fi
203         @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
204             echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
205         else \
206             echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
207         fi
208         @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
209             echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
210         else \
211             echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
212         fi
213         @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
214             echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
215         else \
216             echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
217         fi
218         @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
219             echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
220         else \
221             echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
222         fi
223
224 subdirs: $(patsubst %, _dir_%, $(DIRS))
225
226 $(patsubst %, _dir_%, $(DIRS)) : dummy
227         $(MAKE) -C $(patsubst _dir_%, %, $@)
228
229 tags:
230         ctags -R
231
232 install: install_dev install_runtime install_toolchain install_utils finished2
233
234
235 # Installs header files and development library links.
236 install_dev:
237         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
238         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
239         install -d $(PREFIX)$(DEVEL_PREFIX)/include
240         -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
241         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
242         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
243             chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
244         done;
245         -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
246         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
247 ifeq ($(strip $(HAVE_SHARED)),true)
248         -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
249 endif
250
251
252 # Installs run-time libraries and helper apps onto the host system
253 # allowing cross development.  If you want to deploy to a target 
254 # system, use the "install_target" target instead... 
255 install_runtime:
256 ifeq ($(strip $(HAVE_SHARED)),true)
257         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
258         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
259         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
260         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
261         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
262             set -x -e; \
263             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
264             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
265             ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
266                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
267         fi;
268 endif
269
270 install_toolchain:
271         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
272         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
273         install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
274         $(MAKE) -C extra/gcc-uClibc install
275
276 install_utils:
277 ifeq ($(strip $(HAVE_SHARED)),true)
278         @$(MAKE) -C ldso utils
279         install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
280         ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
281         # For now, don't bother with readelf since surely the host
282         # system has binutils, or we couldn't have gotten this far...
283         #install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
284         #ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
285         @if [ -x ldso/util/ldconfig ] ; then \
286             set -x -e; \
287             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
288             install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
289             ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
290         fi;
291 endif
292
293 # Installs run-time libraries and helper apps in preparation for
294 # deploying onto a target system, but installed below wherever
295 # $PREFIX is set to, allowing you to package up the result for
296 # deployment onto your target system.
297 install_target:
298 ifeq ($(strip $(HAVE_SHARED)),true)
299         install -d $(PREFIX)$(TARGET_PREFIX)/lib
300         install -d $(PREFIX)$(TARGET_PREFIX)/sbin
301         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
302         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib
303         cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
304         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
305             set -x -e; \
306             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib; \
307             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
308             ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
309                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
310         fi;
311 endif
312
313 install_target_utils:
314 ifeq ($(strip $(HAVE_SHARED)),true)
315         install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
316         install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
317         @if [ -x ldso/util/ldconfig.target ] ; then \
318             set -x -e; \
319             install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
320             install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
321         fi;
322 endif
323
324 finished2:
325         @echo
326         @echo Finished installing...
327         @echo
328
329
330 distclean clean:
331         @rm -rf tmp lib include/bits libc/tmp _install
332         - find include -type l -exec rm -f {} \;
333         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
334         $(MAKE) -C test clean
335         $(MAKE) -C ldso clean
336         $(MAKE) -C libc/misc clean
337         $(MAKE) -C libc/unistd clean
338         $(MAKE) -C libc/sysdeps/linux/common clean
339         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
340         $(MAKE) -C extra/gcc-uClibc clean
341         find . -name mipsel -exec rm -rf {} \;
342
343 dist release: distclean
344         cd ..;                                  \
345         rm -rf uClibc-$(VERSION);               \
346         cp -a uClibc uClibc-$(VERSION);         \
347         find uClibc-$(VERSION)/ -type d         \
348             -name CVS -exec rm -rf {} \; ;      \
349         find uClibc-$(VERSION)/ -type d         \
350             -name .\#* -exec rm -rf {} \; ;     \
351                                                 \
352         tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
353
354 .PHONY: dummy subdirs
355