OSDN Git Service

Don't blow away existing files when trying to install a ldso symlink...
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000, 2001 by Lineo, inc.
4 # Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.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 #
20 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
21 # other sundry sources.  Files within this library are copyright by their
22 # respective copyright holders.
23
24 #--------------------------------------------------------
25 #
26 #There are a number of configurable options in "Config"
27 #
28 #--------------------------------------------------------
29
30 TOPDIR=./
31 include Rules.mak
32
33 DIRS = extra ldso libc libcrypt libresolv libutil libm  
34
35 all: headers uClibc_config.h subdirs shared done
36
37 Config:
38         @echo
39         @echo "You didn't read the README, did you... =)"
40         @echo "Choose a configuration file in extras/Config/ and copy it to ./Config."
41         @echo
42         @exit 1
43
44 shared:
45 ifeq ($(strip $(HAVE_SHARED)),true)
46         @$(MAKE) -C libc shared
47         @$(MAKE) -C ldso shared
48         @$(MAKE) -C libcrypt shared
49         @$(MAKE) -C libutil shared
50         @$(MAKE) -C libm shared
51         @$(MAKE) -C libresolv shared
52 else
53         @echo
54         @echo Not building shared libraries...
55         @echo
56 endif
57
58 done: shared
59         @echo
60         @echo Finally finished compiling...
61         @echo
62
63 headers: dummy
64         @rm -f include/asm include/linux include/bits
65         @if [ $(TARGET_ARCH) = "powerpc" ];then \
66             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
67         else \
68             if [ $(HAS_MMU) != "true" ]; then \
69                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
70                 else \
71                         ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
72                 fi; \
73         fi;
74         @if [ ! -f include/asm/unistd.h ] ; then \
75             echo " "; \
76             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
77             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
78             echo "correctly.  Please edit \`Config' and fix these settings."; \
79             echo " "; \
80             /bin/false; \
81         fi;
82         @if [ $(HAS_MMU) != "true" ]  && [ $(TARGET_ARCH) = "i386" ] ; then \
83             echo "WARNING: I bet your x86 system really has an MMU, right?"; \
84             echo "         malloc and friends won't work unless you fix \`Config'"; \
85             echo " "; \
86             sleep 10; \
87         fi;
88         @ln -fs $(KERNEL_SOURCE)/include/linux include/linux
89         @ln -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
90         (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
91         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
92
93 uClibc_config.h: Makefile Config
94         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
95         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
96         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
97         @echo "#endif" >> uClibc_config.h
98         @echo "#define linux 1" >> uClibc_config.h 
99         @echo "#define __linux__ 1" >> uClibc_config.h 
100         @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
101             echo "#define __UCLIBC_HAS_IPV6__ 1" >> uClibc_config.h ; \
102         else \
103             echo "#undef __UCLIBC_HAS_IPV6__" >> uClibc_config.h ; \
104         fi
105         @if [ "$(HAS_MMU)" = "true" ] ; then \
106             echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
107         else \
108             echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
109         fi
110         @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
111             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
112         else \
113             echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
114         fi
115         @if [ "$(HAS_LIBM_FLOAT)" = "true" ] ; then \
116             echo "#define __UCLIBC_HAS_LIBM_FLOAT__ 1" >> uClibc_config.h ; \
117         else \
118             echo "#undef __UCLIBC_HAS_LIBM_FLOAT__" >> uClibc_config.h ; \
119         fi
120         @if [ "$(HAS_LIBM_DOUBLE)" = "true" ] ; then \
121             echo "#define __UCLIBC_HAS_LIBM_DOUBLE__ 1" >> uClibc_config.h ; \
122         else \
123             echo "#undef __UCLIBC_HAS_LIBM_DOUBLE__" >> uClibc_config.h ; \
124         fi
125         @if [ "$(HAS_LIBM_LONG_DOUBLE)" = "true" ] ; then \
126             echo "#define __UCLIBC_HAS_LIBM_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
127         else \
128             echo "#undef __UCLIBC_HAS_LIBM_LONG_DOUBLE__" >> uClibc_config.h ; \
129         fi
130         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
131             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
132         else \
133             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
134         fi
135         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
136             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
137             echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
138         else \
139             echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
140         fi
141         @if [ "$(HAVE_ELF)" = "false" ] ; then \
142             echo "#undef HAVE_ELF" >> uClibc_config.h ; \
143         else \
144             echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
145         fi
146         @if [ "$(HAVE_SHARED)" = "false" ] ; then \
147             echo "#undef HAVE_SHARED" >> uClibc_config.h ; \
148         else \
149             echo "#define HAVE_SHARED 1" >> uClibc_config.h ; \
150         fi
151         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
152             echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
153         else \
154             echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
155         fi
156         @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
157             echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
158         else \
159             echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
160         fi
161         @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
162             echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> uClibc_config.h ; \
163         else \
164             echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> uClibc_config.h ; \
165         fi
166
167 subdirs: $(patsubst %, _dir_%, $(DIRS))
168
169 $(patsubst %, _dir_%, $(DIRS)) : dummy
170         $(MAKE) -C $(patsubst _dir_%, %, $@)
171
172 tags:
173         ctags -R
174
175 install: install_dev install_runtime install_gcc
176
177
178 # Installs header files and development library links.
179 install_dev:
180         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
181         install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
182         install -d $(PREFIX)$(DEVEL_PREFIX)/include
183         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
184         find include/ -name '*.h' -depth -follow -exec install \
185             -D -m 644 {} $(PREFIX)$(DEVEL_PREFIX)/'{}' ';'
186 ifeq ($(strip $(HAVE_SHARED)),true)
187         find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
188 endif
189
190
191 # Installs run-time libraries and helper apps onto the host system
192 # allowing cross development.  If you want to deploy to a target 
193 # system, use the "install_target" target instead... 
194 install_runtime:
195 ifeq ($(strip $(HAVE_SHARED)),true)
196         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
197         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
198         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib
199         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
200         install -m 755 ldso/util/ldd $(PREFIX)$(DEVEL_PREFIX)/bin
201         install -m 755 ldso/util/readelf $(PREFIX)$(DEVEL_PREFIX)/bin
202         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
203         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/bin
204         ln -fs $(DEVEL_PREFIX)/bin/ldd $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/usr/bin/$(TARGET_ARCH)-uclibc-ldd
205         ln -fs $(DEVEL_PREFIX)/bin/readelf $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/usr/bin/$(TARGET_ARCH)-uclibc-readelf
206         if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
207             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)$(DEVEL_PREFIX)/lib; \
208             ln -s $(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) \
209                         $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so || true; \
210         fi;
211         if [ -x ldso/util/ldconfig ] ; then \
212             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
213             install -m 755 ldso/util/ldconfig $(PREFIX)$(DEVEL_PREFIX)/bin; \
214             ln -fs $(DEVEL_PREFIX)/sbin/ldconfig $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/usr/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
215         fi;
216 endif
217
218 install_gcc:
219         $(MAKE) -C extra/gcc-uClibc install
220
221
222 # Installs run-time libraries and helper apps in preparation for
223 # deploying onto a target system, but installed below wherever
224 # $PREFIX is set to, allowing you to package up the result for
225 # deployment onto your target system.
226 install_target:
227 ifeq ($(strip $(HAVE_SHARED)),true)
228         install -d $(PREFIX)/lib
229         install -d $(PREFIX)/sbin
230         install -d $(PREFIX)/usr/bin
231         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)/lib
232         cp -a lib/*.so.* $(PREFIX)/lib
233         install -m 755 ldso/util/ldd $(PREFIX)/usr/bin
234         install -m 755 ldso/util/readelf $(PREFIX)/usr/bin
235         if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so ] ; then \
236             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so $(PREFIX)/lib; \
237             ln -s $(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) \
238                         $(PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so || true; \
239         fi;
240         if [ -x ldso/util/ldconfig ] ; then \
241             install -d $(PREFIX)/etc; \
242             install -m 755 ldso/util/ldconfig $(PREFIX)/sbin; \
243         fi;
244 endif
245
246 clean:
247         @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
248         - find include -type l -exec rm -f {} \;
249         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
250         $(MAKE) -C ldso clean
251         $(MAKE) -C libc/unistd clean
252         $(MAKE) -C libc/sysdeps/linux/common clean
253         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean
254         $(MAKE) -C extra/gcc-uClibc clean
255
256 .PHONY: dummy subdirs
257