OSDN Git Service

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