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 = extra misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd
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) -Wl,-soname,$(SHARED_NAME) -Wl,--whole-archive ./libc.a ./tmp/libgcc-need.a ; \
52 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_NAME) -Wl,-soname,$(SHARED_NAME) -Wl,--whole-archive ./libc.a ; \
56 done: $(STATIC_NAME) $(DO_SHARED)
58 @echo Finally finished compiling...
62 @rm -f $(STATIC_NAME) $(SHARED_NAME) crt0.o uClibc_config.h
65 @rm -f include/asm include/linux include/bits
66 @ln -s $(KERNEL_SOURCE)/include/asm include/asm
67 @if [ ! -f include/asm/unistd.h ] ; then \
69 echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
70 echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
71 echo "correctly. Please edit \`Config' and fix these settings."; \
75 @if [ $(HAS_MMU) != "true" ] && [ $(TARGET_ARCH) = "i386" ] ; then \
76 echo "WARNING: I bet your x86 system really has an MMU, right?"; \
77 echo " malloc and friends won't work unless you fix \`Config'"; \
81 @ln -s $(KERNEL_SOURCE)/include/linux include/linux
82 @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
83 @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
91 rm -f $(STATIC_NAME) crt0.o $(SHARED_NAME) uClibc_config.h
92 rm -f include/asm include/linux include/bits
94 subdirs: $(patsubst %, _dir_%, $(DIRS))
95 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
97 $(patsubst %, _dir_%, $(DIRS)) : dummy
98 $(MAKE) -C $(patsubst _dir_%, %, $@)
100 $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
101 $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
104 @if [ `id -u` -ne 0 ]; then \
105 echo "Aborting install -- You must be root."; \
108 @if [ -n "$(DO_SHARED)" ] ; then \
110 mv -f $(INSTALL_DIR)/lib/$(SHARED_NAME) \
111 $(INSTALL_DIR)/lib/$(SHARED_NAME).old > /dev/null 2>&1; \
112 rm -f $(INSTALL_DIR)/lib/$(SHARED_NAME).old; \
113 cp $(SHARED_NAME) $(INSTALL_DIR)/lib; \
114 chmod 644 $(INSTALL_DIR)/lib/$(SHARED_NAME); \
115 chown -R root.root $(INSTALL_DIR)/lib/$(SHARED_NAME); \
116 rm -f $(INSTALL_DIR)/lib/libuClibc.so; \
117 ln -s $(INSTALL_DIR)/lib/$(SHARED_NAME) \
118 $(INSTALL_DIR)/lib/libuClibc.so; \
121 @if [ "$(HAS_MMU)" = "false" ] ; then \
123 rm -f $(INSTALL_DIR)/include/asm; \
124 rm -f $(INSTALL_DIR)/include/linux; \
125 mkdir -p $(INSTALL_DIR)/include/bits; \
126 ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm; \
127 ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux; \
128 find include/ -type f -depth -print | cpio -pdmu $(INSTALL_DIR); \
129 find include/bits/ -depth -print | cpio -pdmu $(INSTALL_DIR); \
130 rm -f $(INSTALL_DIR)/lib/$(STATIC_NAME); \
131 cp $(STATIC_NAME) $(INSTALL_DIR)/lib; \
132 chmod 644 $(INSTALL_DIR)/lib/$(STATIC_NAME); \
133 chown -R root.root $(INSTALL_DIR)/lib/$(STATIC_NAME); \
134 if [ -f crt0.o ] ; then \
135 rm -f $(INSTALL_DIR)/lib/crt0.o; \
136 cp crt0.o $(INSTALL_DIR)/lib ; \
137 chmod 644 $(INSTALL_DIR)/lib/crt0.o; \
138 chown -R root.root $(INSTALL_DIR)/lib/crt0.o; \
140 chmod -R 775 `find $(INSTALL_DIR)/include -type d`; \
141 chmod -R 644 `find $(INSTALL_DIR)/include -type f`; \
142 chown -R root.root $(INSTALL_DIR)/include; \
145 uClibc_config.h: Config
146 @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
147 @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
148 @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
149 @echo "#endif" >> uClibc_config.h
150 @if [ "$(HAS_MMU)" = "true" ] ; then \
151 echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
153 echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
155 @if [ "$(HAS_FLOATS)" = "true" ] ; then \
156 echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
158 echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
160 @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
161 echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
163 echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
165 @if [ "$(HAS_LOCALE)" = "true" ] ; then \
166 echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
167 echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
169 echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
171 @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
172 echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
173 echo "#define const" >> uClibc_config.h ; \
174 echo "#define __const" >> uClibc_config.h ; \
175 echo "#define __extension" >> uClibc_config.h ; \
177 echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
179 @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
180 echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
182 echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \