OSDN Git Service

Allow using ssp w/ current active Makefiles too. Build crts for non-shared archs...
[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
28 TOPDIR=./
29 include Rules.mak
30
31 RTLD_DIR =
32 ifeq ($(HAVE_SHARED),y)
33 RTLD_DIR = ldso
34 endif
35 # need to have libc built, before we can build the others
36 PRE_DIRS = $(RTLD_DIR) libc
37 DIRS = $(RTLD_DIR) libcrypt libresolv libnsl libutil librt
38 ifeq ($(UCLIBC_HAS_FLOATS),y)
39         DIRS += libm
40 endif
41 ifeq ($(UCLIBC_HAS_THREADS),y)
42         DIRS += libpthread
43 endif
44 ifeq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
45         DIRS += libintl
46 endif
47
48 ifeq ($(HAVE_DOT_CONFIG),y)
49
50 all: finished
51
52 # In this section, we need .config
53 -include .config.cmd
54
55 finished: subdirs
56         $(SECHO)
57         $(SECHO) Finally finished compiling ...
58         $(SECHO)
59
60 include/bits/uClibc_config.h: .config
61         @if [ ! -x ./extra/config/conf ] ; then \
62             $(MAKE) -C extra/config conf; \
63         fi
64         $(RM) -r include/bits
65         $(INSTALL) -d include/bits
66         @./extra/config/conf -o extra/Configs/Config.in
67
68 # For the moment, we have to keep re-running this target 
69 # because the fix includes scripts rely on pre-processers 
70 # in order to generate the headers correctly :(.  That 
71 # means we can't use the $(HOSTCC) in order to get the 
72 # correct output.
73 ifeq ($(ARCH_HAS_MMU),y)
74 export header_extra_args = 
75 else
76 export header_extra_args = -n
77 endif
78 headers: include/bits/uClibc_config.h
79         @$(SHELL_SET_X); \
80         ./extra/scripts/fix_includes.sh \
81                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
82                 $(header_extra_args)
83         @cd include/bits; \
84         set -e; \
85         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
86                 $(LN) -fs $$i .; \
87         done; \
88         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
89                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
90                         $(LN) -fs $$i .; \
91                 done; \
92         fi
93         @cd include/sys; \
94         set -e; \
95         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
96                 $(LN) -fs $$i .; \
97         done; \
98         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
99                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
100                         $(LN) -fs $$i .; \
101                 done; \
102         fi
103         @cd $(TOPDIR); \
104         set -e; \
105         $(SHELL_SET_X); \
106         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
107         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
108                 $(RM) include/bits/sysnum.h.new; \
109         else \
110                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
111         fi
112 ifeq ($(UCLIBC_HAS_THREADS),y)
113         $(MAKE) -C libpthread headers
114 endif
115         $(MAKE) -C libc/sysdeps/linux/common headers
116         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
117
118 # Command used to download source code
119 WGET:=wget --passive-ftp
120
121 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
122
123 pregen: headers
124 ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
125         (cd extra/locale; \
126         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
127         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
128         fi )
129 endif
130 ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
131         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
132         $(MAKE) -C extra/locale pregen
133 endif
134
135 pre_subdirs: $(patsubst %, _pre_dir_%, $(PRE_DIRS))
136 $(patsubst %, _pre_dir_%, $(PRE_DIRS)): pregen
137         $(MAKE) -C $(patsubst _pre_dir_%, %, $@)
138
139 subdirs: $(patsubst %, _dir_%, $(DIRS))
140 $(patsubst %, _dir_%, $(DIRS)): pre_subdirs
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.
152 install_headers:
153         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
154         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
155                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
156         else \
157                 extra_exclude="" ; \
158         fi ; \
159         tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
160                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
161         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ssp-internal.h
162         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
163 ifneq ($(UCLIBC_HAS_FLOATS),y)
164         # Remove floating point related headers since float support is disabled.
165         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
166         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
167         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
168         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
169         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
170         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
171 endif
172 ifneq ($(UCLIBC_HAS_WCHAR),y)
173         # Remove wide char headers since wide char support is disabled.
174         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
175         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
176 endif
177 ifneq ($(UCLIBC_HAS_LOCALE),y)
178         # Remove iconv header since locale support is disabled.
179         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
180 endif
181 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
182         # Remove printf header since custom print specifier support is disabled.
183         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
184 endif
185 ifneq ($(UCLIBC_HAS_XLOCALE),y)
186         # Remove xlocale header since extended locale support is disabled.
187         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
188 endif
189 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
190         # Remove libintl header since gettext support is disabled.
191         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
192 endif
193 ifneq ($(UCLIBC_HAS_REGEX),y)
194         # Remove regex headers since regex support is disabled.
195         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
196         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
197 endif
198 ifneq ($(UCLIBC_HAS_WORDEXP),y)
199         # Remove wordexp header since wordexp support is disabled.
200         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
201 endif
202 ifneq ($(UCLIBC_HAS_FTW),y)
203         # Remove ftw header since ftw support is disabled.
204         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
205 endif
206 ifneq ($(UCLIBC_HAS_GLOB),y)
207         # Remove glob header since glob support is disabled.
208         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
209 endif
210 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
211         # Remove getopt header since gnu getopt support is disabled.
212         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
213 endif
214 ifneq ($(HAS_SHADOW),y)
215         # Remove shadow header since shadow password support is disabled.
216         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
217 endif
218 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
219         # Remove thread_db header since thread debug support is disabled.
220         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
221 endif
222 ifneq ($(UCLIBC_HAS_THREADS),y)
223         # Remove pthread headers since thread support is disabled.
224         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
225         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
226         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
227 endif
228         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
229             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
230         done
231         -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r
232         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
233
234 # Installs development library links.
235 install_dev: install_headers
236         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
237         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
238 ifeq ($(HAVE_SHARED),y)
239         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
240         sed -e 's/lib\///'` ; do \
241                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
242                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
243         done
244         if [ -f $(TOPDIR)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
245                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
246                 sed -e '/^GROUP/d' $(TOPDIR)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
247         fi
248 ifeq ($(UCLIBC_HAS_SSP),y)
249 ifeq ($(COMPAT_ATEXIT),y)
250         if [ -f $(TOPDIR)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
251                 echo "GROUP ( $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) AS_NEEDED ( $(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO) ) )" \
252                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
253         fi
254 else
255         if [ -f $(TOPDIR)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
256                 echo "GROUP ( $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) AS_NEEDED $(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO) ) )" \
257                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
258         fi
259 endif
260 else
261 ifeq ($(COMPAT_ATEXIT),y)
262         if [ -f $(TOPDIR)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
263                 echo "GROUP ( $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) )" \
264                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
265         fi
266 else
267         if [ -f $(TOPDIR)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
268                 echo "GROUP ( $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) )" \
269                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
270         fi
271 endif
272 endif
273 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
274         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
275                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
276 endif
277 #       # If we build shared libraries then the static libs are PIC...
278 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
279         if [ -d lib ] ; then \
280                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
281                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
282                                 | sed -e 's/\.a$$/_pic.a/'`; \
283                 done ; \
284         fi
285 endif
286
287 # Installs run-time libraries
288 install_runtime:
289 ifeq ($(HAVE_SHARED),y)
290         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
291         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
292                 $(PREFIX)$(RUNTIME_PREFIX)lib
293         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
294         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
295             set -e; \
296                 $(SHELL_SET_X); \
297             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
298                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
299         fi
300 endif
301
302 utils:
303         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
304
305 # Installs helper applications, such as 'ldd' and 'ldconfig'
306 install_utils: utils
307         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
308
309 finished2:
310         $(SECHO)
311         $(SECHO) Finished installing ...
312         $(SECHO)
313
314 else # ifeq ($(HAVE_DOT_CONFIG),y)
315
316 all: menuconfig
317
318 # configuration
319 # ---------------------------------------------------------------------------
320 extra/config/conf:
321         $(MAKE) -C extra/config conf
322
323 extra/config/mconf:
324         $(MAKE) -C extra/config ncurses mconf
325
326 menuconfig: extra/config/mconf
327         $(RM) -r include/bits
328         $(INSTALL) -d include/bits
329         @./extra/config/mconf extra/Configs/Config.in
330         $(MAKE) headers
331
332 config: extra/config/conf
333         $(RM) -r include/bits
334         $(INSTALL) -d include/bits
335         @./extra/config/conf extra/Configs/Config.in
336
337 oldconfig: extra/config/conf
338         $(RM) -r include/bits
339         $(INSTALL) -d include/bits
340         @./extra/config/conf -o extra/Configs/Config.in
341
342 randconfig: extra/config/conf
343         $(RM) -r include/bits
344         $(INSTALL) -d include/bits
345         @./extra/config/conf -r extra/Configs/Config.in
346
347 allyesconfig: extra/config/conf
348         $(RM) -r include/bits
349         $(INSTALL) -d include/bits
350         @./extra/config/conf -y extra/Configs/Config.in
351         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
352         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
353         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
354         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
355         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
356         @./extra/config/conf -o extra/Configs/Config.in
357
358 allnoconfig: extra/config/conf
359         $(RM) -r include/bits
360         $(INSTALL) -d include/bits
361         @./extra/config/conf -n extra/Configs/Config.in
362
363 defconfig: extra/config/conf
364         $(RM) -r include/bits
365         $(INSTALL) -d include/bits
366         @./extra/config/conf -d extra/Configs/Config.in
367
368 clean:
369         @$(RM) -r lib include/bits
370         $(RM) libc/*.a libc/obj.* libc/nonshared_obj.*
371         $(RM) libc/misc/locale/locale_data.c
372         $(RM) libc/misc/internals/interp.c
373         $(RM) ldso/libdl/*.a
374         $(RM) include/fpu_control.h include/dl-osinfo.h
375         $(MAKE) -C extra/locale clean
376         $(MAKE) -C ldso headers_clean
377         $(MAKE) -C libpthread headers_clean
378         $(MAKE) -C test clean
379         $(MAKE) -C utils clean
380         @set -e; \
381         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
382                 $(RM) include/sys/$$i; \
383         done; \
384         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
385                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
386                         $(RM) include/sys/$$i; \
387                 done; \
388         fi
389         @$(RM) include/linux include/asm*
390         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
391             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
392         fi
393         -find . \( -name \*.o -o -name \*.os \) -exec $(RM) {} \;
394
395 distclean: clean
396         -find . \( -name core -o -name \*.orig -o -name \*~ -o -name .\#\* \) -exec $(RM) {} \;
397         $(RM) .config .config.old .config.cmd
398         $(RM) extra/locale/*.txt
399         $(MAKE) -C extra clean
400
401 release: distclean
402         cd ..;                                  \
403         $(RM) -r uClibc-$(VERSION);             \
404         cp -dRf uClibc uClibc-$(VERSION);       \
405         find uClibc-$(VERSION)/ -type f         \
406             -name .\#* -exec $(RM) -r {} \; ;   \
407         find uClibc-$(VERSION)/ -type d         \
408             -name .svn -exec $(RM) -r {} \; ;   \
409                                                 \
410         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/
411
412 endif # ifeq ($(HAVE_DOT_CONFIG),y)
413
414 check:
415         $(MAKE) -C test
416
417 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig utils