3 # Copyright (C) 2000 by Lineo, inc.
5 # This program is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Library General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option) any
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
15 # You should have received a copy of the GNU Library General Public License
16 # along with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
20 # other sundry sources. Files within this library are copyright by their
21 # respective copyright holders.
23 #--------------------------------------------------------
25 #There are a number of configurable options in "Config"
27 #--------------------------------------------------------
31 DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd extra
33 ifeq ($(strip $(HAS_MMU)),true)
37 all: $(LIBNAME) $(DO_SHARED) done
39 $(LIBNAME): halfclean headers uClibc_config.h subdirs
40 $(CROSS)ranlib $(LIBNAME)
45 @(cd tmp; CC=$(CC) /bin/sh ../extra/scripts/get-needed-libgcc-objects.sh)
46 if [ -s ./tmp/libgcc-need.a ] ; then \
47 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
48 -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
49 ./$(LIBNAME) ./tmp/libgcc-need.a \
50 ld.so-1/d-link/ld-linux-uclibc.so.0; \
52 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
53 -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
54 ./$(LIBNAME) ld.so-1/d-link/ld-linux-uclibc.so.0; \
57 ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME)
58 ln -sf $(SHARED_MAJORNAME) libc.so
61 done: $(LIBNAME) $(DO_SHARED)
63 @echo Finally finished compiling...
67 @rm -f $(LIBNAME) crt0.o uClibc_config.h
68 @rm -f $(SHARED_FULLNAME) $(SHARED_MAJORNAME) libc.so
71 @rm -f include/asm include/linux include/bits
72 @ln -s $(KERNEL_SOURCE)/include/asm include/asm
73 @if [ ! -f include/asm/unistd.h ] ; then \
75 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
76 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
77 echo "correctly. Please edit \`Config' and fix these settings."; \
81 @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
82 echo "WARNING: I bet your x86 system really has an MMU, right?"; \
83 echo " malloc and friends won't work unless you fix \`Config'"; \
87 @ln -s $(KERNEL_SOURCE)/include/linux include/linux
88 @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
89 @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
95 clean: subdirs_clean halfclean
97 rm -f include/asm include/linux include/bits
98 @make -C ld.so-1 clean
100 subdirs: $(patsubst %, _dir_%, $(DIRS))
101 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
103 $(patsubst %, _dir_%, $(DIRS)) : dummy
104 $(MAKE) -C $(patsubst _dir_%, %, $@)
106 $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
107 $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
109 install: install_runtime install_dev install_ldso
111 # Installs shared library
113 ifneq ($(DO_SHARED),)
114 install -d $(INSTALL_DIR)/lib
115 rm -rf $(INSTALL_DIR)/lib/$(SHARED_FULLNAME)
116 rm -rf $(INSTALL_DIR)/lib/$(SHARED_MAJORNAME)
117 rm -rf $(INSTALL_DIR)/lib/libc.so
118 install -m 644 $(SHARED_FULLNAME) $(INSTALL_DIR)/lib/
119 (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME))
120 (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_MAJORNAME) libc.so)
121 # ldconfig is really not necessary, and impossible to cross
122 #ifeq ($(INSTALL_DIR),)
123 # /sbin/ldconfig -n $(INSTALL_DIR)/lib
126 echo shared library not installed
129 # Installs development library and headers
130 # This is done with the assumption that it can blow away anything
131 # in $(INSTALL_DIR)/include. Probably true only if you're using
132 # a packaging system.
134 install -d $(INSTALL_DIR)/include
135 install -d $(INSTALL_DIR)/include/bits
136 rm -f $(INSTALL_DIR)/include/asm
137 rm -f $(INSTALL_DIR)/include/linux
138 ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm
139 ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux
140 find include/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
141 find include/bits/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
142 install -m 644 include/bits/uClibc_config.h $(INSTALL_DIR)/include/bits/
143 install -d $(INSTALL_DIR)/lib
144 rm -f $(INSTALL_DIR)/lib/$(LIBNAME)
145 install -m 644 $(LIBNAME) $(INSTALL_DIR)/lib/
146 @if [ -f crt0.o ] ; then install -m 644 crt0.o $(INSTALL_DIR)/lib/; fi
147 install -d $(INSTALL_DIR)/bin
148 @if [ -f extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc ] ; then install -m 755 extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/ ; fi
152 ifeq ($(strip $(DO_SHARED)),shared)
153 @make -C ld.so-1 install
155 @echo "Skipping shared library support"
158 uClibc_config.h: Config
159 @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
160 @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
161 @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
162 @echo "#endif" >> uClibc_config.h
163 @echo "#define linux 1" >> uClibc_config.h
164 @echo "#define __linux__ 1" >> uClibc_config.h
165 @if [ "$(HAS_MMU)" = "true" ] ; then \
166 echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
168 echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
170 @if [ "$(HAS_FLOATS)" = "true" ] ; then \
171 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
173 echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
175 @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
176 echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
178 echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
180 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
181 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
182 echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
184 echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
186 @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
187 echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
188 if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
189 echo "#define const" >> uClibc_config.h ; \
190 echo "#define __const" >> uClibc_config.h ; \
191 echo "#define __extension" >> uClibc_config.h ; \
194 echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
196 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
197 echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
199 echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \