OSDN Git Service

Sync w/ dirent.h, s:HAVE_D_NAMLEN:_DIRENT_HAVE_D_NAMLEN:
[uclinux-h8/uClibc.git] / Makefile.in
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 include $(top_builddir)Rules.mak
16
17 # need to have libc.so built, before we can build the others
18 ifeq ($(HAVE_SHARED),y)
19 PRE_DIRS = ldso libc
20 DIRS = ldso libcrypt libresolv libnsl libutil librt
21 else
22 PRE_DIRS = libc
23 DIRS = libcrypt libresolv libnsl libutil librt
24 endif
25 ifeq ($(UCLIBC_HAS_FLOATS),y)
26         DIRS += libm
27 endif
28 ifeq ($(UCLIBC_HAS_THREADS),y)
29         DIRS += libpthread
30 endif
31 ifeq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
32         DIRS += libintl
33 endif
34
35 ifeq ($(HAVE_DOT_CONFIG),y)
36
37 all: finished
38
39 # In this section, we need .config
40 -include .config.cmd
41
42 finished: subdirs
43         $(SECHO)
44         $(SECHO) Finally finished compiling ...
45         $(SECHO)
46
47 include/bits/uClibc_config.h: .config
48         @if [ ! -x $(top_builddir)extra/config/conf ] ; then \
49             $(MAKE) -C $(top_builddir)extra/config conf; \
50         fi
51         $(RM) -r $(top_builddir)include/bits
52         $(INSTALL) -d $(top_builddir)include/bits
53         @$(top_builddir)extra/config/conf -o $(top_srcdir)extra/Configs/Config.in
54
55 # For the moment, we have to keep re-running this target 
56 # because the fix includes scripts rely on pre-processers 
57 # in order to generate the headers correctly :(.  That 
58 # means we can't use the $(HOSTCC) in order to get the 
59 # correct output.
60 ifeq ($(ARCH_HAS_MMU),y)
61 export header_extra_args = 
62 else
63 export header_extra_args = -n
64 endif
65 headers: $(top_srcdir)include/bits/uClibc_config.h
66         @$(SHELL_SET_X); \
67         $(top_srcdir)extra/scripts/fix_includes.sh \
68                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
69                 $(header_extra_args)
70         if [ -f libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
71                 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
72         else \
73                 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
74         fi
75         $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h include/
76         @cd $(top_builddir)include/bits; \
77         set -e; \
78         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
79                 $(LN) -fs $$i .; \
80         done; \
81         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
82                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
83                         $(LN) -fs $$i .; \
84                 done; \
85         fi
86         @cd $(top_builddir)include/sys; \
87         set -e; \
88         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
89                 $(LN) -fs $$i .; \
90         done; \
91         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
92                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
93                         $(LN) -fs $$i .; \
94                 done; \
95         fi
96         @cd $(top_builddir); \
97         set -e; \
98         $(SHELL_SET_X); \
99         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
100         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
101                 $(RM) include/bits/sysnum.h.new; \
102         else \
103                 $(RM) include/bits/sysnum.h; \
104                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
105         fi
106 ifeq ($(HAVE_SHARED),y)
107         $(MAKE) -C ldso headers-y
108 endif
109 ifeq ($(UCLIBC_HAS_THREADS),y)
110         $(MAKE) -C libpthread headers-y
111 endif
112         $(MAKE) -C libc/sysdeps/linux headers-y
113
114 # Command used to download source code
115 WGET:=wget --passive-ftp
116
117 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
118
119 pregen: headers
120 ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
121         (cd $(top_builddir)extra/locale; \
122         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
123         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
124         fi )
125 endif
126 ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
127         (cd $(top_builddir)extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
128         $(MAKE) -C $(top_srcdir)extra/locale pregen
129 endif
130
131 pre_subdirs: $(patsubst %, _pre_dir_%, $(PRE_DIRS))
132 $(patsubst %, _pre_dir_%, $(PRE_DIRS)): pregen
133         $(MAKE) -C $(patsubst _pre_dir_%, %, $@)
134
135 subdirs: $(patsubst %, _dir_%, $(DIRS))
136 $(patsubst %, _dir_%, $(DIRS)): pre_subdirs
137         $(MAKE) -C $(patsubst _dir_%, %, $@)
138
139 install: install_runtime install_dev finished2
140
141
142 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
143
144 # Installs header files.
145 install_headers:
146         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
147         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
148                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
149         else \
150                 extra_exclude="" ; \
151         fi ; \
152         tar -chf - include --exclude .svn $$extra_exclude \
153                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
154         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ssp-internal.h
155         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
156 ifneq ($(UCLIBC_HAS_FLOATS),y)
157         # Remove floating point related headers since float support is disabled.
158         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
160         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
161         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
162         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
164 endif
165 ifneq ($(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 ($(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 ($(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 ($(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 ($(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 ($(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 ($(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 ($(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 ($(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 ($(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 ($(HAS_SHADOW),y)
208         # Remove shadow header since shadow password support is disabled.
209         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
210 endif
211 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
212         # Remove thread_db header since thread debug support is disabled.
213         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
214 endif
215 ifneq ($(UCLIBC_HAS_THREADS),y)
216         # Remove pthread headers since thread support is disabled.
217         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
218         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
219         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
220 endif
221         -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
222             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
223         done
224         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
225
226 # Installs development library links.
227 install_dev: install_headers
228         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
229         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
230 ifeq ($(HAVE_SHARED),y)
231         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
232         sed -e 's/lib\///'` ; do \
233                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
234                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
235         done
236         if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
237                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
238                 sed     -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
239                         -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
240                         -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
241                         $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
242         fi
243 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
244         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
245                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
246 endif
247 ifeq ($(DOPIC),y)
248 #       # If we build shared libraries then the static libs are PIC...
249 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
250         if [ -d lib ] ; then \
251                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
252                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
253                                 | sed -e 's/\.a$$/_pic.a/'`; \
254                 done ; \
255         fi
256 endif
257 endif
258
259 # Installs run-time libraries
260 install_runtime:
261 ifeq ($(HAVE_SHARED),y)
262         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
263         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
264                 $(PREFIX)$(RUNTIME_PREFIX)lib
265         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
266         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
267             set -e; \
268                 $(SHELL_SET_X); \
269             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
270                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
271         fi
272 endif
273
274 utils:
275         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
276
277 # Installs helper applications, such as 'ldd' and 'ldconfig'
278 install_utils: utils
279         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
280
281 finished2:
282         $(SECHO)
283         $(SECHO) Finished installing ...
284         $(SECHO)
285
286 else # ifeq ($(HAVE_DOT_CONFIG),y)
287
288 all: menuconfig
289
290 headers:
291         @echo "Need to make a config file first, run: make menuconfig"
292         @false
293
294 endif # ifeq ($(HAVE_DOT_CONFIG),y)
295
296 # configuration
297 # ---------------------------------------------------------------------------
298 extra/config/conf:
299         $(MAKE) -C extra/config conf
300
301 extra/config/mconf:
302         $(MAKE) -C extra/config ncurses mconf
303
304 menuconfig: extra/config/mconf
305         $(RM) -r include/bits
306         $(INSTALL) -d include/bits
307         @./extra/config/mconf extra/Configs/Config.in
308         $(MAKE) headers
309
310 config: extra/config/conf
311         $(RM) -r include/bits
312         $(INSTALL) -d include/bits
313         @./extra/config/conf extra/Configs/Config.in
314
315 oldconfig: extra/config/conf
316         $(RM) -r include/bits
317         $(INSTALL) -d include/bits
318         @./extra/config/conf -o extra/Configs/Config.in
319
320 randconfig: extra/config/conf
321         $(RM) -r include/bits
322         $(INSTALL) -d include/bits
323         @./extra/config/conf -r extra/Configs/Config.in
324
325 allyesconfig: extra/config/conf
326         $(RM) -r include/bits
327         $(INSTALL) -d include/bits
328         @./extra/config/conf -y extra/Configs/Config.in
329         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
330         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
331         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
332         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
333         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
334         @./extra/config/conf -o extra/Configs/Config.in
335
336 allnoconfig: extra/config/conf
337         $(RM) -r include/bits
338         $(INSTALL) -d include/bits
339         @./extra/config/conf -n extra/Configs/Config.in
340
341 defconfig: extra/config/conf
342         $(RM) -r include/bits
343         $(INSTALL) -d include/bits
344         @./extra/config/conf -d extra/Configs/Config.in
345
346 clean:
347         @$(RM) -r lib include/bits
348         $(RM) lib*/*.a ldso/*/*.a libpthread/*/*.a
349         $(RM) libc/misc/internals/interp.c
350         $(RM) libc/stdio/*64.c
351         $(RM) include/fpu_control.h include/dl-osinfo.h
352         $(MAKE) -C extra/locale clean
353         $(MAKE) -C ldso headers_clean-y
354         $(MAKE) -C libpthread headers_clean-y
355         $(MAKE) -C libc/sysdeps/linux headers_clean-y
356         $(MAKE) -C test clean
357         $(MAKE) -C utils clean
358         @set -e; \
359         for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
360                 $(RM) include/sys/$$i; \
361         done; \
362         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
363                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
364                         $(RM) include/sys/$$i; \
365                 done; \
366         fi
367         @$(RM) include/linux include/asm*
368         -find . \( -name \*.o -o -name \*.os -o -name \*.oS \) -exec $(RM) {} \;
369
370 distclean: clean
371         -find . \( -name core -o -name \*.orig -o -name \*~ \) -exec $(RM) {} \;
372         $(RM) .config .config.old .config.cmd
373         $(RM) extra/locale/*.txt
374         $(MAKE) -C extra clean
375
376 dist release:
377         $(MAKE) -s distclean
378         $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.gz
379         svn -q export . ../uClibc-$(VERSION)
380         tar czf ../uClibc-$(VERSION).tar.gz -C .. uClibc-$(VERSION)
381         du -b ../uClibc-$(VERSION).tar.gz
382
383 check:
384         $(MAKE) -C test
385
386 .PHONY: dummy subdirs release dist distclean clean config oldconfig menuconfig utils