OSDN Git Service

Fix up breakage resulting from flipping the sense of some defines. Change from
[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
32 DIRS = extra misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd
33
34 ifeq ($(strip $(HAS_MMU)),true)
35         DO_SHARED=shared
36 endif
37
38 all: $(STATIC_NAME) $(DO_SHARED) done
39
40 $(STATIC_NAME): halfclean headers uClibc_config.h subdirs
41         $(CROSS)ranlib $(STATIC_NAME)
42
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)
46         @rm -rf tmp
47         @mkdir tmp
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 ; \
51         else \
52                 $(CC) -g $(LDFLAGS) -shared -o $(SHARED_NAME) -Wl,-soname,$(SHARED_NAME) -Wl,--whole-archive ./libc.a ; \
53         fi
54         @rm -rf tmp
55
56 done: $(STATIC_NAME) $(DO_SHARED)
57         @echo
58         @echo Finally finished compiling...
59         @echo
60
61 halfclean:
62         @rm -f $(STATIC_NAME) $(SHARED_NAME) crt0.o uClibc_config.h
63
64 headers: dummy
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 \
68             echo " "; \
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."; \
72             echo " "; \
73             /bin/false; \
74         fi;
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'"; \
78             echo " "; \
79             sleep 10; \
80         fi;
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
84
85
86 tags:
87         ctags -R
88
89 clean: subdirs_clean
90         @rm -rf tmp
91         rm -f $(STATIC_NAME) crt0.o $(SHARED_NAME) uClibc_config.h
92         rm -f include/asm include/linux include/bits
93
94 subdirs: $(patsubst %, _dir_%, $(DIRS))
95 subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS) test)
96
97 $(patsubst %, _dir_%, $(DIRS)) : dummy
98         $(MAKE) -C $(patsubst _dir_%, %, $@)
99
100 $(patsubst %, _dirclean_%, $(DIRS) test) : dummy
101         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
102
103 install:
104         @if [ `id -u` -ne 0 ]; then \
105             echo "Aborting install -- You must be root."; \
106             /bin/false; \
107         fi;
108         @if [ -n "$(DO_SHARED)" ] ; then \
109             set -x; \
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; \
119             ldconfig; \
120         fi;
121         @if [ "$(HAS_MMU)" = "false" ] ; then \
122             set -x; \
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; \
139             fi; \
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; \
143         fi;
144
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 ; \
152         else \
153             echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
154         fi
155         @if [ "$(HAS_FLOATS)" = "true" ] ; then \
156             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
157         else \
158             echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
159         fi
160         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
161             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
162         else \
163             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
164         fi
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 ; \
168         else \
169             echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
170         fi
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 ; \
176         else \
177             echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
178         fi
179         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
180             echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
181         else \
182             echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
183         fi
184
185 .PHONY: dummy
186