OSDN Git Service

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