OSDN Git Service

(headers): Remove special case for v850, now that the general case
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-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 subdirs shared utils 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 #
67 # dummy target for uClinux distro
68 #
69 romfs:
70
71 headers: dummy
72         rm -f include/asm;
73         @if [ $(TARGET_ARCH) = "powerpc" ];then \
74             ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
75         elif [ $(TARGET_ARCH) = "mips" ];then \
76             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
77         elif [ $(TARGET_ARCH) = "mipsel" ];then \
78             ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
79             cd $(shell pwd)/libc/sysdeps/linux; \
80             ln -fs mips mipsel; \
81             cd $(shell pwd)/ldso/ldso; \
82             ln -fs mips mipsel; \
83             cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
84             ln -fs mips mipsel; \
85         elif [ $(TARGET_ARCH) = "h8300" ];then \
86             ln -fs $(KERNEL_SOURCE)/include/asm-h8300 include/asm; \
87         else \
88             if [ $(HAS_MMU) != "true" ]; then \
89                 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
90                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
91                 else \
92                     ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
93                 fi; \
94             else \
95                 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
96             fi; \
97         fi;
98         @if [ ! -f include/asm/unistd.h ] ; then \
99             set -e; \
100             echo " "; \
101             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
102             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
103             echo "correctly.  Please edit \`Config' and fix these settings."; \
104             echo " "; \
105             /bin/false; \
106         fi;
107         rm -f include/linux include/scsi
108         ln -fs $(KERNEL_SOURCE)/include/linux include/linux
109         ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
110         rm -rf include/bits
111         mkdir -p include/bits
112         @cd include/bits; \
113         set -e; \
114         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
115                 ln -fs $$i .; \
116         done; \
117         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
118                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
119                         ln -fs $$i .; \
120                 done; \
121         fi
122         @cd include/sys; \
123         set -e; \
124         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
125                 ln -fs $$i .; \
126         done; \
127         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
128                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
129                         ln -fs $$i .; \
130                 done; \
131         fi
132         @cd $(TOPDIR); \
133         set -x -e; \
134         rm -f include/bits/syscall.h; \
135         TOPDIR=$(TOPDIR) CC=$(CC) /bin/sh $(TOPDIR)/extra/scripts/gen_bits_syscall_h.sh > include/bits/syscall.h
136         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
137
138 uClibc_config: Makefile Config
139         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > include/bits/uClibc_config.h
140         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> include/bits/uClibc_config.h
141         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> include/bits/uClibc_config.h
142         @echo "#endif" >> include/bits/uClibc_config.h
143         @echo "#define __UCLIBC_MAJOR__ $(MAJOR_VERSION)" >> include/bits/uClibc_config.h 
144         @echo "#define __UCLIBC_MINOR__ $(MINOR_VERSION)" >> include/bits/uClibc_config.h 
145         @echo "#define __UCLIBC_SUBLEVEL__ $(SUBLEVEL)" >> include/bits/uClibc_config.h 
146         @echo "#define linux 1" >> include/bits/uClibc_config.h 
147         @echo "#define __linux__ 1" >> include/bits/uClibc_config.h 
148         @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
149             echo "#define __UCLIBC_HAS_IPV6__ 1" >> include/bits/uClibc_config.h ; \
150         else \
151             echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
152         fi
153         @if [ "$(HAS_MMU)" = "true" ] ; then \
154             echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
155         else \
156             echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
157         fi
158         @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
159             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
160         else \
161             echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
162         fi
163         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
164             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> include/bits/uClibc_config.h ; \
165         else \
166             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> include/bits/uClibc_config.h ; \
167         fi
168         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
169             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
170         else \
171             echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
172         fi
173         @if [ "$(HAS_WCHAR)" = "true" ] ; then \
174             echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
175         else \
176             echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
177         fi
178         @if [ "$(HAVE_ELF)" = "false" ] ; then \
179             echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
180         else \
181             echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
182         fi
183         @if [ "$(HAVE_SHARED)" = "false" ] ; then \
184             echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
185         else \
186             echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
187         fi
188         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
189             echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
190         else \
191             echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
192         fi
193         @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
194             echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
195         else \
196             echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
197         fi
198         @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
199         @if [ "$(DOLFS)" = "true" ] ; then \
200             echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
201         else \
202             echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
203         fi
204         @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
205             echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
206         else \
207             echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
208         fi
209         @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
210             echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
211         else \
212             echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
213         fi
214         @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
215             echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
216         else \
217             echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
218         fi
219         @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
220             echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
221         else \
222             echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
223         fi
224
225 subdirs: $(patsubst %, _dir_%, $(DIRS))
226
227 $(patsubst %, _dir_%, $(DIRS)) : dummy
228         $(MAKE) -C $(patsubst _dir_%, %, $@)
229
230 tags:
231         ctags -R
232
233 install: install_dev install_runtime install_toolchain install_utils finished2
234
235
236 # Installs header files and development library links.
237 install_dev:
238         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
239         install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
240         install -d $(PREFIX)$(DEVEL_PREFIX)/include
241         -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
242         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
243         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
244             chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
245         done;
246         -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
247         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
248 ifeq ($(strip $(HAVE_SHARED)),true)
249         -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
250         # If we build shared libraries then the static libs are PIC...
251         # Make _pic.a symlinks to make mklibs.py and similar tools happy.
252         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
253                 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
254         done
255 endif
256
257
258 # Installs run-time libraries and helper apps onto the host system
259 # allowing cross development.  If you want to deploy to a target 
260 # system, use the "install_target" target instead... 
261 install_runtime:
262 ifeq ($(strip $(HAVE_SHARED)),true)
263         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
264         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
265         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
266                 $(PREFIX)$(DEVEL_PREFIX)/lib
267         cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
268         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
269             set -x -e; \
270             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
271                         $(PREFIX)$(DEVEL_PREFIX)/lib; \
272             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
273             ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
274                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
275         fi;
276 endif
277
278 install_toolchain:
279         install -d $(PREFIX)$(DEVEL_PREFIX)/lib
280         install -d $(PREFIX)$(DEVEL_PREFIX)/bin
281         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
282         install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
283         $(MAKE) -C extra/gcc-uClibc install
284
285 ifeq ($(strip $(HAVE_SHARED)),true)
286 utils: $(TOPDIR)ldso/util/ldd
287         $(MAKE) -C ldso utils
288 else
289 utils: dummy
290 endif
291
292 install_utils: utils
293 ifeq ($(strip $(HAVE_SHARED)),true)
294         install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
295         install -m 755 ldso/util/ldd \
296                 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
297         ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
298                 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
299         # For now, don't bother with readelf since surely the host
300         # system has binutils, or we couldn't have gotten this far...
301         #install -m 755 ldso/util/readelf \
302         #       $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
303         #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
304         #       $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
305         @if [ -x ldso/util/ldconfig ] ; then \
306             set -x -e; \
307             install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
308             install -m 755 ldso/util/ldconfig \
309                     $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
310             ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
311                     $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
312         fi;
313 endif
314
315 # Installs run-time libraries and helper apps in preparation for
316 # deploying onto a target system, but installed below wherever
317 # $PREFIX is set to, allowing you to package up the result for
318 # deployment onto your target system.
319 install_target:
320 ifeq ($(strip $(HAVE_SHARED)),true)
321         install -d $(PREFIX)$(TARGET_PREFIX)/lib
322         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
323         install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
324                 $(PREFIX)$(TARGET_PREFIX)/lib
325         cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
326         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
327             set -x -e; \
328             install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
329                         $(PREFIX)$(TARGET_PREFIX)/lib; \
330             mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
331             ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
332                         $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
333         fi;
334 endif
335
336 install_target_utils:
337 ifeq ($(strip $(HAVE_SHARED)),true)
338         @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
339         install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
340         install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
341         install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
342         @if [ -x ldso/util/ldconfig.target ] ; then \
343             set -x -e; \
344             install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
345             install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
346             install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
347         fi;
348 endif
349
350 finished2:
351         @echo
352         @echo Finished installing...
353         @echo
354
355
356 distclean clean:
357         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
358         @rm -rf tmp lib include/bits libc/tmp _install
359         $(MAKE) -C test clean
360         $(MAKE) -C ldso clean
361         $(MAKE) -C libc/misc/internals clean
362         $(MAKE) -C libc/unistd clean
363         $(MAKE) -C libc/sysdeps/linux/common clean
364         $(MAKE) -C extra/gcc-uClibc clean
365         @set -e; \
366         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
367                 rm -f include/sys/$$i; \
368         done; \
369         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
370                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
371                         rm -f include/sys/$$i; \
372                 done; \
373         fi;
374         @rm -f include/linux include/scsi include/asm
375         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
376             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
377         fi;
378         @if [ $(TARGET_ARCH) = "mipsel" ]; then \
379             $(MAKE) -C libc/sysdeps/linux/mips clean; \
380             rm -f ldso/ldso/mipsel; \
381             rm -f libc/sysdeps/linux/mipsel; \
382             rm -f libpthread/linuxthreads/sysdeps/mipsel; \
383         fi;
384
385 dist release: distclean
386         cd ..;                                  \
387         rm -rf uClibc-$(VERSION);               \
388         cp -a uClibc uClibc-$(VERSION);         \
389         find uClibc-$(VERSION)/ -type d         \
390             -name .\#* -exec rm -rf {} \; ;     \
391                                                 \
392         tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
393
394 .PHONY: dummy subdirs release distclean clean
395