OSDN Git Service

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