OSDN Git Service

Replace all Makefiles for new build infrastucture
[uclinux-h8/uClibc.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
8 #--------------------------------------------------------------
9 # You shouldn't need to mess with anything beyond this point...
10 #--------------------------------------------------------------
11 noconfig_targets := menuconfig config oldconfig randconfig \
12         defconfig allyesconfig allnoconfig clean distclean \
13         release dist tags
14
15 TOPDIR=./
16
17 top_srcdir=$(TOPDIR)
18 top_builddir=./
19 include $(top_builddir)Rules.mak
20
21 # need to have libc.so built, before we can build the others
22 ifeq ($(HAVE_SHARED),y)
23 PRE_DIRS = ldso libc
24 DIRS = ldso libcrypt libresolv libnsl libutil librt
25 else
26 PRE_DIRS = libc
27 DIRS = libcrypt libresolv libnsl libutil librt
28 endif
29 ifeq ($(UCLIBC_HAS_FLOATS),y)
30         DIRS += libm
31 endif
32 ifeq ($(UCLIBC_HAS_THREADS),y)
33         DIRS += libpthread
34 endif
35 ifeq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
36         DIRS += libintl
37 endif
38
39 ifeq ($(HAVE_DOT_CONFIG),y)
40
41 all: finished
42
43 # In this section, we need .config
44 -include .config.cmd
45
46 finished: subdirs
47         $(SECHO)
48         $(SECHO) Finally finished compiling ...
49         $(SECHO)
50
51 include/bits/uClibc_config.h: .config
52         @if [ ! -x $(top_builddir)extra/config/conf ] ; then \
53             $(MAKE) -C $(top_builddir)extra/config conf; \
54         fi
55         $(RM) -r $(top_builddir)include/bits
56         $(INSTALL) -d $(top_builddir)include/bits
57         @$(top_builddir)extra/config/conf -o $(top_srcdir)extra/Configs/Config.in
58
59 # For the moment, we have to keep re-running this target 
60 # because the fix includes scripts rely on pre-processers 
61 # in order to generate the headers correctly :(.  That 
62 # means we can't use the $(HOSTCC) in order to get the 
63 # correct output.
64 ifeq ($(ARCH_HAS_MMU),y)
65 export header_extra_args = 
66 else
67 export header_extra_args = -n
68 endif
69 headers: $(top_srcdir)include/bits/uClibc_config.h
70         @$(SHELL_SET_X); \
71         $(top_srcdir)extra/scripts/fix_includes.sh \
72                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
73                 $(header_extra_args)
74         if [ -f libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
75                 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
76         else \
77                 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
78         fi
79         $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h include/
80         @cd $(top_builddir)include/bits; \
81         set -e; \
82         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
83                 $(LN) -fs $$i .; \
84         done; \
85         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
86                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
87                         $(LN) -fs $$i .; \
88                 done; \
89         fi
90         @cd $(top_builddir)include/sys; \
91         set -e; \
92         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
93                 $(LN) -fs $$i .; \
94         done; \
95         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
96                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
97                         $(LN) -fs $$i .; \
98                 done; \
99         fi
100         @cd $(top_builddir); \
101         set -e; \
102         $(SHELL_SET_X); \
103         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
104         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
105                 $(RM) include/bits/sysnum.h.new; \
106         else \
107                 $(RM) include/bits/sysnum.h; \
108                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
109         fi
110 ifeq ($(HAVE_SHARED),y)
111         $(MAKE) -C ldso headers-y
112 endif
113 ifeq ($(UCLIBC_HAS_THREADS),y)
114         $(MAKE) -C libpthread headers-y
115 endif
116         $(MAKE) -C libc/sysdeps/linux headers-y
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 $(top_builddir)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 $(top_builddir)extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
132         $(MAKE) -C $(top_srcdir)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 install: install_runtime install_dev finished2
144
145
146 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
147
148 # Installs header files.
149 install_headers:
150         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
151         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
152                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
153         else \
154                 extra_exclude="" ; \
155         fi ; \
156         tar -chf - include --exclude .svn $$extra_exclude \
157                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
158         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ssp-internal.h
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
160 ifneq ($(UCLIBC_HAS_FLOATS),y)
161         # Remove floating point related headers since float support is disabled.
162         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
164         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
165         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
166         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
167         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
168 endif
169 ifneq ($(UCLIBC_HAS_WCHAR),y)
170         # Remove wide char headers since wide char support is disabled.
171         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
173 endif
174 ifneq ($(UCLIBC_HAS_LOCALE),y)
175         # Remove iconv header since locale support is disabled.
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
177 endif
178 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
179         # Remove printf header since custom print specifier support is disabled.
180         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
181 endif
182 ifneq ($(UCLIBC_HAS_XLOCALE),y)
183         # Remove xlocale header since extended locale support is disabled.
184         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
185 endif
186 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
187         # Remove libintl header since gettext support is disabled.
188         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
189 endif
190 ifneq ($(UCLIBC_HAS_REGEX),y)
191         # Remove regex headers since regex support is disabled.
192         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
193         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
194 endif
195 ifneq ($(UCLIBC_HAS_WORDEXP),y)
196         # Remove wordexp header since wordexp support is disabled.
197         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
198 endif
199 ifneq ($(UCLIBC_HAS_FTW),y)
200         # Remove ftw header since ftw support is disabled.
201         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
202 endif
203 ifneq ($(UCLIBC_HAS_GLOB),y)
204         # Remove glob header since glob support is disabled.
205         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
206 endif
207 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
208         # Remove getopt header since gnu getopt support is disabled.
209         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
210 endif
211 ifneq ($(HAS_SHADOW),y)
212         # Remove shadow header since shadow password support is disabled.
213         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
214 endif
215 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
216         # Remove thread_db header since thread debug support is disabled.
217         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
218 endif
219 ifneq ($(UCLIBC_HAS_THREADS),y)
220         # Remove pthread headers since thread support is disabled.
221         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
222         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
223         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
224 endif
225         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
226             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
227         done
228         -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r
229         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
230
231 # Installs development library links.
232 install_dev: install_headers
233         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
234         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
235 ifeq ($(HAVE_SHARED),y)
236         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
237         sed -e 's/lib\///'` ; do \
238                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
239                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
240         done
241         if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
242                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
243                 sed     -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
244                         -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
245                         -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
246                         $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
247         fi
248 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
249         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
250                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
251 endif
252 #       # If we build shared libraries then the static libs are PIC...
253 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
254         if [ -d lib ] ; then \
255                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
256                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
257                                 | sed -e 's/\.a$$/_pic.a/'`; \
258                 done ; \
259         fi
260 endif
261
262 # Installs run-time libraries
263 install_runtime:
264 ifeq ($(HAVE_SHARED),y)
265         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
266         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
267                 $(PREFIX)$(RUNTIME_PREFIX)lib
268         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
269         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
270             set -e; \
271                 $(SHELL_SET_X); \
272             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
273                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
274         fi
275 endif
276
277 utils:
278         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
279
280 # Installs helper applications, such as 'ldd' and 'ldconfig'
281 install_utils: utils
282         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
283
284 finished2:
285         $(SECHO)
286         $(SECHO) Finished installing ...
287         $(SECHO)
288
289 else # ifeq ($(HAVE_DOT_CONFIG),y)
290
291 all: menuconfig
292
293 # configuration
294 # ---------------------------------------------------------------------------
295 extra/config/conf:
296         $(MAKE) -C extra/config conf
297
298 extra/config/mconf:
299         $(MAKE) -C extra/config ncurses mconf
300
301 menuconfig: extra/config/mconf
302         $(RM) -r include/bits
303         $(INSTALL) -d include/bits
304         @./extra/config/mconf extra/Configs/Config.in
305         $(MAKE) headers
306
307 config: extra/config/conf
308         $(RM) -r include/bits
309         $(INSTALL) -d include/bits
310         @./extra/config/conf extra/Configs/Config.in
311
312 oldconfig: extra/config/conf
313         $(RM) -r include/bits
314         $(INSTALL) -d include/bits
315         @./extra/config/conf -o extra/Configs/Config.in
316
317 randconfig: extra/config/conf
318         $(RM) -r include/bits
319         $(INSTALL) -d include/bits
320         @./extra/config/conf -r extra/Configs/Config.in
321
322 allyesconfig: extra/config/conf
323         $(RM) -r include/bits
324         $(INSTALL) -d include/bits
325         @./extra/config/conf -y extra/Configs/Config.in
326         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
327         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
328         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
329         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
330         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
331         @./extra/config/conf -o extra/Configs/Config.in
332
333 allnoconfig: extra/config/conf
334         $(RM) -r include/bits
335         $(INSTALL) -d include/bits
336         @./extra/config/conf -n extra/Configs/Config.in
337
338 defconfig: extra/config/conf
339         $(RM) -r include/bits
340         $(INSTALL) -d include/bits
341         @./extra/config/conf -d extra/Configs/Config.in
342
343 clean:
344         @$(RM) -r lib include/bits
345         $(RM) lib*/*.a ldso/*/*.a libpthread/*/*.a
346         $(RM) libc/misc/internals/interp.c
347         $(RM) include/fpu_control.h include/dl-osinfo.h
348         $(MAKE) -C extra/locale clean
349         $(MAKE) -C ldso headers_clean-y
350         $(MAKE) -C libpthread headers_clean-y
351         $(MAKE) -C libc/sysdeps/linux headers_clean-y
352         $(MAKE) -C test clean
353         $(MAKE) -C utils clean
354         @set -e; \
355         for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
356                 $(RM) include/sys/$$i; \
357         done; \
358         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
359                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
360                         $(RM) include/sys/$$i; \
361                 done; \
362         fi
363         @$(RM) include/linux include/asm*
364         -find . \( -name \*.o -o -name \*.os -o -name \*.oS \) -exec $(RM) {} \;
365
366 distclean: clean
367         -find . \( -name core -o -name \*.orig -o -name \*~ \) -exec $(RM) {} \;
368         $(RM) .config .config.old .config.cmd
369         $(RM) extra/locale/*.txt
370         $(MAKE) -C extra clean
371
372 dist release:
373         $(MAKE) -s distclean
374         $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.gz
375         svn -q export . ../uClibc-$(VERSION)
376         tar czf ../uClibc-$(VERSION).tar.gz -C .. uClibc-$(VERSION)
377         du -b ../uClibc-$(VERSION).tar.gz
378
379 endif # ifeq ($(HAVE_DOT_CONFIG),y)
380
381 include $(top_srcdir)Makerules
382
383 check:
384         $(MAKE) -C test
385
386 .PHONY: dummy subdirs release dist distclean clean config oldconfig menuconfig utils