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 libnsl libutil libm libpthread
37 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
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 libnsl shared
51 @$(MAKE) -C libutil shared
52 @$(MAKE) -C libm shared
53 @$(MAKE) -C libpthread shared
56 @echo Not building shared libraries...
62 @echo Finally finished compiling...
66 # Target for uClinux distro
69 ifeq ($(strip $(HAVE_SHARED)),y)
70 install -d $(ROMFSDIR)/lib
71 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
73 cp -a lib/*.so.* $(ROMFSDIR)/lib
74 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
76 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
81 include/bits/uClibc_config.h: .config
82 @if [ ! -x ./extra/config/conf ] ; then \
83 make -C extra/config conf; \
87 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
89 headers: include/bits/uClibc_config.h
91 @if [ "$(TARGET_ARCH)" = "powerpc" ];then \
92 ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
93 elif [ "$(TARGET_ARCH)" = "mips" ];then \
94 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
95 elif [ "$(TARGET_ARCH)" = "mipsel" ];then \
96 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
97 cd $(shell pwd)/libc/sysdeps/linux; \
99 cd $(shell pwd)/ldso/ldso; \
100 ln -fs mips mipsel; \
101 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
102 ln -fs mips mipsel; \
103 elif [ "$(TARGET_ARCH)" = "cris" ];then \
104 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
106 if [ "$(UCLIBC_HAS_MMU)" != "y" ]; then \
107 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
108 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
110 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
113 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
116 @if [ ! -f include/asm/unistd.h ] ; then \
119 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
120 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or UCLIBC_HAS_MMU"; \
121 echo "correctly when you configured uClibc. Please fix these settings."; \
125 rm -f include/linux include/scsi
126 ln -fs $(KERNEL_SOURCE)/include/linux include/linux
127 ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
130 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
133 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
134 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
140 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
143 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
144 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
150 rm -f include/bits/sysnum.h; \
151 TOPDIR=. CC=$(CC) /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h
152 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
154 subdirs: $(patsubst %, _dir_%, $(DIRS))
156 $(patsubst %, _dir_%, $(DIRS)) : dummy
157 $(MAKE) -C $(patsubst _dir_%, %, $@)
162 install: install_dev install_runtime install_toolchain install_utils finished2
165 # Installs header files and development library links.
167 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
168 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
169 install -d $(PREFIX)$(DEVEL_PREFIX)/include
170 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
171 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
172 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
173 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
175 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
176 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
177 ifeq ($(strip $(HAVE_SHARED)),y)
178 -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
179 # If we build shared libraries then the static libs are PIC...
180 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
181 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
182 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
187 # Installs run-time libraries and helper apps onto the host system
188 # allowing cross development. If you want to deploy to a target
189 # system, use the "install_target" target instead...
191 ifeq ($(strip $(HAVE_SHARED)),y)
192 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
193 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
194 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
195 $(PREFIX)$(DEVEL_PREFIX)/lib
196 cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
197 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
199 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
200 $(PREFIX)$(DEVEL_PREFIX)/lib; \
202 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
203 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
204 # ln -sf $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
205 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
210 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
211 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
212 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
213 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
214 $(MAKE) -C extra/gcc-uClibc install
216 ifeq ($(strip $(HAVE_SHARED)),y)
217 utils: $(TOPDIR)ldso/util/ldd
218 $(MAKE) -C ldso utils
224 ifeq ($(strip $(HAVE_SHARED)),y)
225 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
226 install -m 755 ldso/util/ldd \
227 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
228 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
229 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
230 # For now, don't bother with readelf since surely the host
231 # system has binutils, or we couldn't have gotten this far...
232 #install -m 755 ldso/util/readelf \
233 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
234 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
235 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
236 @if [ -x ldso/util/ldconfig ] ; then \
238 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
239 install -m 755 ldso/util/ldconfig \
240 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
241 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
242 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
246 # Installs run-time libraries and helper apps in preparation for
247 # deploying onto a target system, but installed below wherever
248 # $PREFIX is set to, allowing you to package up the result for
249 # deployment onto your target system.
251 ifeq ($(strip $(HAVE_SHARED)),y)
252 install -d $(PREFIX)$(TARGET_PREFIX)/lib
253 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
254 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
255 $(PREFIX)$(TARGET_PREFIX)/lib
256 cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
257 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
259 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
260 $(PREFIX)$(TARGET_PREFIX)/lib; \
262 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
263 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
264 # ln -sf $(PREFIX)$(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
265 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
269 install_target_utils:
270 ifeq ($(strip $(HAVE_SHARED)),y)
271 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
272 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
273 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
274 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
275 @if [ -x ldso/util/ldconfig.target ] ; then \
277 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
278 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
279 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
282 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
283 @$(MAKE) -C libc/misc/wchar iconv.target
284 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
285 install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
290 @echo Finished installing...
293 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
298 # ---------------------------------------------------------------------------
301 make -C extra/config conf
302 -@if [ ! -f .config ] ; then \
303 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
307 make -C extra/config ncurses conf mconf
308 -@if [ ! -f .config ] ; then \
309 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
312 menuconfig: extra/config/mconf
314 mkdir -p include/bits
315 @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
317 config: extra/config/conf
319 mkdir -p include/bits
320 @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
322 oldconfig: extra/config/conf
324 mkdir -p include/bits
325 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
327 randconfig: extra/config/conf
329 mkdir -p include/bits
330 @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
332 allyesconfig: extra/config/conf
334 mkdir -p include/bits
335 @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
337 allnoconfig: extra/config/conf
339 mkdir -p include/bits
340 @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
342 defconfig: extra/config/conf
344 mkdir -p include/bits
345 @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
349 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
350 @rm -rf tmp lib include/bits libc/tmp _install
351 $(MAKE) -C test clean
352 $(MAKE) -C ldso clean
353 $(MAKE) -C libc/misc/internals clean
354 $(MAKE) -C libc/misc/wchar clean
355 $(MAKE) -C libc/unistd clean
356 $(MAKE) -C libc/sysdeps/linux/common clean
357 $(MAKE) -C extra/gcc-uClibc clean
358 $(MAKE) -C extra/locale clean
360 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
361 rm -f include/sys/$$i; \
363 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
364 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
365 rm -f include/sys/$$i; \
368 @rm -f include/linux include/scsi include/asm
369 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
370 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
372 @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
373 $(MAKE) -C libc/sysdeps/linux/mips clean; \
374 rm -f ldso/ldso/mipsel; \
375 rm -f libc/sysdeps/linux/mipsel; \
376 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
380 rm -f .config .config.old .config.cmd
381 $(MAKE) -C extra clean
385 rm -rf uClibc-$(VERSION); \
386 cp -a uClibc uClibc-$(VERSION); \
387 find uClibc-$(VERSION)/ -type d \
388 -name .\#* -exec rm -rf {} \; ; \
390 tar -cvzf uClibc-$(VERSION).tar.gz --exclude CVS uClibc-$(VERSION)/;
392 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
394 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig