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 # dummy target for uClinux distro
73 @if [ $(TARGET_ARCH) = "powerpc" ];then \
74 ln -fs $(KERNEL_SOURCE)/include/asm-ppc include/asm; \
75 elif [ $(TARGET_ARCH) = "mips" ];then \
76 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
77 elif [ $(TARGET_ARCH) = "mipsel" ];then \
78 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
79 cd $(shell pwd)/libc/sysdeps/linux; \
81 cd $(shell pwd)/ldso/ldso; \
83 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
86 if [ $(HAS_MMU) != "true" ]; then \
87 if [ -d $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu ] ; then \
88 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu include/asm;\
90 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
93 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH) include/asm; \
96 @if [ ! -f include/asm/unistd.h ] ; then \
99 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
100 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
101 echo "correctly. Please edit \`Config' and fix these settings."; \
105 rm -f include/linux include/scsi
106 ln -fs $(KERNEL_SOURCE)/include/linux include/linux
107 ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
109 mkdir -p include/bits
112 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
115 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
116 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
122 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
125 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
126 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
132 rm -f include/bits/syscall.h; \
133 TOPDIR=$(TOPDIR) CC=$(CC) /bin/sh $(TOPDIR)/extra/scripts/gen_bits_syscall_h.sh > include/bits/syscall.h
134 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
136 uClibc_config: Makefile Config
137 @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > include/bits/uClibc_config.h
138 @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> include/bits/uClibc_config.h
139 @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> include/bits/uClibc_config.h
140 @echo "#endif" >> include/bits/uClibc_config.h
141 @echo "#define __UCLIBC_MAJOR__ $(MAJOR_VERSION)" >> include/bits/uClibc_config.h
142 @echo "#define __UCLIBC_MINOR__ $(MINOR_VERSION)" >> include/bits/uClibc_config.h
143 @echo "#define __UCLIBC_SUBLEVEL__ $(SUBLEVEL)" >> include/bits/uClibc_config.h
144 @echo "#define linux 1" >> include/bits/uClibc_config.h
145 @echo "#define __linux__ 1" >> include/bits/uClibc_config.h
146 @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
147 echo "#define __UCLIBC_HAS_IPV6__ 1" >> include/bits/uClibc_config.h ; \
149 echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
151 @if [ "$(HAS_MMU)" = "true" ] ; then \
152 echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
154 echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
156 @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
157 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
159 echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
161 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
162 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
164 echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
166 @if [ "$(HAS_WCHAR)" = "true" ] ; then \
167 echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
169 echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
171 @if [ "$(HAVE_ELF)" = "false" ] ; then \
172 echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
174 echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
176 @if [ "$(HAVE_SHARED)" = "false" ] ; then \
177 echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
179 echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
181 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
182 echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
184 echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
186 @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
187 echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
189 echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
191 @if [ "$(DOLFS)" = "true" ] ; then \
192 echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
194 echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
196 @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
197 echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
199 echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
201 @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
202 echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
204 echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
206 @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
207 echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
209 echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
211 @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
212 echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
214 echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
216 @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
217 @if [ "$(HAVE_DOT_HIDDEN)" = "true" ] ; then \
218 echo "#define HAVE_DOT_HIDDEN 1" >> include/bits/uClibc_config.h ; \
220 echo "#undef HAVE_DOT_HIDDEN" >> include/bits/uClibc_config.h ; \
223 subdirs: $(patsubst %, _dir_%, $(DIRS))
225 $(patsubst %, _dir_%, $(DIRS)) : dummy
226 $(MAKE) -C $(patsubst _dir_%, %, $@)
231 install: install_dev install_runtime install_toolchain install_utils finished2
234 # Installs header files and development library links.
236 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
237 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
238 install -d $(PREFIX)$(DEVEL_PREFIX)/include
239 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
240 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
241 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
242 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
244 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
245 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
246 ifeq ($(strip $(HAVE_SHARED)),true)
247 -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
248 # If we build shared libraries then the static libs are PIC...
249 # Make _pic.a symlinks to make mklibs.py and similar tools happy.
250 for i in `find lib/ -type f -name '*.a' | sed -e 's/lib\///'` ; do \
251 ln -sf $$i $(PREFIX)$(DEVEL_PREFIX)/lib/`echo $$i | sed -e 's/\.a$$/_pic.a/'`; \
256 # Installs run-time libraries and helper apps onto the host system
257 # allowing cross development. If you want to deploy to a target
258 # system, use the "install_target" target instead...
260 ifeq ($(strip $(HAVE_SHARED)),true)
261 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
262 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
263 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
264 $(PREFIX)$(DEVEL_PREFIX)/lib
265 cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
266 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
268 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
269 $(PREFIX)$(DEVEL_PREFIX)/lib; \
270 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
271 ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
272 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
277 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
278 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
279 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
280 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
281 $(MAKE) -C extra/gcc-uClibc install
283 ifeq ($(strip $(HAVE_SHARED)),true)
284 utils: $(TOPDIR)ldso/util/ldd
285 $(MAKE) -C ldso utils
291 ifeq ($(strip $(HAVE_SHARED)),true)
292 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
293 install -m 755 ldso/util/ldd \
294 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
295 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
296 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
297 # For now, don't bother with readelf since surely the host
298 # system has binutils, or we couldn't have gotten this far...
299 #install -m 755 ldso/util/readelf \
300 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
301 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
302 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
303 @if [ -x ldso/util/ldconfig ] ; then \
305 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
306 install -m 755 ldso/util/ldconfig \
307 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
308 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
309 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
313 # Installs run-time libraries and helper apps in preparation for
314 # deploying onto a target system, but installed below wherever
315 # $PREFIX is set to, allowing you to package up the result for
316 # deployment onto your target system.
318 ifeq ($(strip $(HAVE_SHARED)),true)
319 install -d $(PREFIX)$(TARGET_PREFIX)/lib
320 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
321 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
322 $(PREFIX)$(TARGET_PREFIX)/lib
323 cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
324 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
326 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
327 $(PREFIX)$(TARGET_PREFIX)/lib; \
328 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
329 ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
330 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
334 install_target_utils:
335 ifeq ($(strip $(HAVE_SHARED)),true)
336 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
337 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
338 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
339 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
340 @if [ -x ldso/util/ldconfig.target ] ; then \
342 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
343 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
344 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
350 @echo Finished installing...
355 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
356 @rm -rf tmp lib include/bits libc/tmp _install
357 $(MAKE) -C test clean
358 $(MAKE) -C ldso clean
359 $(MAKE) -C libc/misc/internals clean
360 $(MAKE) -C libc/unistd clean
361 $(MAKE) -C libc/sysdeps/linux/common clean
362 $(MAKE) -C extra/gcc-uClibc clean
364 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
365 rm -f include/sys/$$i; \
367 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
368 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
369 rm -f include/sys/$$i; \
372 @rm -f include/linux include/scsi include/asm
373 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
374 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
376 @if [ $(TARGET_ARCH) = "mipsel" ]; then \
377 $(MAKE) -C libc/sysdeps/linux/mips clean; \
378 rm -f ldso/ldso/mipsel; \
379 rm -f libc/sysdeps/linux/mipsel; \
380 rm -f libpthread/linuxthreads/sysdeps/mipsel; \
383 dist release: distclean
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 .PHONY: dummy subdirs release distclean clean