OSDN Git Service

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