OSDN Git Service

Fix up compiler name
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 #
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
8 # later version.
9 #
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
13 # details.
14 #
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
18 #
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.
22
23 #--------------------------------------------------------
24 #
25 #There are a number of configurable options in "Config"
26 #
27 #--------------------------------------------------------
28
29 include Rules.mak
30
31 DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd extra
32
33 ifeq ($(strip $(HAS_MMU)),true)
34         DO_SHARED=shared
35 endif
36
37 all: libc.a $(DO_SHARED) done
38
39 libc.a: halfclean headers uClibc_config.h subdirs
40         $(CROSS)ranlib libc.a
41
42 shared: libc.a
43         @rm -rf tmp
44         @mkdir tmp
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                     ./libc.a ./tmp/libgcc-need.a ; \
50         else \
51                 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_FULLNAME) \
52                     -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
53                     ./libc.a ; \
54         fi
55         @rm -rf tmp
56         ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME)
57         ln -sf $(SHARED_MAJORNAME) libc.so
58
59 done: libc.a $(DO_SHARED)
60         @echo
61         @echo Finally finished compiling...
62         @echo
63
64 halfclean:
65         @rm -f libc.a crt0.o uClibc_config.h
66         @rm -f $(SHARED_FULLNAME) $(SHARED_MAJORNAME) libc.so
67
68 headers: dummy
69         @rm -f include/asm include/linux include/bits
70         @ln -s $(KERNEL_SOURCE)/include/asm include/asm
71         @if [ ! -f include/asm/unistd.h ] ; then \
72             echo " "; \
73             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
74             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
75             echo "correctly.  Please edit \`Config' and fix these settings."; \
76             echo " "; \
77             /bin/false; \
78         fi;
79         @if [ $(HAS_MMU) != "true" ]  && [ $(TARGET_ARCH) = "i386" ] ; then \
80             echo "WARNING: I bet your x86 system really has an MMU, right?"; \
81             echo "         malloc and friends won't work unless you fix \`Config'"; \
82             echo " "; \
83             sleep 10; \
84         fi;
85         @ln -s $(KERNEL_SOURCE)/include/linux include/linux
86         @ln -s ../sysdeps/linux/$(TARGET_ARCH)/bits include/bits
87         @ln -sf ../../../../uClibc_config.h sysdeps/linux/$(TARGET_ARCH)/bits/uClibc_config.h
88
89
90 tags:
91         ctags -R
92
93 clean: subdirs_clean halfclean
94         @rm -rf tmp
95         rm -f include/asm include/linux include/bits
96
97 subdirs: $(patsubst %, _dir_%, $(DIRS))
98 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
99
100 $(patsubst %, _dir_%, $(DIRS)) : dummy
101         $(MAKE) -C $(patsubst _dir_%, %, $@)
102
103 $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
104         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
105
106 install_new: install_runtime install_dev
107
108 # Installs shared library
109 install_runtime:
110 ifneq ($(DO_SHARED),)
111         install -d $(INSTALL_DIR)/lib
112         install -m 644 $(SHARED_FULLNAME) $(INSTALL_DIR)/lib/
113         (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_FULLNAME) $(SHARED_MAJORNAME))
114         (cd $(INSTALL_DIR)/lib;ln -sf $(SHARED_MAJORNAME) libc.so)
115 # ldconfig is really not necessary, and impossible to cross
116 #ifeq ($(INSTALL_DIR),)
117 #       /sbin/ldconfig -n $(INSTALL_DIR)/lib
118 #endif
119 else
120         echo shared library not installed
121 endif
122
123 # Installs development library and headers
124 # This is done with the assumption that it can blow away anything
125 # in $(INSTALL_DIR)/include.  Probably true only if you're using
126 # a packaging system.
127 install_dev:
128         install -d $(INSTALL_DIR)/include
129         install -d $(INSTALL_DIR)/include/bits
130         rm -f $(INSTALL_DIR)/include/asm
131         rm -f $(INSTALL_DIR)/include/linux
132         ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm
133         ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux
134         find include/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
135         find include/bits/ -type f -depth -not -path "*CVS*" -exec install -D -m 644 {} $(INSTALL_DIR)/'{}' ';'
136         install -m 644 include/bits/uClibc_config.h $(INSTALL_DIR)/include/bits/
137         install -d $(INSTALL_DIR)/lib
138         rm -f $(INSTALL_DIR)/lib/libc.a
139         install -m 644 libc.a $(INSTALL_DIR)/lib/
140         @if [ -f crt0.o ] ; then install -m 644 crt0.o $(INSTALL_DIR)/lib/; fi
141         install -d $(INSTALL_DIR)/bin
142         @if [ -f extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc ] ; then install -m 755 extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/ ; fi
143
144 install:
145         echo Consider using 'make install_new'
146         @if [ `id -u` -ne 0 ]; then \
147             echo "Aborting install -- You must be root."; \
148             /bin/false; \
149         fi;
150         @if [ -n "$(DO_SHARED)" ] ; then \
151             set -x; \
152             mv -f $(INSTALL_DIR)/lib/$(SHARED_NAME) \
153                 $(INSTALL_DIR)/lib/$(SHARED_NAME).old > /dev/null 2>&1; \
154             rm -f $(INSTALL_DIR)/lib/$(SHARED_NAME).old; \
155             cp $(SHARED_NAME) $(INSTALL_DIR)/lib; \
156             chmod 644 $(INSTALL_DIR)/lib/$(SHARED_NAME); \
157             chown -R root.root $(INSTALL_DIR)/lib/$(SHARED_NAME); \
158             rm -f $(INSTALL_DIR)/lib/libc.so; \
159             ln -s $(INSTALL_DIR)/lib/$(SHARED_NAME) \
160                     $(INSTALL_DIR)/lib/libc.so; \
161             /sbin/ldconfig; \
162         fi;
163         @if [ "$(HAS_MMU)" = "false" ] ; then \
164             set -x; \
165             rm -f $(INSTALL_DIR)/include/asm; \
166             rm -f $(INSTALL_DIR)/include/linux; \
167             mkdir -p $(INSTALL_DIR)/include/bits; \
168             ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/include/asm; \
169             ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/include/linux; \
170             find include/ -type f -depth -print | cpio -pdmu $(INSTALL_DIR); \
171             find include/bits/ -depth -print | cpio -pdmu $(INSTALL_DIR); \
172             rm -f $(INSTALL_DIR)/lib/libc.a; \
173             cp libc.a $(INSTALL_DIR)/lib; \
174             chmod 644 $(INSTALL_DIR)/lib/libc.a; \
175             chown -R root.root $(INSTALL_DIR)/lib/libc.a; \
176             if [ -f crt0.o ] ; then \
177                 rm -f $(INSTALL_DIR)/lib/crt0.o; \
178                 cp crt0.o $(INSTALL_DIR)/lib ; \
179                 chmod 644 $(INSTALL_DIR)/lib/crt0.o; \
180                 chown -R root.root $(INSTALL_DIR)/lib/crt0.o; \
181             fi; \
182             chmod -R 775 `find $(INSTALL_DIR)/include -type d`; \
183             chmod -R 644 `find $(INSTALL_DIR)/include -type f`; \
184             chown -R root.root $(INSTALL_DIR)/include; \
185         fi;
186
187 uClibc_config.h: Config
188         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
189         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
190         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
191         @echo "#endif" >> uClibc_config.h
192         @echo "#define linux 1" >> uClibc_config.h 
193         @echo "#define __linux__ 1" >> uClibc_config.h 
194         @if [ "$(HAS_MMU)" = "true" ] ; then \
195             echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
196         else \
197             echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
198         fi
199         @if [ "$(HAS_FLOATS)" = "true" ] ; then \
200             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
201         else \
202             echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
203         fi
204         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
205             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
206         else \
207             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
208         fi
209         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
210             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
211             echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
212         else \
213             echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
214         fi
215         @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
216             echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
217             if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
218                 echo "#define const" >> uClibc_config.h ; \
219                 echo "#define __const" >> uClibc_config.h ; \
220                 echo "#define __extension" >> uClibc_config.h ; \
221             fi; \
222         else \
223             echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
224         fi
225         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
226             echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
227         else \
228             echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
229         fi
230
231 .PHONY: dummy
232