OSDN Git Service

Be more carefull about erroring out of shell fragments. Try to
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000,2001 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.h subdirs shared done
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 copy it to ./Config"
42         @echo
43         @exit 1
44
45 shared:
46 ifeq ($(strip $(HAVE_SHARED)),true)
47         @$(MAKE) -C libc shared
48         @$(MAKE) -C ldso shared
49         @$(MAKE) -C libcrypt shared
50         @$(MAKE) -C libresolv 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 done: shared
61         @echo
62         @echo Finally finished compiling...
63         @echo
64
65 headers: dummy
66         @rm -f include/asm include/linux include/bits
67         @if [ $(TARGET_ARCH) = "powerpc" ];then \
68             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
69         elif [ $(TARGET_ARCH) = "v850" ];then \
70             ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
71         else \
72             if [ $(HAS_MMU) != "true" ]; then \
73                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
74                 else \
75                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
76                 fi; \
77         fi;
78         @if [ ! -f include/asm/unistd.h ] ; then \
79             set -e; \
80             echo " "; \
81             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
82             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
83             echo "correctly.  Please edit \`Config' and fix these settings."; \
84             echo " "; \
85             /bin/false; \
86         fi;
87         @if [ $(HAS_MMU) != "true" ]  && [ $(TARGET_ARCH) = "i386" ] ; then \
88             set -e; \
89             echo "WARNING: I bet your x86 system really has an MMU, right?"; \
90             echo "         malloc and friends won't work unless you fix \`Config'"; \
91             echo " "; \
92             sleep 10; \
93         fi;
94         @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
95         @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
96         (cd include/bits && ln -sf ../../../../../uClibc_config.h uClibc_config.h)
97         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
98
99 uClibc_config.h: Makefile Config
100         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
101         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
102         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
103         @echo "#endif" >> uClibc_config.h
104         @echo "#define linux 1" >> uClibc_config.h 
105         @echo "#define __linux__ 1" >> uClibc_config.h 
106         @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
107             echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
108         else \
109             echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
110         fi
111         @if [ "$(HAS_MMU)" = "true" ] ; then \
112             echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
113         else \
114             echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
115         fi
116         @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
117             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
118         else \
119             echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
120         fi
121         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
122             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
123         else \
124             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
125         fi
126         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
127             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
128             echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
129         else \
130             echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
131         fi
132         @if [ "$(HAVE_ELF)" = "false" ] ; then \
133             echo "#undef HAVE_ELF" >> uClibc_config.h ; \
134         else \
135             echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
136         fi
137         @if [ "$(HAVE_SHARED)" = "false" ] ; then \
138             echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
139         else \
140             echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
141         fi
142         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
143             echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
144         else \
145             echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
146         fi
147         @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
148             echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
149         else \
150             echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
151         fi
152         @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
153             echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
154         else \
155             echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
156         fi
157         @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> uClibc_config.h
158         @if [ "$(DOLFS)" = "true" ] ; then \
159             echo "#define __UCLIBC_HAVE_LFS__ 1" >> uClibc_config.h ; \
160         else \
161             echo "#undef __UCLIBC_HAVE_LFS__" >> uClibc_config.h ; \
162         fi
163
164 subdirs: $(patsubst %, _dir_%, $(DIRS))
165
166 $(patsubst %, _dir_%, $(DIRS)) : dummy
167         $(MAKE) -C $(patsubst _dir_%, %, $@)
168
169 tags:
170         ctags -R
171
172 install: install_dev install_runtime install_gcc
173
174
175 # Installs header files and development library links.
176 install_dev:
177         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
178         install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
179         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
180         install -d $(PREFIX)$(DEVEL_PREFIX)/include
181         tar -chO include | tar -xC $(PREFIX)$(DEVEL_PREFIX);
182         chmod 755 `find  $(PREFIX)$(DEVEL_PREFIX) -type d` 
183         chmod 644 `find  $(PREFIX)$(DEVEL_PREFIX)/include -name '*.h'` 
184         (NAME=`whoami`; chown -R $$NAME.$$NAME $(PREFIX)$(DEVEL_PREFIX))
185 ifeq ($(strip $(HAVE_SHARED)),true)
186         find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
187 endif
188
189
190 # Installs run-time libraries and helper apps onto the host system
191 # allowing cross development.  If you want to deploy to a target 
192 # system, use the "install_target" target instead... 
193 install_runtime:
194 ifeq ($(strip $(HAVE_SHARED)),true)
195         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
196         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
197         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
198         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
199         install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
200         install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
201         install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
202         ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
203         ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
204         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
205             set -x -e; \
206             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
207             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
208             ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
209                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
210         fi;
211         @if [ -x ldso/util/ldconfig ] ; then \
212             set -x -e; \
213             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
214             install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
215             ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
216         fi;
217 endif
218
219 install_gcc:
220         $(MAKE) -C extra/gcc-uClibc install
221
222
223 # Installs run-time libraries and helper apps in preparation for
224 # deploying onto a target system, but installed below wherever
225 # $PREFIX is set to, allowing you to package up the result for
226 # deployment onto your target system.
227 install_target:
228 ifeq ($(strip $(HAVE_SHARED)),true)
229         install -d $(PREFIX)$(TARGET_PREFIX)/lib
230         install -d $(PREFIX)$(TARGET_PREFIX)/sbin
231         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
232         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib
233         cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
234         install -m 755 ldso/util/ldd $(PREFIX)$(TARGET_PREFIX)/usr/bin
235         install -m 755 ldso/util/readelf $(PREFIX)$(TARGET_PREFIX)/usr/bin
236         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
237             set -x -e; \
238             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(TARGET_PREFIX)/lib; \
239             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
240             ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so \
241                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
242         fi;
243         @if [ -x ldso/util/ldconfig ] ; then \
244             set -x -e; \
245             install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
246             install -m 755 ldso/util/ldconfig $(PREFIX)$(TARGET_PREFIX)/sbin; \
247         fi;
248 endif
249
250 distclean clean:
251         @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
252         - find include -type l -exec rm -f {} \;
253         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
254         $(MAKE) -C test clean
255         $(MAKE) -C ldso clean
256         $(MAKE) -C libc/unistd clean
257         $(MAKE) -C libc/sysdeps/linux/common clean
258         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
259         $(MAKE) -C extra/gcc-uClibc clean
260
261 dist release: distclean
262         cd ..;                                  \
263         rm -rf uClibc-$(VERSION);               \
264         cp -a uClibc uClibc-$(VERSION);         \
265                                                 \
266         find uClibc-$(VERSION)/ -type d \
267                                  -name CVS      \
268                 -exec rm -rf {} \; ;            \
269                                                 \
270         tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
271
272 .PHONY: dummy subdirs
273