OSDN Git Service

Fix up some more NPTL stuff for header file symbolic links.
[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 ifeq ($(strip $(PTHREADS_NATIVE)),y)
121         (cd include; \
122         $(LN) -fs ../libpthread/nptl/sysdeps/pthread/pthread.h .; \
123         $(LN) -fs ../libpthread/nptl/semaphore.h .);
124         (cd include/bits; \
125         $(LN) -fs ../../libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/pthreadtypes.h .; \
126         $(LN) -fs ../../libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/semaphore.h .);
127 else
128         (cd include; \
129         $(LN) -fs ../libpthread/linuxthreads/sysdeps/pthread/pthread.h .; \
130         $(LN) -fs ../libpthread/linuxthreads/semaphore.h .);
131         (cd include/bits; \
132         $(LN) -fs ../../libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h .);
133 endif
134
135 # Command used to download source code
136 WGET:=wget --passive-ftp
137
138 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
139
140 pregen: headers
141 ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
142         (cd extra/locale; \
143         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
144         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
145         fi );
146 endif
147 ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
148         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
149         $(MAKE) -C extra/locale pregen
150 endif
151
152
153 subdirs: $(patsubst %, _dir_%, $(DIRS))
154 $(patsubst %, _dir_%, $(DIRS)): headers
155         $(MAKE) -C $(patsubst _dir_%, %, $@)
156
157 tags:
158         ctags -R
159
160 install: install_runtime install_dev finished2
161
162
163 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
164
165 # Installs header files and development library links.
166 install_dev:
167         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
168         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
169         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
170         tar -chf - include | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX);
171 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
172         # Remove floating point related headers since float support is disabled.
173         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
174         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
175         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
177         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
178 endif
179 ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
180         # Remove wide char headers since wide char support is disabled.
181         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
182         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
183 endif
184 ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
185         # Remove iconv header since locale support is disabled.
186         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
187 endif
188 ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
189         # Remove printf header since custom print specifier support is disabled.
190         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
191 endif
192 ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
193         # Remove xlocale header since extended locale support is disabled.
194         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
195 endif
196 ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
197         # Remove libintl header since gettext support is disabled.
198         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
199 endif
200 ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
201         # Remove regex headers since regex support is disabled.
202         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
203         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
204 endif
205 ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
206         # Remove wordexp header since wordexp support is disabled.
207         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
208 endif
209 ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
210         # Remove ftw header since ftw support is disabled.
211         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
212 endif
213 ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
214         # Remove glob header since glob support is disabled.
215         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
216 endif
217 ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
218         # Remove getopt header since gnu getopt support is disabled.
219         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
220 endif
221 ifneq ($(strip $(HAS_SHADOW)),y)
222         # Remove getopt header since shadow password support is disabled.
223         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.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 ifeq ($(strip $(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 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
237         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
238                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
239 endif
240 #       # If we build shared libraries then the static libs are PIC...
241 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
242         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
243                 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
244                         | sed -e 's/\.a$$/_pic.a/'`; \
245         done;
246         # Ugh!!! Remember that libdl.a and libdl_pic.a are different.  Since
247         # libdl is pretty small, and not likely to benefit from mklibs.py and
248         # similar, lets just remove libdl_pic.a and avoid the issue
249         rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
250 endif
251
252
253 # Installs run-time libraries
254 install_runtime:
255 ifeq ($(strip $(HAVE_SHARED)),y)
256         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
257         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
258                 $(PREFIX)$(RUNTIME_PREFIX)lib
259         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
260         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
261             set -x -e; \
262             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
263                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
264         fi;
265 endif
266
267 .PHONY: utils
268 ifeq ($(strip $(HAVE_SHARED)),y)
269 utils:
270         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
271 else
272 utils: dummy
273 endif
274
275 # Installs helper applications, such as 'ldd' and 'ldconfig'
276 install_utils: utils
277         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
278 #ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
279 #       @$(MAKE) -C libc/misc/wchar iconv.target
280 #       $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
281 #       $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
282 #endif
283
284 finished2:
285         @echo
286         @echo Finished installing ...
287         @echo
288
289 else # ifeq ($(strip $(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
306 config: extra/config/conf
307         $(RM) -r include/bits
308         $(INSTALL) -d include/bits
309         @./extra/config/conf extra/Configs/Config.in
310
311 oldconfig: extra/config/conf
312         $(RM) -r include/bits
313         $(INSTALL) -d include/bits
314         @./extra/config/conf -o extra/Configs/Config.in
315
316 randconfig: extra/config/conf
317         $(RM) -r include/bits
318         $(INSTALL) -d include/bits
319         @./extra/config/conf -r extra/Configs/Config.in
320
321 allyesconfig: extra/config/conf
322         $(RM) -r include/bits
323         $(INSTALL) -d include/bits
324         @./extra/config/conf -y extra/Configs/Config.in
325         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
326         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
327         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
328         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
329         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
330         @./extra/config/conf -o extra/Configs/Config.in
331
332 allnoconfig: extra/config/conf
333         $(RM) -r include/bits
334         $(INSTALL) -d include/bits
335         @./extra/config/conf -n extra/Configs/Config.in
336
337 defconfig: extra/config/conf
338         $(RM) -r include/bits
339         $(INSTALL) -d include/bits
340         @./extra/config/conf -d extra/Configs/Config.in
341
342 clean:
343         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
344         @$(RM) -r tmp lib include/bits libc/tmp _install
345         $(RM) libc/obj.* headers
346         $(MAKE) -C test clean
347         $(MAKE) -C ldso clean
348         $(MAKE) -C libc/misc/internals clean
349         $(MAKE) -C libc/misc/wchar clean
350         $(MAKE) -C libc/unistd clean
351         $(MAKE) -C libc/sysdeps/linux/common clean
352         $(MAKE) -C extra/locale clean
353         @set -e; \
354         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
355                 $(RM) include/sys/$$i; \
356         done; \
357         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
358                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
359                         $(RM) include/sys/$$i; \
360                 done; \
361         fi;
362         @$(RM) include/linux include/asm*
363         @$(RM) include/pthread.h include/semaphore.h
364         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
365             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
366         fi;
367
368 distclean: clean
369         $(RM) .config .config.old .config.cmd
370         $(MAKE) -C extra clean
371
372 release: distclean
373         cd ..;                                  \
374         $(RM) -r uClibc-$(VERSION);             \
375         cp -dRf uClibc uClibc-$(VERSION);       \
376         find uClibc-$(VERSION)/ -type f         \
377             -name .\#* -exec $(RM) -r {} \; ;   \
378         find uClibc-$(VERSION)/ -type d         \
379             -name .svn -exec $(RM) -r {} \; ;   \
380                                                 \
381         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
382
383 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
384
385 check:
386         $(MAKE) -C test
387
388 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig