3 # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Library General Public License for more details.
16 # You should have received a copy of the GNU Library General
17 # Public License along with this program; if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 # Boston, MA 02111-1307 USA
22 #--------------------------------------------------------------
23 # You shouldn't need to mess with anything beyond this point...
24 #--------------------------------------------------------------
25 noconfig_targets := menuconfig config oldconfig randconfig \
26 defconfig allyesconfig allnoconfig clean distclean \
31 DIRS = extra ldso libc libcrypt libresolv libnsl libutil libm libpthread
32 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
36 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
38 all: headers subdirs shared utils finished
40 # In this section, we need .config
43 .PHONY: $(SHARED_TARGET)
44 shared: $(SHARED_TARGET)
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
54 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
55 @$(MAKE) -C libintl shared
58 ifeq ($(SHARED_TARGET),)
60 @echo Not building shared libraries...
65 ifneq ($(SHARED_TARGET),)
67 lib/main.o: $(ROOTDIR)/lib/libc/main.c
68 $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c -o $@ $(ROOTDIR)/lib/libc/main.c
70 bogus $(SHARED_TARGET): lib/libc.a lib/main.o Makefile
71 make -C $(ROOTDIR) relink
72 $(CC) -nostartfiles -o $(SHARED_TARGET) $(ARCH_CFLAGS) -Wl,-elf2flt -nostdlib \
73 -Wl,-shared-lib-id,${LIBID} \
75 -Wl,--whole-archive,lib/libc.a,-lgcc,--no-whole-archive
76 $(OBJCOPY) -L _GLOBAL_OFFSET_TABLE_ -L main -L __main -L _start \
77 -L __uClibc_main -L __uClibc_start_main -L lib_main \
79 -L __do_global_dtors -L __do_global_ctors \
80 -L __CTOR_LIST__ -L __DTOR_LIST__ \
81 -L _current_shared_library_a5_offset_ \
83 ln -sf $(SHARED_TARGET).gdb .
88 @echo Finally finished compiling...
92 # Target for uClinux distro
96 @if [ "$(CONFIG_BINFMT_SHARED_FLAT)" = "y" ]; then \
97 [ -e $(ROMFSDIR)/lib ] || mkdir -p $(ROMFSDIR)/lib; \
98 $(ROMFSINST) $(SHARED_TARGET) /lib/lib$(LIBID).so; \
100 ifeq ($(strip $(HAVE_SHARED)),y)
101 install -d $(ROMFSDIR)/lib
102 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
104 cp -fa lib/*.so.* $(ROMFSDIR)/lib/.
105 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
107 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
110 /lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
111 /lib/ld-linux.so.2; \
115 include/bits/uClibc_config.h: .config
116 @if [ ! -x ./extra/config/conf ] ; then \
117 make -C extra/config conf; \
120 mkdir -p include/bits
121 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
123 headers: include/bits/uClibc_config.h
124 ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
125 @./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH)
127 @./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) -n
129 @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
130 (cd libc/sysdeps/linux; \
131 ln -fs mips mipsel); \
133 ln -fs mips mipsel); \
134 (cd libpthread/linuxthreads/sysdeps; \
135 ln -fs mips mipsel); \
139 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
142 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
143 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
149 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
152 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
153 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
159 TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
160 if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
161 $(RM) include/bits/sysnum.h.new; \
163 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
165 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
167 subdirs: $(patsubst %, _dir_%, $(DIRS))
169 $(patsubst %, _dir_%, $(DIRS)) : dummy
170 $(MAKE) -C $(patsubst _dir_%, %, $@)
175 install: install_dev install_runtime install_toolchain install_utils finished2
178 # Installs header files and development library links.
180 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
181 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
182 install -d $(PREFIX)$(DEVEL_PREFIX)/include
183 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
184 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
185 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
186 # Remove floating point related headers since float support is disabled.
187 rm $(PREFIX)$(DEVEL_PREFIX)/include/complex.h
188 rm $(PREFIX)$(DEVEL_PREFIX)/include/fpu_control.h
189 rm $(PREFIX)$(DEVEL_PREFIX)/include/ieee754.h
190 rm $(PREFIX)$(DEVEL_PREFIX)/include/math.h
191 rm $(PREFIX)$(DEVEL_PREFIX)/include/tgmath.h
193 ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
194 # Remove wide char headers since wide char support is disabled.
195 rm $(PREFIX)$(DEVEL_PREFIX)/include/wctype.h
196 rm $(PREFIX)$(DEVEL_PREFIX)/include/wchar.h
198 ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
199 # Remove iconv header since locale support is disabled.
200 rm $(PREFIX)$(DEVEL_PREFIX)/include/iconv.h
202 ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
203 # Remove printf header since custom print specifier support is disabled.
204 rm $(PREFIX)$(DEVEL_PREFIX)/include/printf.h
206 ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
207 # Remove xlocale header since extended locale support is disabled.
208 rm $(PREFIX)$(DEVEL_PREFIX)/include/xlocale.h
210 ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
211 # Remove libintl header since gettext support is disabled.
212 rm $(PREFIX)$(DEVEL_PREFIX)/include/libintl.h
214 ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
215 # Remove regex headers since regex support is disabled.
216 rm $(PREFIX)$(DEVEL_PREFIX)/include/regex.h
217 rm $(PREFIX)$(DEVEL_PREFIX)/include/regexp.h
219 ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
220 # Remove wordexp header since wordexp support is disabled.
221 rm $(PREFIX)$(DEVEL_PREFIX)/include/wordexp.h
223 ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
224 # Remove ftw header since ftw support is disabled.
225 rm $(PREFIX)$(DEVEL_PREFIX)/include/ftw.h
227 ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
228 # Remove glob header since glob support is disabled.
229 rm $(PREFIX)$(DEVEL_PREFIX)/include/glob.h
231 ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
232 # Remove getopt header since gnu getopt support is disabled.
233 rm $(PREFIX)$(DEVEL_PREFIX)/include/getopt.h
235 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
236 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
238 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
239 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
240 ifeq ($(strip $(HAVE_SHARED)),y)
241 -install -m 644 lib/*.so $(PREFIX)$(DEVEL_PREFIX)/lib/
242 -find lib/ -type l -name '*.so' -exec cp -fa {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
243 # If we build shared libraries then the static libs are PIC...
244 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
245 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
246 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
251 # Installs run-time libraries and helper apps onto the host system
252 # allowing cross development. If you want to deploy to a target
253 # system, use the "install_target" target instead...
255 ifeq ($(strip $(HAVE_SHARED)),y)
256 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
257 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
258 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
259 $(PREFIX)$(DEVEL_PREFIX)/lib
260 cp -fa lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
261 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
263 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
264 $(PREFIX)$(DEVEL_PREFIX)/lib; \
266 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
267 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
268 # ln -sf $(PREFIX)$(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
269 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
274 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
275 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
276 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
277 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
278 $(MAKE) -C extra/gcc-uClibc install
280 ifeq ($(strip $(HAVE_SHARED)),y)
281 utils: $(TOPDIR)ldso/util/ldd
282 $(MAKE) -C ldso utils
288 ifeq ($(strip $(HAVE_SHARED)),y)
289 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
290 install -m 755 ldso/util/ldd \
291 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
292 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
293 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
294 # For now, don't bother with readelf since surely the host
295 # system has binutils, or we couldn't have gotten this far...
296 #install -m 755 ldso/util/readelf \
297 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
298 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
299 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
300 @if [ -x ldso/util/ldconfig ] ; then \
302 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
303 install -m 755 ldso/util/ldconfig \
304 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
305 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
306 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
310 # Installs run-time libraries and helper apps in preparation for
311 # deploying onto a target system, but installed below wherever
312 # $PREFIX is set to, allowing you to package up the result for
313 # deployment onto your target system.
315 ifeq ($(strip $(HAVE_SHARED)),y)
316 install -d $(PREFIX)$(TARGET_PREFIX)/lib
317 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
318 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
319 $(PREFIX)$(TARGET_PREFIX)/lib
320 cp -fa lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
321 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
323 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
324 $(PREFIX)$(TARGET_PREFIX)/lib; \
326 #@if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
327 # install -d $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
328 # ln -sf $(PREFIX)$(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
329 # $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO); \
333 install_target_utils:
334 ifeq ($(strip $(HAVE_SHARED)),y)
335 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
336 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
337 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
338 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
339 @if [ -x ldso/util/ldconfig.target ] ; then \
341 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
342 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
343 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
346 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
347 @$(MAKE) -C libc/misc/wchar iconv.target
348 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
349 install -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/iconv
354 @echo Finished installing...
357 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
362 # ---------------------------------------------------------------------------
363 extra/config/conf: buildconf
364 -@if [ ! -f .config ] ; then \
365 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
369 make -C extra/config conf
371 extra/config/mconf: buildmconf
372 -@if [ ! -f .config ] ; then \
373 cp extra/Configs/Config.$(TARGET_ARCH).default .config; \
377 make -C extra/config ncurses mconf
379 menuconfig: extra/config/mconf
381 mkdir -p include/bits
382 @./extra/config/mconf extra/Configs/Config.$(TARGET_ARCH)
384 config: extra/config/conf
386 mkdir -p include/bits
387 @./extra/config/conf extra/Configs/Config.$(TARGET_ARCH)
389 oldconfig: extra/config/conf
391 mkdir -p include/bits
392 @./extra/config/conf -o extra/Configs/Config.$(TARGET_ARCH)
394 randconfig: extra/config/conf
396 mkdir -p include/bits
397 @./extra/config/conf -r extra/Configs/Config.$(TARGET_ARCH)
399 allyesconfig: extra/config/conf
401 mkdir -p include/bits
402 @./extra/config/conf -y extra/Configs/Config.$(TARGET_ARCH)
404 allnoconfig: extra/config/conf
406 mkdir -p include/bits
407 @./extra/config/conf -n extra/Configs/Config.$(TARGET_ARCH)
409 defconfig: extra/config/conf
411 mkdir -p include/bits
412 @./extra/config/conf -d extra/Configs/Config.$(TARGET_ARCH)
416 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
417 @rm -rf tmp lib include/bits libc/tmp _install
418 $(MAKE) -C test clean
419 $(MAKE) -C ldso clean
420 $(MAKE) -C libc/misc/internals clean
421 $(MAKE) -C libc/misc/wchar clean
422 $(MAKE) -C libc/unistd clean
423 $(MAKE) -C libc/sysdeps/linux/common clean
424 $(MAKE) -C extra/gcc-uClibc clean
425 $(MAKE) -C extra/locale clean
427 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
428 rm -f include/sys/$$i; \
430 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
431 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
432 rm -f include/sys/$$i; \
435 @rm -f include/linux include/scsi include/asm
436 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
437 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
439 @if [ "$(TARGET_ARCH)" = "mipsel" ]; then \
440 $(MAKE) -C libc/sysdeps/linux/mips clean; \
441 rm -f ldso/ldso/mipsel; \
442 rm -f libc/sysdeps/linux/mipsel; \
443 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
447 rm -f .config .config.old .config.cmd
448 $(MAKE) -C extra clean
452 rm -rf uClibc-$(VERSION); \
453 cp -fa uClibc uClibc-$(VERSION); \
454 find uClibc-$(VERSION)/ -type f \
455 -name .\#* -exec rm -rf {} \; ; \
456 find uClibc-$(VERSION)/ -type d \
457 -name CVS -exec rm -rf {} \; ; \
459 tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
461 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
463 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig