3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
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
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
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
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.
25 #--------------------------------------------------------
27 #There are a number of configurable options in "Config"
29 #--------------------------------------------------------
34 DIRS = extra ldso libc libcrypt libresolv libutil libm libpthread
36 all: headers uClibc_config subdirs shared utils finished
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"
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
57 @echo Not building shared libraries...
63 @echo Finally finished compiling...
67 # Target for uClinux distro
70 ifeq ($(strip $(HAVE_SHARED)),true)
71 install -d $(ROMFSDIR)/lib
72 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
74 cp -a lib/*.so.* $(ROMFSDIR)/lib
75 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
77 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
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; \
92 cd $(shell pwd)/ldso/ldso; \
94 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
96 elif [ $(TARGET_ARCH) = "cris" ];then \
97 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
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;\
103 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
106 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
109 @if [ ! -f include/asm/unistd.h ] ; then \
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."; \
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
122 mkdir -p include/bits
125 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
128 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
129 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
135 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
138 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
139 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
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
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 ; \
162 echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
164 # [For now we make the assumption that a linux system without an
165 # MMU must be uClinux, and must have a broken munmap (both
166 # assumptions are a bit dodgy, but can be changed in the future).]
167 @if [ "$(HAS_MMU)" = "true" ] ; then \
168 echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
170 echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
171 echo "#define __UCLIBC_UCLINUX_BROKEN_MUNMAP__ 1" >> include/bits/uClibc_config.h ; \
173 @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
174 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
176 echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
178 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
179 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
181 echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
183 @if [ "$(HAS_WCHAR)" = "true" ] ; then \
184 echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
186 echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
188 @if [ "$(HAVE_ELF)" = "false" ] ; then \
189 echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
191 echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
193 @if [ "$(HAVE_SHARED)" = "false" ] ; then \
194 echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
196 echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
198 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
199 echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
201 echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
203 @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
204 echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
206 echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
208 @if [ "$(DOLFS)" = "true" ] ; then \
209 echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
211 echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
213 @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
214 echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
216 echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
218 @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
219 echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
221 echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
223 @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
224 echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
226 echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
228 @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
229 echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
231 echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
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 ; \
237 echo "#undef HAVE_DOT_HIDDEN" >> include/bits/uClibc_config.h ; \
240 subdirs: $(patsubst %, _dir_%, $(DIRS))
242 $(patsubst %, _dir_%, $(DIRS)) : dummy
243 $(MAKE) -C $(patsubst _dir_%, %, $@)
248 install: install_dev install_runtime install_toolchain install_utils finished2
251 # Installs header files and development library links.
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; \
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/'`; \
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...
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 \
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; \
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
300 ifeq ($(strip $(HAVE_SHARED)),true)
301 utils: $(TOPDIR)ldso/util/ldd
302 $(MAKE) -C ldso 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 \
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; \
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.
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 \
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; \
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 \
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; \
367 @echo Finished installing...
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
381 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
382 rm -f include/sys/$$i; \
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; \
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; \
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; \
400 dist release: distclean
402 rm -rf uClibc-$(VERSION); \
403 cp -a uClibc uClibc-$(VERSION); \
404 find uClibc-$(VERSION)/ -type d \
405 -name .\#* -exec rm -rf {} \; ; \
407 tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
409 .PHONY: dummy subdirs release distclean clean