3 # Copyright (C) 2000 by Lineo, inc.
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 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) = "v850" ];then \
76 ln -fs $(KERNEL_SOURCE)/include/asm-v850 include/asm; \
77 elif [ $(TARGET_ARCH) = "mips" ];then \
78 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
79 elif [ $(TARGET_ARCH) = "mipsel" ];then \
80 ln -fs $(KERNEL_SOURCE)/include/asm-mips include/asm; \
81 cd $(shell pwd)/libc/sysdeps/linux; \
83 cd $(shell pwd)/ldso/ldso; \
85 cd $(shell pwd)/libpthread/linuxthreads/sysdeps; \
87 elif [ $(TARGET_ARCH) = "h8300" ];then \
88 ln -fs $(KERNEL_SOURCE)/include/asm-h8300 include/asm; \
90 if [ $(HAS_MMU) != "true" ]; then \
91 ln -fs $(KERNEL_SOURCE)/include/asm-$(TARGET_ARCH)nommu 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 @if [ $(HAS_MMU) != "true" -a $(TARGET_ARCH) = "i386" ] ; then \
107 echo "WARNING: I bet your x86 system really has an MMU, right?"; \
108 echo " malloc and friends won't work unless you fix \`Config'"; \
112 rm -f include/linux include/scsi
113 ln -fs $(KERNEL_SOURCE)/include/linux include/linux
114 ln -fs $(KERNEL_SOURCE)/include/scsi include/scsi
116 mkdir -p include/bits
119 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
122 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
123 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
129 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
132 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
133 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
139 rm -f include/bits/syscall.h; \
140 TOPDIR=$(TOPDIR) CC=$(CC) /bin/sh $(TOPDIR)/extra/scripts/gen_bits_syscall_h.sh > include/bits/syscall.h
141 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
143 uClibc_config: Makefile Config
144 @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > include/bits/uClibc_config.h
145 @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> include/bits/uClibc_config.h
146 @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> include/bits/uClibc_config.h
147 @echo "#endif" >> include/bits/uClibc_config.h
148 @echo "#define __UCLIBC_MAJOR__ $(MAJOR_VERSION)" >> include/bits/uClibc_config.h
149 @echo "#define __UCLIBC_MINOR__ $(MINOR_VERSION)" >> include/bits/uClibc_config.h
150 @echo "#define __UCLIBC_SUBLEVEL__ $(SUBLEVEL)" >> include/bits/uClibc_config.h
151 @echo "#define linux 1" >> include/bits/uClibc_config.h
152 @echo "#define __linux__ 1" >> include/bits/uClibc_config.h
153 @if [ "$(INCLUDE_IPV6)" = "true" ] ; then \
154 echo "#define __UCLIBC_HAS_IPV6__ 1" >> include/bits/uClibc_config.h ; \
156 echo "#undef __UCLIBC_HAS_IPV6__" >> include/bits/uClibc_config.h ; \
158 @if [ "$(HAS_MMU)" = "true" ] ; then \
159 echo "#define __UCLIBC_HAS_MMU__ 1" >> include/bits/uClibc_config.h ; \
161 echo "#undef __UCLIBC_HAS_MMU__" >> include/bits/uClibc_config.h ; \
163 @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
164 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> include/bits/uClibc_config.h ; \
166 echo "#undef __UCLIBC_HAS_FLOATS__" >> include/bits/uClibc_config.h ; \
168 @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
169 echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> include/bits/uClibc_config.h ; \
171 echo "#undef __UCLIBC_HAS_LONG_LONG__" >> include/bits/uClibc_config.h ; \
173 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
174 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> include/bits/uClibc_config.h ; \
176 echo "#undef __UCLIBC_HAS_LOCALE__" >> include/bits/uClibc_config.h ; \
178 @if [ "$(HAS_WCHAR)" = "true" ] ; then \
179 echo "#define __UCLIBC_HAS_WCHAR__ 1" >> include/bits/uClibc_config.h ; \
181 echo "#undef __UCLIBC_HAS_WCHAR__" >> include/bits/uClibc_config.h ; \
183 @if [ "$(HAVE_ELF)" = "false" ] ; then \
184 echo "#undef HAVE_ELF" >> include/bits/uClibc_config.h ; \
186 echo "#define HAVE_ELF 1" >> include/bits/uClibc_config.h ; \
188 @if [ "$(HAVE_SHARED)" = "false" ] ; then \
189 echo "#undef HAVE_SHARED" >> include/bits/uClibc_config.h ; \
191 echo "#define HAVE_SHARED 1" >> include/bits/uClibc_config.h ; \
193 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
194 echo "#define NO_UNDERSCORES 1" >> include/bits/uClibc_config.h ; \
196 echo "#undef NO_UNDERSCORES" >> include/bits/uClibc_config.h ; \
198 @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
199 echo "#define __UCLIBC_HAS_RPC__ 1" >> include/bits/uClibc_config.h ; \
201 echo "#undef __UCLIBC_HAS_RPC__" >> include/bits/uClibc_config.h ; \
203 @if [ "$(UNIFIED_SYSCALL)" = "true" ] ; then \
204 echo "#define __UCLIBC_USE_UNIFIED_SYSCALL__ 1" >> include/bits/uClibc_config.h ; \
206 echo "#undef __UCLIBC_USE_UNIFIED_SYSCALL__" >> include/bits/uClibc_config.h ; \
208 @echo "#define C_SYMBOL_PREFIX "\""$(C_SYMBOL_PREFIX)"\" >> include/bits/uClibc_config.h
209 @if [ "$(DOLFS)" = "true" ] ; then \
210 echo "#define __UCLIBC_HAVE_LFS__ 1" >> include/bits/uClibc_config.h ; \
212 echo "#undef __UCLIBC_HAVE_LFS__" >> include/bits/uClibc_config.h ; \
214 @if [ "$(INCLUDE_THREADS)" = "true" ] ; then \
215 echo "#define __UCLIBC_HAS_THREADS__ 1" >> include/bits/uClibc_config.h ; \
217 echo "#undef __UCLIBC_HAS_THREADS__" >> include/bits/uClibc_config.h ; \
219 @if [ "$(INCLUDE_REGEX)" = "true" ] ; then \
220 echo "#define __UCLIBC_HAS_REGEX__ 1" >> include/bits/uClibc_config.h ; \
222 echo "#undef __UCLIBC_HAS_REGEX__" >> include/bits/uClibc_config.h ; \
224 @if [ "$(UNIX98PTY_ONLY)" = "true" ] ; then \
225 echo "#define UNIX98PTY_ONLY 1" >> include/bits/uClibc_config.h ; \
227 echo "#undef UNIX98PTY_ONLY" >> include/bits/uClibc_config.h ; \
229 @if [ "$(ASSUME_DEVPTS)" = "true" ] ; then \
230 echo "#define ASSUME_DEVPTS 1" >> include/bits/uClibc_config.h ; \
232 echo "#undef ASSUME_DEVPTS" >> include/bits/uClibc_config.h ; \
235 subdirs: $(patsubst %, _dir_%, $(DIRS))
237 $(patsubst %, _dir_%, $(DIRS)) : dummy
238 $(MAKE) -C $(patsubst _dir_%, %, $@)
243 install: install_dev install_runtime install_toolchain install_utils finished2
246 # Installs header files and development library links.
248 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
249 install -d $(PREFIX)$(DEVEL_PREFIX)/usr/lib
250 install -d $(PREFIX)$(DEVEL_PREFIX)/include
251 -install -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)/lib/
252 tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
253 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
254 chmod -f 755 $$i; chmod -f 644 $$i/*.h; \
256 -find $(PREFIX)$(DEVEL_PREFIX) -name CVS | xargs rm -rf;
257 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
258 ifeq ($(strip $(HAVE_SHARED)),true)
259 -find lib/ -type l -name '*.so' -exec cp -a {} $(PREFIX)$(DEVEL_PREFIX)/lib ';'
263 # Installs run-time libraries and helper apps onto the host system
264 # allowing cross development. If you want to deploy to a target
265 # system, use the "install_target" target instead...
267 ifeq ($(strip $(HAVE_SHARED)),true)
268 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
269 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
270 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
271 $(PREFIX)$(DEVEL_PREFIX)/lib
272 cp -a lib/*.so.* $(PREFIX)$(DEVEL_PREFIX)/lib
273 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
275 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
276 $(PREFIX)$(DEVEL_PREFIX)/lib; \
277 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
278 ln -s $(DEVEL_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
279 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
284 install -d $(PREFIX)$(DEVEL_PREFIX)/lib
285 install -d $(PREFIX)$(DEVEL_PREFIX)/bin
286 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
287 install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
288 $(MAKE) -C extra/gcc-uClibc install
291 ifeq ($(strip $(HAVE_SHARED)),true)
292 @$(MAKE) -C ldso utils
293 install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
294 install -m 755 ldso/util/ldd \
295 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd
296 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldd \
297 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldd
298 # For now, don't bother with readelf since surely the host
299 # system has binutils, or we couldn't have gotten this far...
300 #install -m 755 ldso/util/readelf \
301 # $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf
302 #ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-readelf \
303 # $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/readelf
304 @if [ -x ldso/util/ldconfig ] ; then \
306 install -d $(PREFIX)$(DEVEL_PREFIX)/etc; \
307 install -m 755 ldso/util/ldconfig \
308 $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig; \
309 ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ldconfig \
310 $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ldconfig; \
314 # Installs run-time libraries and helper apps in preparation for
315 # deploying onto a target system, but installed below wherever
316 # $PREFIX is set to, allowing you to package up the result for
317 # deployment onto your target system.
319 ifeq ($(strip $(HAVE_SHARED)),true)
320 install -d $(PREFIX)$(TARGET_PREFIX)/lib
321 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin
322 install -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
323 $(PREFIX)$(TARGET_PREFIX)/lib
324 cp -a lib/*.so.* $(PREFIX)$(TARGET_PREFIX)/lib
325 @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
327 install -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
328 $(PREFIX)$(TARGET_PREFIX)/lib; \
329 mkdir -p $(PREFIX)$(SHARED_LIB_LOADER_PATH); \
330 ln -s $(TARGET_PREFIX)/lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
331 $(PREFIX)$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO) || true; \
335 install_target_utils:
336 ifeq ($(strip $(HAVE_SHARED)),true)
337 @$(MAKE) -C ldso/util ldd.target readelf.target #ldconfig.target
338 install -d $(PREFIX)$(TARGET_PREFIX)/usr/bin;
339 install -m 755 ldso/util/ldd.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/ldd
340 install -m 755 ldso/util/readelf.target $(PREFIX)$(TARGET_PREFIX)/usr/bin/readelf
341 @if [ -x ldso/util/ldconfig.target ] ; then \
343 install -d $(PREFIX)$(TARGET_PREFIX)/etc; \
344 install -d $(PREFIX)$(TARGET_PREFIX)/sbin; \
345 install -m 755 ldso/util/ldconfig.target $(PREFIX)$(TARGET_PREFIX)/sbin/ldconfig; \
351 @echo Finished installing...
356 - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec rm -f {} \;
357 @rm -rf tmp lib include/bits libc/tmp _install
358 $(MAKE) -C test clean
359 $(MAKE) -C ldso clean
360 $(MAKE) -C libc/misc/internals clean
361 $(MAKE) -C libc/unistd clean
362 $(MAKE) -C libc/sysdeps/linux/common clean
363 $(MAKE) -C extra/gcc-uClibc clean
365 for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
366 rm -f include/sys/$$i; \
368 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
369 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
370 rm -f include/sys/$$i; \
373 @rm -f include/linux include/scsi include/asm
374 @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then \
375 $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean; \
377 @if [ $(TARGET_ARCH) = "mipsel" ]; then \
378 rm -f libc/sysdeps/linux/$(TARGET_ARCH); \
379 rm -f ldso/ldso/$(TARGET_ARCH); \
380 rm -f libpthread/linuxthreads/sysdeps/$(TARGET_ARCH); \
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