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