OSDN Git Service

Unlike the other static libs, libdl.a and libdl_pic.a are different.
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later
9 # version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Library General Public License for more details.
15 #
16 # You should have received a copy of the GNU Library General
17 # Public License along with this program; if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 # Boston, MA 02111-1307 USA
20
21
22 #--------------------------------------------------------------
23 # You shouldn't need to mess with anything beyond this point...
24 #--------------------------------------------------------------
25 noconfig_targets := menuconfig config oldconfig randconfig \
26         defconfig allyesconfig allnoconfig clean distclean \
27         release tags TAGS
28 TOPDIR=./
29 include Rules.mak
30
31 DIRS = ldso libc libcrypt libresolv libnsl libutil libm libpthread librt
32 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
33         DIRS += libintl
34 endif
35
36 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
37
38 all: headers pregen subdirs shared finished
39
40 # In this section, we need .config
41 -include .config.cmd
42
43 shared: subdirs
44 ifeq ($(strip $(HAVE_SHARED)),y)
45         @echo
46         @echo Building shared libraries ...
47         @echo
48         @$(MAKE) -C libc shared
49         @$(MAKE) -C ldso shared
50         @$(MAKE) -C libcrypt shared
51         @$(MAKE) -C libresolv shared
52         @$(MAKE) -C libnsl shared
53         @$(MAKE) -C libutil shared
54         @$(MAKE) -C libm shared
55         @$(MAKE) -C libpthread shared
56         @$(MAKE) -C librt shared
57 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
58         @$(MAKE) -C libintl shared
59 endif
60 else
61         @echo
62         @echo Not building shared libraries ...
63         @echo
64 endif
65
66 finished: shared
67         @echo
68         @echo Finally finished compiling ...
69         @echo
70
71 include/bits/uClibc_config.h: .config
72         @if [ ! -x ./extra/config/conf ] ; then \
73             $(MAKE) -C extra/config conf; \
74         fi;
75         $(RM) -r include/bits
76         $(INSTALL) -d include/bits
77         @./extra/config/conf -o extra/Configs/Config.in
78
79 # For the moment, we have to keep re-running this target 
80 # because the fix includes scripts rely on pre-processers 
81 # in order to generate the headers correctly :(.  That 
82 # means we can't use the $(HOSTCC) in order to get the 
83 # correct output.
84 headers: include/bits/uClibc_config.h
85 ifeq ($(strip $(ARCH_HAS_MMU)),y)
86         @set -x; ./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH)
87 else
88         @set -x; ./extra/scripts/fix_includes.sh -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) -n
89 endif
90         @cd include/bits; \
91         set -e; \
92         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
93                 $(LN) -fs $$i .; \
94         done; \
95         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
96                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
97                         $(LN) -fs $$i .; \
98                 done; \
99         fi
100         @cd include/sys; \
101         set -e; \
102         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
103                 $(LN) -fs $$i .; \
104         done; \
105         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
106                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
107                         $(LN) -fs $$i .; \
108                 done; \
109         fi
110         @cd $(TOPDIR); \
111         set -x -e; \
112         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
113         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
114                 $(RM) include/bits/sysnum.h.new; \
115         else \
116                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
117         fi
118         $(MAKE) -C libc/sysdeps/linux/common headers
119         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
120
121 # Command used to download source code
122 WGET:=wget --passive-ftp
123
124 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
125
126 pregen: headers
127 ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
128         (cd extra/locale; \
129         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
130         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
131         fi );
132 endif
133 ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
134         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
135         $(MAKE) -C extra/locale pregen
136 endif
137
138
139 subdirs: $(patsubst %, _dir_%, $(DIRS))
140 $(patsubst %, _dir_%, $(DIRS)): headers
141         $(MAKE) -C $(patsubst _dir_%, %, $@)
142
143 tags:
144         ctags -R
145
146 install: install_runtime install_dev finished2
147
148
149 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
150
151 # Installs header files and development library links.
152 install_dev:
153         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
154         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
155         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
156         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
157 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
158         # Remove floating point related headers since float support is disabled.
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
160         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
161         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
162         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
164 endif
165 ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
166         # Remove wide char headers since wide char support is disabled.
167         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
168         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
169 endif
170 ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
171         # Remove iconv header since locale support is disabled.
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
173 endif
174 ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
175         # Remove printf header since custom print specifier support is disabled.
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
177 endif
178 ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
179         # Remove xlocale header since extended locale support is disabled.
180         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
181 endif
182 ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
183         # Remove libintl header since gettext support is disabled.
184         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
185 endif
186 ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
187         # Remove regex headers since regex support is disabled.
188         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
189         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
190 endif
191 ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
192         # Remove wordexp header since wordexp support is disabled.
193         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
194 endif
195 ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
196         # Remove ftw header since ftw support is disabled.
197         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
198 endif
199 ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
200         # Remove glob header since glob support is disabled.
201         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
202 endif
203 ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
204         # Remove getopt header since gnu getopt support is disabled.
205         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
206 endif
207 ifneq ($(strip $(HAS_SHADOW)),y)
208         # Remove getopt header since shadow password support is disabled.
209         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
210 endif
211         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
212             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
213         done;
214         -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
215         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1.\2/'` $(PREFIX)$(DEVEL_PREFIX)
216 ifeq ($(strip $(HAVE_SHARED)),y)
217         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
218         sed -e 's/lib\///'` ; do \
219                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
220                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
221         done;
222 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
223         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
224                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
225 endif
226 #       # If we build shared libraries then the static libs are PIC...
227 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
228         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
229                 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
230                         | sed -e 's/\.a$$/_pic.a/'`; \
231         done;
232         # Ugh!!! Remember that libdl.a and libdl_pic.a are different!
233         rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
234         cp -f ldso/libdl/libdl_pic.a $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
235 endif
236
237
238 # Installs run-time libraries
239 install_runtime:
240 ifeq ($(strip $(HAVE_SHARED)),y)
241         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
242         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
243                 $(PREFIX)$(RUNTIME_PREFIX)lib
244         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
245         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
246             set -x -e; \
247             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
248                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
249         fi;
250 endif
251
252 .PHONY: utils
253 ifeq ($(strip $(HAVE_SHARED)),y)
254 utils:
255         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
256 else
257 utils: dummy
258 endif
259
260 # Installs helper applications, such as 'ldd' and 'ldconfig'
261 install_utils: utils
262         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
263 #ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
264 #       @$(MAKE) -C libc/misc/wchar iconv.target
265 #       $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
266 #       $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
267 #endif
268
269 finished2:
270         @echo
271         @echo Finished installing ...
272         @echo
273
274 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
275
276 all: menuconfig
277
278 # configuration
279 # ---------------------------------------------------------------------------
280 extra/config/conf:
281         $(MAKE) -C extra/config conf
282
283 extra/config/mconf:
284         $(MAKE) -C extra/config ncurses mconf
285
286 menuconfig: extra/config/mconf
287         $(RM) -r include/bits
288         $(INSTALL) -d include/bits
289         @./extra/config/mconf extra/Configs/Config.in
290
291 config: extra/config/conf
292         $(RM) -r include/bits
293         $(INSTALL) -d include/bits
294         @./extra/config/conf extra/Configs/Config.in
295
296 oldconfig: extra/config/conf
297         $(RM) -r include/bits
298         $(INSTALL) -d include/bits
299         @./extra/config/conf -o extra/Configs/Config.in
300
301 randconfig: extra/config/conf
302         $(RM) -r include/bits
303         $(INSTALL) -d include/bits
304         @./extra/config/conf -r extra/Configs/Config.in
305
306 allyesconfig: extra/config/conf
307         $(RM) -r include/bits
308         $(INSTALL) -d include/bits
309         @./extra/config/conf -y extra/Configs/Config.in
310         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
311         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
312         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
313         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
314         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
315         @./extra/config/conf -o extra/Configs/Config.in
316
317 allnoconfig: extra/config/conf
318         $(RM) -r include/bits
319         $(INSTALL) -d include/bits
320         @./extra/config/conf -n extra/Configs/Config.in
321
322 defconfig: extra/config/conf
323         $(RM) -r include/bits
324         $(INSTALL) -d include/bits
325         @./extra/config/conf -d extra/Configs/Config.in
326
327
328 clean:
329         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
330         @$(RM) -r tmp lib include/bits libc/tmp _install
331         $(RM) libc/obj.* headers
332         $(MAKE) -C test clean
333         $(MAKE) -C ldso clean
334         $(MAKE) -C libc/misc/internals clean
335         $(MAKE) -C libc/misc/wchar clean
336         $(MAKE) -C libc/unistd clean
337         $(MAKE) -C libc/sysdeps/linux/common clean
338         $(MAKE) -C extra/locale clean
339         @set -e; \
340         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
341                 $(RM) include/sys/$$i; \
342         done; \
343         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
344                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
345                         $(RM) include/sys/$$i; \
346                 done; \
347         fi;
348         @$(RM) include/linux include/asm*
349         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
350             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
351         fi;
352
353 distclean: clean
354         $(RM) .config .config.old .config.cmd
355         $(MAKE) -C extra clean
356
357 release: distclean
358         cd ..;                                  \
359         $(RM) -r uClibc-$(VERSION);             \
360         cp -dRf uClibc uClibc-$(VERSION);       \
361         find uClibc-$(VERSION)/ -type f         \
362             -name .\#* -exec $(RM) -r {} \; ;   \
363         find uClibc-$(VERSION)/ -type d         \
364             -name .svn -exec $(RM) -r {} \; ;   \
365                                                 \
366         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
367
368 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
369
370 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig