OSDN Git Service

0f5cde117fdaab2bf7cfc92650146a40b6bac771
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000, 2001 by Lineo, inc.
4 # Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Library General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option) any
9 # later version.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Library General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
21 # other sundry sources.  Files within this library are copyright by their
22 # respective copyright holders.
23
24 #--------------------------------------------------------
25 #
26 #There are a number of configurable options in "Config"
27 #
28 #--------------------------------------------------------
29
30 TOPDIR=./
31 include Rules.mak
32
33 ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
34     LDSO_DIR = ldso
35 endif
36 DIRS = extra $(LDSO_DIR) libc libcrypt libresolv libutil libm  
37
38 ifndef $(TARGET_PREFIX)
39         TARGET_PREFIX = `pwd`/_install
40 endif
41
42 all: headers uClibc_config.h subdirs $(DO_SHARED) done
43
44 shared:
45         @$(MAKE) -C libc shared
46 ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
47         @$(MAKE) -C ldso shared
48 endif
49         @$(MAKE) -C libcrypt shared
50         @$(MAKE) -C libutil shared
51         @$(MAKE) -C libm shared
52
53 done: $(DO_SHARED)
54         @echo
55         @echo Finally finished compiling...
56         @echo
57
58 headers: dummy
59         @rm -f include/asm include/linux include/bits
60         @ln -s $(KERNEL_SOURCE)/include/asm include/asm
61         @if [ ! -f include/asm/unistd.h ] ; then \
62             echo " "; \
63             echo "The path '$(KERNEL_SOURCE)/include/asm' doesn't exist."; \
64             echo "I bet you didn't set KERNEL_SOURCE, TARGET_ARCH or HAS_MMU in \`Config'"; \
65             echo "correctly.  Please edit \`Config' and fix these settings."; \
66             echo " "; \
67             /bin/false; \
68         fi;
69         @if [ $(HAS_MMU) != "true" ]  && [ $(TARGET_ARCH) = "i386" ] ; then \
70             echo "WARNING: I bet your x86 system really has an MMU, right?"; \
71             echo "         malloc and friends won't work unless you fix \`Config'"; \
72             echo " "; \
73             sleep 10; \
74         fi;
75         @ln -s $(KERNEL_SOURCE)/include/linux include/linux
76         @ln -s ../libc/sysdeps/linux/$(TARGET_ARCH)/bits include/bits
77         (cd include/bits; ln -sf ../../../../../uClibc_config.h uClibc_config.h)
78         make -C libc/sysdeps/linux/$(TARGET_ARCH) headers
79
80 uClibc_config.h: Config
81         @echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" > uClibc_config.h
82         @echo "#if !defined __FEATURES_H && !defined __need_uClibc_config_h" >> uClibc_config.h
83         @echo "#error Never include <bits/uClibc_config.h> directly; use <features.h> instead." >> uClibc_config.h
84         @echo "#endif" >> uClibc_config.h
85         @echo "#define linux 1" >> uClibc_config.h 
86         @echo "#define __linux__ 1" >> uClibc_config.h 
87         @if [ "$(HAS_MMU)" = "true" ] ; then \
88             echo "#define __UCLIBC_HAS_MMU__ 1" >> uClibc_config.h ; \
89         else \
90             echo "#undef __UCLIBC_HAS_MMU__" >> uClibc_config.h ; \
91         fi
92         @if [ "$(HAS_FLOATING_POINT)" = "true" ] ; then \
93             echo "#define __UCLIBC_HAS_FLOATS__ 1" >> uClibc_config.h ; \
94         else \
95             echo "#undef __UCLIBC_HAS_FLOATS__" >> uClibc_config.h ; \
96         fi
97         @if [ "$(HAS_LIBM_FLOAT)" = "true" ] ; then \
98             echo "#define __UCLIBC_HAS_LIBM_FLOAT__ 1" >> uClibc_config.h ; \
99         else \
100             echo "#undef __UCLIBC_HAS_LIBM_FLOAT__" >> uClibc_config.h ; \
101         fi
102         @if [ "$(HAS_LIBM_DOUBLE)" = "true" ] ; then \
103             echo "#define __UCLIBC_HAS_LIBM_DOUBLE__ 1" >> uClibc_config.h ; \
104         else \
105             echo "#undef __UCLIBC_HAS_LIBM_DOUBLE__" >> uClibc_config.h ; \
106         fi
107         @if [ "$(HAS_LIBM_LONG_DOUBLE)" = "true" ] ; then \
108             echo "#define __UCLIBC_HAS_LIBM_LONG_DOUBLE__ 1" >> uClibc_config.h ; \
109         else \
110             echo "#undef __UCLIBC_HAS_LIBM_LONG_DOUBLE__" >> uClibc_config.h ; \
111         fi
112         @if [ "$(HAS_LONG_LONG)" = "true" ] ; then \
113             echo "#define __UCLIBC_HAS_LONG_LONG__ 1" >> uClibc_config.h ; \
114         else \
115             echo "#undef __UCLIBC_HAS_LONG_LONG__" >> uClibc_config.h ; \
116         fi
117         @if [ "$(HAS_LOCALE)" = "true" ] ; then \
118             echo "#define __UCLIBC_HAS_LOCALE__ 1" >> uClibc_config.h ; \
119             echo "#define __UCLIBC_LOCALE_DIR \""$(LOCALE_DIR)"\"" >> uClibc_config.h ; \
120         else \
121             echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
122         fi
123         @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
124             echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
125             if [ `expr match "$(CC)" ".*\(m68k-elf-.*\)"`x = x ]; then \
126                 echo "#define const" >> uClibc_config.h ; \
127                 echo "#define __const" >> uClibc_config.h ; \
128                 echo "#define __extension" >> uClibc_config.h ; \
129             fi; \
130         else \
131             echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
132         fi
133         @if [ "$(TARGET_ARCH)" = "sh" ] ; then \
134             echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
135         else \
136             echo "#undef NO_UNDERSCORES" >> uClibc_config.h ; \
137         fi
138         @if [ "$(INCLUDE_RPC)" = "true" ] ; then \
139             echo "#define __UCLIBC_HAS_RPC__ 1" >> uClibc_config.h ; \
140         else \
141             echo "#undef __UCLIBC_HAS_RPC__" >> uClibc_config.h ; \
142         fi
143
144 subdirs: $(patsubst %, _dir_%, $(DIRS))
145
146 $(patsubst %, _dir_%, $(DIRS)) : dummy
147         $(MAKE) -C $(patsubst _dir_%, %, $@)
148
149 tags:
150         ctags -R
151
152 install: install_dev
153
154 # Installs shared libraries for a target.
155 install_target:
156 ifeq ($(DO_SHARED),shared)
157         install -d $(TARGET_PREFIX)$(ROOT_DIR)/lib
158         cp -fa lib/*.so* $(TARGET_PREFIX)$(ROOT_DIR)/lib;
159 endif
160 ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
161         install -d $(TARGET_PREFIX)$(ROOT_DIR)/etc
162         install -d $(TARGET_PREFIX)$(ROOT_DIR)/sbin
163         install -d $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
164         cp -f ldso/util/ldd $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
165         cp -f ldso/util/ldconfig $(TARGET_PREFIX)$(ROOT_DIR)/sbin
166 #       -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
167 endif
168
169 # Installs development library and headers
170 # This is done with the assumption that it can blow away anything
171 # in $(DEVEL_PREFIX)$(ROOT_DIR)/include.  Probably true only if you're using
172 # a packaging system.
173 install_dev:
174 ifeq ($(DO_SHARED),shared)
175         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/lib
176         cp -fa lib/*.so* $(DEVEL_PREFIX)$(ROOT_DIR)/lib;
177 endif
178         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib
179         cp -fa lib/*.[ao] $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib;
180 ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
181         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
182         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
183         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
184         cp -f ldso/util/ldd $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
185         cp -f ldso/util/ldconfig $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
186 #       -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
187 endif
188         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
189         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include
190         install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits
191         rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm
192         rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux
193         ln -s $(KERNEL_SOURCE)/include/asm $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm
194         ln -s $(KERNEL_SOURCE)/include/linux $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux
195         find include/ -type f -depth -not -path "*CVS*" -exec install \
196             -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';'
197         find include/bits/ -type f -depth -not -path "*CVS*" -exec install \
198             -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';'
199         install -m 644 include/bits/uClibc_config.h $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits/
200         $(MAKE) -C extra/gcc-uClibc install
201
202 clean:
203         @rm -rf tmp lib
204         - find include -type l -exec rm -f {} \;
205         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core \) -exec rm -f {} \;
206 ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
207         make -C ldso clean
208 endif
209
210 .PHONY: dummy subdirs
211