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
44 .PHONY: $(SHARED_TARGET)
45 shared: $(SHARED_TARGET)
46 ifeq ($(strip $(HAVE_SHARED)),y)
47 @$(MAKE) -C libc shared
48 @$(MAKE) -C ldso shared
49 @$(MAKE) -C libcrypt shared
50 @$(MAKE) -C libresolv shared
51 @$(MAKE) -C libnsl shared
52 @$(MAKE) -C libutil shared
53 @$(MAKE) -C libm shared
54 @$(MAKE) -C libpthread shared
56 ifeq ($(SHARED_TARGET),)
58 @echo Not building shared libraries...
63 ifneq ($(SHARED_TARGET),)
65 lib/main.o: $(ROOTDIR)/lib/libc/main.c
66 $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c -o $@ $(ROOTDIR)/lib/libc/main.c
68 bogus $(SHARED_TARGET): lib/libc.a lib/main.o Makefile
69 make -C $(ROOTDIR) relink
70 $(CC) -nostartfiles -o $(SHARED_TARGET) $(ARCH_CFLAGS) -Wl,-elf2flt -nostdlib \
71 -Wl,-shared-lib-id,${LIBID} \
73 -Wl,--whole-archive,lib/libc.a,-lgcc,--no-whole-archive
74 $(OBJCOPY) -L _GLOBAL_OFFSET_TABLE_ -L main -L __main -L _start \
75 -L __uClibc_main -L __uClibc_start_main -L lib_main \
77 -L __do_global_dtors -L __do_global_ctors \
78 -L __CTOR_LIST__ -L __DTOR_LIST__ \
79 -L _current_shared_library_a5_offset_ \
81 ln -sf $(SHARED_TARGET).gdb .
86 @echo Finally finished compiling...
90 # Target for uClinux distro
94 @if [ "$(CONFIG_BINFMT_SHARED_FLAT)" = "y" ]; then \
95 [ -e $(ROMFSDIR)/lib ] || mkdir -p $(ROMFSDIR)/lib; \
96 $(ROMFSINST) $(SHARED_TARGET) /lib/lib$(LIBID).so; \
98 ifeq ($(strip $(HAVE_SHARED)),y)
99 install -d $(ROMFSDIR)/lib
100 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
102 cp -fa lib/*.so.* $(ROMFSDIR)/lib/.
103 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
105 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
108 /lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
109 /lib/ld-linux.so.2; \
113 include/bits/uClibc_config.h: .config
114 @if [ ! -x ./extra/config/conf ] ; then \
115 make -C extra/config conf; \
118 mkdir -p include/bits
119 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
121 headers: include/bits/uClibc_config.h
123 @if [ "$(TARGET_ARCH)" = "powerpc" ];then \
124 ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
125 elif [ "$(TARGET_ARCH)" = "mips" ];then \
126 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
127 elif [ "$(TARGET_ARCH)" = "mipsel" ];then \
128 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
129 cd $(shell pwd)/libc/sysdeps/linux; \
130 ln -fs mips mipsel; \
131 cd $(shell pwd)/ldso/ldso; \
132 ln -fs mips mipsel; \
133 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
134 ln -fs mips mipsel; \
135 elif [ "$(TARGET_ARCH)" = "cris" ];then \
136 ln -fs $(KERNEL_SOURCE)/include/asm-cris include/asm; \
138 if [ "$(UCLIBC_HAS_MMU)" != "y" ]; then \
139 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
140 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
142 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
145 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
148 rm -f include/asm-generic;
149 ln -fs $(KERNEL_SOURCE)/include/asm-generic include/asm-generic;
150 @if [ ! -f include/asm/unistd.h ] ; then \
153 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
154 echo "I bet you did not set KERNEL_SOURCE, TARGET_ARCH or UCLIBC_HAS_MMU"; \
155 echo "correctly when you configured uClibc. Please fix these settings."; \
159 rm -f include/linux include/scsi
160 ln -fs $(KERNEL_SOURCE)/include/linux include/linux
161 ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
164 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
167 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
168 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
174 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
177 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
178 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
184 rm -f include/bits/sysnum.h; \
185 TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h
186 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
188 subdirs: $(patsubst %, _dir_%, $(DIRS))
190 $(patsubst %, _dir_%, $(DIRS)) : dummy
191 $(MAKE) -C $(patsubst _dir_%, %, $@)
196 install: install_dev install_runtime install_toolchain install_utils finished2
199 # Installs header files and development library links.
201 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
202 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
203 install -d $(PREFIX)$(DEVEL_PREFIX)/include
204 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
205 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
206 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
207 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
209 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
210 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
211 ifeq ($(strip $(HAVE_SHARED)),y)
212 -install -m 644 lib/*.so $(PREFIX)$(DEVEL_PREFIX)/lib/
213 -find lib/ -type l -name '*.so' -exec cp -fa {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
214 # If we build shared libraries then the static libs are PIC...
215 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
216 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
217 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
222 # Installs run-time libraries and helper apps onto the host system
223 # allowing cross development. If you want to deploy to a target
224 # system, use the "install_target" target instead...
226 ifeq ($(strip $(HAVE_SHARED)),y)
227 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
228 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
229 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
230 $(PREFIX)$(DEVEL_PREFIX)/lib
231 cp -fa lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
232 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
234 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
235 $(PREFIX)$(DEVEL_PREFIX)/lib; \
237 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
238 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
239 # ln -sf $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
240 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
245 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
246 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
247 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
248 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
249 $(MAKE) -C extra/gcc-uClibc install
251 ifeq ($(strip $(HAVE_SHARED)),y)
252 utils: $(TOPDIR)ldso/util/ldd
253 $(MAKE) -C ldso utils
259 ifeq ($(strip $(HAVE_SHARED)),y)
260 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
261 install -m 755 ldso/util/ldd \
262 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
263 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
264 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
265 # For now, don't bother with readelf since surely the host
266 # system has binutils, or we couldn't have gotten this far...
267 #install -m 755 ldso/util/readelf \
268 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
269 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
270 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
271 @if [ -x ldso/util/ldconfig ] ; then \
273 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
274 install -m 755 ldso/util/ldconfig \
275 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
276 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
277 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
281 # Installs run-time libraries and helper apps in preparation for
282 # deploying onto a target system, but installed below wherever
283 # $PREFIX is set to, allowing you to package up the result for
284 # deployment onto your target system.
286 ifeq ($(strip $(HAVE_SHARED)),y)
287 install -d $(PREFIX)$(TARGET_PREFIX)/lib
288 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
289 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
290 $(PREFIX)$(TARGET_PREFIX)/lib
291 cp -fa lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
292 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
294 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
295 $(PREFIX)$(TARGET_PREFIX)/lib; \
297 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
298 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
299 # ln -sf $(PREFIX)$(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
300 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
304 install_target_utils:
305 ifeq ($(strip $(HAVE_SHARED)),y)
306 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
307 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
308 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
309 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
310 @if [ -x ldso/util/ldconfig.target ] ; then \
312 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
313 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
314 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
317 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
318 @$(MAKE) -C libc/misc/wchar iconv.target
319 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
320 install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
325 @echo Finished installing...
328 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
333 # ---------------------------------------------------------------------------
336 make -C extra/config conf
337 -@if [ ! -f .config ] ; then \
338 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
342 make -C extra/config ncurses conf mconf
343 -@if [ ! -f .config ] ; then \
344 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
347 menuconfig: extra/config/mconf
349 mkdir -p include/bits
350 @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
352 config: extra/config/conf
354 mkdir -p include/bits
355 @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
357 oldconfig: extra/config/conf
359 mkdir -p include/bits
360 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
362 randconfig: extra/config/conf
364 mkdir -p include/bits
365 @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
367 allyesconfig: extra/config/conf
369 mkdir -p include/bits
370 @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
372 allnoconfig: extra/config/conf
374 mkdir -p include/bits
375 @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
377 defconfig: extra/config/conf
379 mkdir -p include/bits
380 @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
384 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
385 @rm -rf tmp lib include/bits libc/tmp _install
386 $(MAKE) -C test clean
387 $(MAKE) -C ldso clean
388 $(MAKE) -C libc/misc/internals clean
389 $(MAKE) -C libc/misc/wchar clean
390 $(MAKE) -C libc/unistd clean
391 $(MAKE) -C libc/sysdeps/linux/common clean
392 $(MAKE) -C extra/gcc-uClibc clean
393 $(MAKE) -C extra/locale clean
395 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
396 rm -f include/sys/$$i; \
398 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
399 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
400 rm -f include/sys/$$i; \
403 @rm -f include/linux include/scsi include/asm
404 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
405 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
407 @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
408 $(MAKE) -C libc/sysdeps/linux/mips clean; \
409 rm -f ldso/ldso/mipsel; \
410 rm -f libc/sysdeps/linux/mipsel; \
411 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
415 rm -f .config .config.old .config.cmd
416 $(MAKE) -C extra clean
420 rm -rf uClibc-$(VERSION); \
421 cp -fa uClibc uClibc-$(VERSION); \
422 find uClibc-$(VERSION)/ -type f \
423 -name .\#* -exec rm -rf {} \; ; \
424 find uClibc-$(VERSION)/ -type d \
425 -name CVS -exec rm -rf {} \; ; \
427 tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
429 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
431 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig