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 @if [ "$(HAS_MMU)" = "true" ] ; then \
165 echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
167 echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
169 @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
170 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
172 echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
174 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
175 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
177 echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
179 @if [ "$(HAS_WCHAR)" = "true" ] ; then \
180 echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
182 echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
184 @if [ "$(HAVE_ELF)" = "false" ] ; then \
185 echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
187 echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
189 @if [ "$(HAVE_SHARED)" = "false" ] ; then \
190 echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
192 echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
194 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
195 echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
197 echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
199 @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
200 echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
202 echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
204 @if [ "$(DOLFS)" = "true" ] ; then \
205 echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
207 echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
209 @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
210 echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
212 echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
214 @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
215 echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
217 echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
219 @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
220 echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
222 echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
224 @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
225 echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
227 echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
229 @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
230 @if [ "$(HAVE_DOT_HIDDEN)" = "true" ] ; then \
231 echo "#define HAVE_DOT_HIDDEN 1" >> include/bits/uClibc_config.h ; \
233 echo "#undef HAVE_DOT_HIDDEN" >> include/bits/uClibc_config.h ; \
236 subdirs: $(patsubst %, _dir_%, $(DIRS))
238 $(patsubst %, _dir_%, $(DIRS)) : dummy
239 $(MAKE) -C $(patsubst _dir_%, %, $@)
244 install: install_dev install_runtime install_toolchain install_utils finished2
247 # Installs header files and development library links.
249 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
250 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
251 install -d $(PREFIX)$(DEVEL_PREFIX)/include
252 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
253 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
254 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
255 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
257 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
258 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
259 ifeq ($(strip $(HAVE_SHARED)),true)
260 -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
261 # If we build shared libraries then the static libs are PIC...
262 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
263 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
264 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
269 # Installs run-time libraries and helper apps onto the host system
270 # allowing cross development. If you want to deploy to a target
271 # system, use the "install_target" target instead...
273 ifeq ($(strip $(HAVE_SHARED)),true)
274 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
275 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
276 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
277 $(PREFIX)$(DEVEL_PREFIX)/lib
278 cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
279 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
281 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
282 $(PREFIX)$(DEVEL_PREFIX)/lib; \
283 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
284 ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
285 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
290 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
291 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
292 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
293 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
294 $(MAKE) -C extra/gcc-uClibc install
296 ifeq ($(strip $(HAVE_SHARED)),true)
297 utils: $(TOPDIR)ldso/util/ldd
298 $(MAKE) -C ldso utils
304 ifeq ($(strip $(HAVE_SHARED)),true)
305 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
306 install -m 755 ldso/util/ldd \
307 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
308 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
309 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
310 # For now, don't bother with readelf since surely the host
311 # system has binutils, or we couldn't have gotten this far...
312 #install -m 755 ldso/util/readelf \
313 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
314 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
315 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
316 @if [ -x ldso/util/ldconfig ] ; then \
318 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
319 install -m 755 ldso/util/ldconfig \
320 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
321 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
322 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
326 # Installs run-time libraries and helper apps in preparation for
327 # deploying onto a target system, but installed below wherever
328 # $PREFIX is set to, allowing you to package up the result for
329 # deployment onto your target system.
331 ifeq ($(strip $(HAVE_SHARED)),true)
332 install -d $(PREFIX)$(TARGET_PREFIX)/lib
333 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
334 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
335 $(PREFIX)$(TARGET_PREFIX)/lib
336 cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
337 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
339 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
340 $(PREFIX)$(TARGET_PREFIX)/lib; \
341 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
342 ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
343 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
347 install_target_utils:
348 ifeq ($(strip $(HAVE_SHARED)),true)
349 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
350 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
351 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
352 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
353 @if [ -x ldso/util/ldconfig.target ] ; then \
355 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
356 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
357 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
363 @echo Finished installing...
368 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
369 @rm -rf tmp lib include/bits libc/tmp _install
370 $(MAKE) -C test clean
371 $(MAKE) -C ldso clean
372 $(MAKE) -C libc/misc/internals clean
373 $(MAKE) -C libc/unistd clean
374 $(MAKE) -C libc/sysdeps/linux/common clean
375 $(MAKE) -C extra/gcc-uClibc clean
377 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
378 rm -f include/sys/$$i; \
380 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
381 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
382 rm -f include/sys/$$i; \
385 @rm -f include/linux include/scsi include/asm
386 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
387 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
389 @if [ $(TARGET_ARCH) = "mipsel" ]; then \
390 $(MAKE) -C libc/sysdeps/linux/mips clean; \
391 rm -f ldso/ldso/mipsel; \
392 rm -f libc/sysdeps/linux/mipsel; \
393 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
396 dist release: distclean
398 rm -rf uClibc-$(VERSION); \
399 cp -a uClibc uClibc-$(VERSION); \
400 find uClibc-$(VERSION)/ -type d \
401 -name .\#* -exec rm -rf {} \; ; \
403 tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
405 .PHONY: dummy subdirs release distclean clean