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.
26 #--------------------------------------------------------------
27 # You shouldn't need to mess with anything beyond this point...
28 #--------------------------------------------------------------
29 noconfig_targets := menuconfig config oldconfig randconfig \
30 defconfig allyesconfig allnoconfig clean distclean \
35 DIRS = extra ldso libc libcrypt libresolv libutil libm libpthread
39 all: headers subdirs shared utils finished
41 # In this section, we need .config
45 ifeq ($(strip $(HAVE_SHARED)),y)
46 @$(MAKE) -C libc shared
47 @$(MAKE) -C ldso shared
48 @$(MAKE) -C libcrypt shared
49 @$(MAKE) -C libresolv shared
50 @$(MAKE) -C libutil shared
51 @$(MAKE) -C libm shared
52 @$(MAKE) -C libpthread shared
55 @echo Not building shared libraries...
61 @echo Finally finished compiling...
65 # Target for uClinux distro
68 ifeq ($(strip $(HAVE_SHARED)),y)
69 install -d $(ROMFSDIR)/lib
70 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
72 cp -a lib/*.so.* $(ROMFSDIR)/lib
73 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
75 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
80 include/bits/uClibc_config.h: .config
81 @if [ ! -x ./extra/config/conf ] ; then \
82 make -C extra/config; \
86 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
88 headers: include/bits/uClibc_config.h
90 @if [ "$(TARGET_ARCH)" = "powerpc" ];then \
91 ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
92 elif [ "$(TARGET_ARCH)" = "mips" ];then \
93 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
94 elif [ "$(TARGET_ARCH)" = "mipsel" ];then \
95 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
96 cd $(shell pwd)/libc/sysdeps/linux; \
98 cd $(shell pwd)/ldso/ldso; \
100 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
101 ln -fs mips mipsel; \
102 elif [ "$(TARGET_ARCH)" = "cris" ];then \
103 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
105 if [ "$(UCLIBC_HAS_MMU)" != "y" ]; then \
106 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
107 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
109 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
112 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
115 @if [ ! -f include/asm/unistd.h ] ; then \
118 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
119 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or UCLIBC_HAS_MMU"; \
120 echo "correctly when you configured uClibc. Please fix these settings."; \
124 rm -f include/linux include/scsi
125 ln -fs $(KERNEL_SOURCE)/include/linux include/linux
126 ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
129 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
132 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
133 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
139 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
142 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
143 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
149 rm -f include/bits/sysnum.h; \
150 TOPDIR=. CC=$(CC) /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h
151 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
153 subdirs: $(patsubst %, _dir_%, $(DIRS))
155 $(patsubst %, _dir_%, $(DIRS)) : dummy
156 $(MAKE) -C $(patsubst _dir_%, %, $@)
161 install: install_dev install_runtime install_toolchain install_utils finished2
164 # Installs header files and development library links.
166 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
167 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
168 install -d $(PREFIX)$(DEVEL_PREFIX)/include
169 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
170 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
171 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
172 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
174 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
175 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
176 ifeq ($(strip $(HAVE_SHARED)),y)
177 -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
178 # If we build shared libraries then the static libs are PIC...
179 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
180 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
181 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
186 # Installs run-time libraries and helper apps onto the host system
187 # allowing cross development. If you want to deploy to a target
188 # system, use the "install_target" target instead...
190 ifeq ($(strip $(HAVE_SHARED)),y)
191 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
192 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
193 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
194 $(PREFIX)$(DEVEL_PREFIX)/lib
195 cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
196 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
198 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
199 $(PREFIX)$(DEVEL_PREFIX)/lib; \
200 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
201 ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
202 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
207 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
208 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
209 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
210 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
211 $(MAKE) -C extra/gcc-uClibc install
213 ifeq ($(strip $(HAVE_SHARED)),y)
214 utils: $(TOPDIR)ldso/util/ldd
215 $(MAKE) -C ldso utils
221 ifeq ($(strip $(HAVE_SHARED)),y)
222 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
223 install -m 755 ldso/util/ldd \
224 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
225 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
226 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
227 # For now, don't bother with readelf since surely the host
228 # system has binutils, or we couldn't have gotten this far...
229 #install -m 755 ldso/util/readelf \
230 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
231 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
232 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
233 @if [ -x ldso/util/ldconfig ] ; then \
235 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
236 install -m 755 ldso/util/ldconfig \
237 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
238 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
239 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
243 # Installs run-time libraries and helper apps in preparation for
244 # deploying onto a target system, but installed below wherever
245 # $PREFIX is set to, allowing you to package up the result for
246 # deployment onto your target system.
248 ifeq ($(strip $(HAVE_SHARED)),y)
249 install -d $(PREFIX)$(TARGET_PREFIX)/lib
250 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
251 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
252 $(PREFIX)$(TARGET_PREFIX)/lib
253 cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
254 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
256 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
257 $(PREFIX)$(TARGET_PREFIX)/lib; \
258 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
259 ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
260 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
264 install_target_utils:
265 ifeq ($(strip $(HAVE_SHARED)),y)
266 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
267 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
268 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
269 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
270 @if [ -x ldso/util/ldconfig.target ] ; then \
272 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
273 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
274 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
277 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
278 @$(MAKE) -C libc/misc/wchar iconv.target
279 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
280 install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
285 @echo Finished installing...
288 else # ifdef include_config
292 ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
293 # Targets which don't need .config
296 # ---------------------------------------------------------------------------
298 extra/config/conf extra/config/mconf:
300 -@if [ ! -f .config ] ; then \
301 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
304 menuconfig: extra/config/mconf
305 make -C extra/config/lxdialog
307 mkdir -p include/bits
308 @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
310 config: extra/config/conf
312 mkdir -p include/bits
313 @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
315 oldconfig: extra/config/conf
317 mkdir -p include/bits
318 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
320 randconfig: extra/config/conf
322 mkdir -p include/bits
323 @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
325 allyesconfig: extra/config/conf
327 mkdir -p include/bits
328 @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
330 allnoconfig: extra/config/conf
332 mkdir -p include/bits
333 @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
335 defconfig: extra/config/conf
337 mkdir -p include/bits
338 @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
342 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
343 @rm -rf tmp lib include/bits libc/tmp _install
344 $(MAKE) -C test clean
345 $(MAKE) -C ldso clean
346 $(MAKE) -C libc/misc/internals clean
347 $(MAKE) -C libc/misc/wchar clean
348 $(MAKE) -C libc/unistd clean
349 $(MAKE) -C libc/sysdeps/linux/common clean
350 $(MAKE) -C extra clean
352 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
353 rm -f include/sys/$$i; \
355 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
356 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
357 rm -f include/sys/$$i; \
360 @rm -f include/linux include/scsi include/asm
361 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
362 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
364 @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
365 $(MAKE) -C libc/sysdeps/linux/mips clean; \
366 rm -f ldso/ldso/mipsel; \
367 rm -f libc/sysdeps/linux/mipsel; \
368 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
372 rm -f .config .config.old .config.cmd
376 rm -rf uClibc-$(VERSION); \
377 cp -a uClibc uClibc-$(VERSION); \
378 find uClibc-$(VERSION)/ -type d \
379 -name .\#* -exec rm -rf {} \; ; \
381 tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
383 endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
384 endif # ifdef include_config
386 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig