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 #--------------------------------------------------------
32 DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd extra
34 ifeq ($(strip $(HAS_MMU)),true)
38 all: $(STATIC_NAME) $(DO_SHARED) done
40 $(STATIC_NAME): halfclean headers uClibc_config.h subdirs
41 $(CROSS)ranlib $(STATIC_NAME)
43 # Surely there is a better way to do this then dumping all
44 # the objects into a tmp dir. Please -- someone enlighten me.
45 shared: $(STATIC_NAME)
48 @(cd tmp; CC=$(CC) /bin/sh ../extra/scripts/get-needed-libgcc-objects.sh)
49 if [ -s ./tmp/libgcc-need.a ] ; then \
50 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_NAME) \
51 -Wl,-soname,$(SHARED_NAME) -Wl,--whole-archive \
52 ./libc.a ./tmp/libgcc-need.a ; \
54 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_NAME) \
55 -Wl,-soname,$(SHARED_NAME) -Wl,--whole-archive ./libc.a ; \
59 done: $(STATIC_NAME) $(DO_SHARED)
61 @echo Finally finished compiling...
65 @rm -f $(STATIC_NAME) $(SHARED_NAME) crt0.o uClibc_config.h
68 @rm -f include/asm include/linux include/bits
69 @ln -s $(KERNEL_SOURCE)/include/asm include/asm
70 @if [ ! -f include/asm/unistd.h ] ; then \
72 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
73 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
74 echo "correctly. Please edit \`Config' and fix these settings."; \
78 @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
79 echo "WARNING: I bet your x86 system really has an MMU, right?"; \
80 echo " malloc and friends won't work unless you fix \`Config'"; \
84 @ln -s $(KERNEL_SOURCE)/include/linux include/linux
85 @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
86 @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
94 rm -f $(STATIC_NAME) crt0.o $(SHARED_NAME) uClibc_config.h
95 rm -f include/asm include/linux include/bits
97 subdirs: $(patsubst %, _dir_%, $(DIRS))
98 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
100 $(patsubst %, _dir_%, $(DIRS)) : dummy
101 $(MAKE) -C $(patsubst _dir_%, %, $@)
103 $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
104 $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
106 install_new: install_runtime install_dev
108 # Installs shared library
110 ifneq ($(DO_SHARED),)
111 install -d $(INSTALL_DIR)/lib
112 install -m 644 $(SHARED_NAME) $(INSTALL_DIR)/lib/
113 (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_NAME) libuClibc.so)
114 # ldconfig is really not necessary, and impossible to cross
115 ifeq ($(INSTALL_DIR),)
116 /sbin/ldconfig -n $(INSTALL_DIR)/lib
119 echo shared library not installed
122 # Installs development library and headers
123 # This is done with the assumption that it can blow away anything
124 # in $(INSTALL_DIR)/include. Probably true only if you're using
125 # a packaging system.
127 install -d $(INSTALL_DIR)/include
128 install -d $(INSTALL_DIR)/include/bits
129 rm -f $(INSTALL_DIR)/include/asm
130 rm -f $(INSTALL_DIR)/include/linux
131 ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm
132 ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux
133 find include/ -type f -depth -exec install -m 644 {} $(INSTALL_DIR)/include/ ';'
134 find include/bits/ -type f -depth -exec install -m 644 {} $(INSTALL_DIR)/include/bits/ ';'
135 install -d $(INSTALL_DIR)/lib
136 rm -f $(INSTALL_DIR)/lib/$(STATIC_NAME)
137 install -m 644 $(STATIC_NAME) $(INSTALL_DIR)/lib/
138 @if [ -f crt0.o ] ; then install -m 644 crt0.o $(INSTALL_DIR)/lib/; fi
141 echo Consider using 'make install_new'
142 @if [ `id -u` -ne 0 ]; then \
143 echo "Aborting install -- You must be root."; \
146 @if [ -n "$(DO_SHARED)" ] ; then \
148 mv -f $(INSTALL_DIR)/lib/$(SHARED_NAME) \
149 $(INSTALL_DIR)/lib/$(SHARED_NAME).old > /dev/null 2>&1; \
150 rm -f $(INSTALL_DIR)/lib/$(SHARED_NAME).old; \
151 cp $(SHARED_NAME) $(INSTALL_DIR)/lib; \
152 chmod 644 $(INSTALL_DIR)/lib/$(SHARED_NAME); \
153 chown -R root.root $(INSTALL_DIR)/lib/$(SHARED_NAME); \
154 rm -f $(INSTALL_DIR)/lib/libuClibc.so; \
155 ln -s $(INSTALL_DIR)/lib/$(SHARED_NAME) \
156 $(INSTALL_DIR)/lib/libuClibc.so; \
159 @if [ "$(HAS_MMU)" = "false" ] ; then \
161 rm -f $(INSTALL_DIR)/include/asm; \
162 rm -f $(INSTALL_DIR)/include/linux; \
163 mkdir -p $(INSTALL_DIR)/include/bits; \
164 ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm; \
165 ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux; \
166 find include/ -type f -depth -print | cpio -pdmu $(INSTALL_DIR); \
167 find include/bits/ -depth -print | cpio -pdmu $(INSTALL_DIR); \
168 rm -f $(INSTALL_DIR)/lib/$(STATIC_NAME); \
169 cp $(STATIC_NAME) $(INSTALL_DIR)/lib; \
170 chmod 644 $(INSTALL_DIR)/lib/$(STATIC_NAME); \
171 chown -R root.root $(INSTALL_DIR)/lib/$(STATIC_NAME); \
172 if [ -f crt0.o ] ; then \
173 rm -f $(INSTALL_DIR)/lib/crt0.o; \
174 cp crt0.o $(INSTALL_DIR)/lib ; \
175 chmod 644 $(INSTALL_DIR)/lib/crt0.o; \
176 chown -R root.root $(INSTALL_DIR)/lib/crt0.o; \
178 chmod -R 775 `find $(INSTALL_DIR)/include -type d`; \
179 chmod -R 644 `find $(INSTALL_DIR)/include -type f`; \
180 chown -R root.root $(INSTALL_DIR)/include; \
183 uClibc_config.h: Config
184 @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
185 @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
186 @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
187 @echo "#endif" >> uClibc_config.h
188 @echo "#define linux 1" >> uClibc_config.h
189 @echo "#define __linux__ 1" >> uClibc_config.h
190 @if [ "$(HAS_MMU)" = "true" ] ; then \
191 echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
193 echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
195 @if [ "$(HAS_FLOATS)" = "true" ] ; then \
196 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
198 echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
200 @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
201 echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
203 echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
205 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
206 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
207 echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
209 echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
211 @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
212 echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
213 if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
214 echo "#define const" >> uClibc_config.h ; \
215 echo "#define __const" >> uClibc_config.h ; \
216 echo "#define __extension" >> uClibc_config.h ; \
219 echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
221 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
222 echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
224 echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \