OSDN Git Service

Correct targets install_dev and install_runtime to depend on shared
[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 ALL_SUBDIRS = ldso libc libcrypt libresolv libnsl libutil librt libm libpthread libintl test utils # extra
32
33 DIRS = ldso libc libcrypt libresolv libnsl libutil librt
34 ifeq ($(strip $(UCLIBC_HAS_FLOATS)),y)
35         DIRS += libm
36 endif
37 ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
38         DIRS += libpthread
39 endif
40 ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
41         DIRS += libintl
42 endif
43
44 ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
45
46 all: headers pregen subdirs shared finished
47
48 # In this section, we need .config
49 -include .config.cmd
50
51 shared: $(patsubst %, _shared_dir_%, $(DIRS))
52 $(patsubst %, _shared_dir_%, $(DIRS)): subdirs
53 ifeq ($(strip $(HAVE_SHARED)),y)
54         $(SECHO)
55         $(SECHO) Building shared libraries ...
56         $(SECHO)
57         $(MAKE) -C $(patsubst _shared_dir_%, %, $@) shared
58 else
59         $(SECHO)
60         $(SECHO) Not building shared libraries ...
61         $(SECHO)
62 endif
63
64 finished: shared
65         $(SECHO)
66         $(SECHO) Finally finished compiling ...
67         $(SECHO)
68
69 include/bits/uClibc_config.h: .config
70         @if [ ! -x ./extra/config/conf ] ; then \
71             $(MAKE) -C extra/config conf; \
72         fi;
73         $(RM) -r include/bits
74         $(INSTALL) -d include/bits
75         @./extra/config/conf -o extra/Configs/Config.in
76
77 # For the moment, we have to keep re-running this target 
78 # because the fix includes scripts rely on pre-processers 
79 # in order to generate the headers correctly :(.  That 
80 # means we can't use the $(HOSTCC) in order to get the 
81 # correct output.
82 ifeq ($(strip $(ARCH_HAS_MMU)),y)
83 export header_extra_args = 
84 else
85 export header_extra_args = -n
86 endif
87 headers: include/bits/uClibc_config.h
88         @$(SHELL_SET_X); \
89         ./extra/scripts/fix_includes.sh \
90                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
91                 $(header_extra_args)
92         @cd include/bits; \
93         set -e; \
94         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
95                 $(LN) -fs $$i .; \
96         done; \
97         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
98                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
99                         $(LN) -fs $$i .; \
100                 done; \
101         fi
102         @cd include/sys; \
103         set -e; \
104         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
105                 $(LN) -fs $$i .; \
106         done; \
107         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
108                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
109                         $(LN) -fs $$i .; \
110                 done; \
111         fi
112         @cd $(TOPDIR); \
113         set -e; \
114         $(SHELL_SET_X); \
115         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
116         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
117                 $(RM) include/bits/sysnum.h.new; \
118         else \
119                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
120         fi
121 ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
122         $(MAKE) -C libpthread headers
123 endif
124         $(MAKE) -C libc/sysdeps/linux/common headers
125         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
126
127 # Command used to download source code
128 WGET:=wget --passive-ftp
129
130 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
131
132 pregen: headers
133 ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
134         (cd extra/locale; \
135         if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
136         $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
137         fi );
138 endif
139 ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
140         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
141         $(MAKE) -C extra/locale pregen
142 endif
143
144
145 subdirs: $(patsubst %, _dir_%, $(DIRS))
146 $(patsubst %, _dir_%, $(DIRS)): headers
147         $(MAKE) -C $(patsubst _dir_%, %, $@)
148
149 tags:
150         ctags -R
151
152 install: install_runtime install_dev finished2
153
154
155 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
156
157 # Installs header files and development library links.
158 install_dev: shared
159         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
160         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
161         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
162         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
163                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
164         else \
165                 extra_exclude="" ; \
166         fi ; \
167         tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
168                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
169         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ssp-internal.h
170 ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
171         # Remove floating point related headers since float support is disabled.
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
173         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
174         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
175         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
177         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.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 shadow header since shadow password support is disabled.
223         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
224 endif
225 ifneq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
226         # Remove thread_db header since thread debug support is disabled.
227         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
228 endif
229 ifneq ($(strip $(UCLIBC_HAS_THREADS)),y)
230         # Remove pthread headers since thread support is disabled.
231         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
232         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
233         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
234 endif
235         -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
236             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
237         done;
238         -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
239         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
240 ifeq ($(strip $(HAVE_SHARED)),y)
241         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
242         sed -e 's/lib\///'` ; do \
243                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
244                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
245         done;
246 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
247         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
248                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
249 endif
250 #       # If we build shared libraries then the static libs are PIC...
251 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
252         if [ -d lib ] ; then \
253         for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
254                 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
255                         | sed -e 's/\.a$$/_pic.a/'`; \
256         done ; \
257         fi
258         # Ugh!!! Remember that libdl.a and libdl_pic.a are different.  Since
259         # libdl is pretty small, and not likely to benefit from mklibs.py and
260         # similar, lets just remove libdl_pic.a and avoid the issue
261         $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
262 endif
263
264
265 # Installs run-time libraries
266 install_runtime: shared
267 ifeq ($(strip $(HAVE_SHARED)),y)
268         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
269         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
270                 $(PREFIX)$(RUNTIME_PREFIX)lib
271         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
272         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
273             set -e; \
274                 $(SHELL_SET_X); \
275             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
276                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
277         fi;
278 endif
279
280 utils:
281         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
282
283 # Installs helper applications, such as 'ldd' and 'ldconfig'
284 install_utils: utils
285         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
286
287 finished2:
288         $(SECHO)
289         $(SECHO) Finished installing ...
290         $(SECHO)
291
292 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
293
294 all: menuconfig
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 subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
347 $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)): dummy
348         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
349
350 clean: subdirs_clean
351         - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
352         @$(RM) -r lib include/bits
353         $(MAKE) -C libc/misc/internals clean
354         $(MAKE) -C extra/locale clean
355         @set -e; \
356         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
357                 $(RM) include/sys/$$i; \
358         done; \
359         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
360                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
361                         $(RM) include/sys/$$i; \
362                 done; \
363         fi;
364         @$(RM) include/linux include/asm*
365         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
366             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
367         fi;
368
369 distclean: clean
370         $(RM) .config .config.old .config.cmd
371         $(MAKE) -C extra clean
372
373 release: distclean
374         cd ..;                                  \
375         $(RM) -r uClibc-$(VERSION);             \
376         cp -dRf uClibc uClibc-$(VERSION);       \
377         find uClibc-$(VERSION)/ -type f         \
378             -name .\#* -exec $(RM) -r {} \; ;   \
379         find uClibc-$(VERSION)/ -type d         \
380             -name .svn -exec $(RM) -r {} \; ;   \
381                                                 \
382         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/;
383
384 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
385
386 check:
387         $(MAKE) -C test
388
389 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig