]> Git Repo - uclibc-ng.git/blob - Makefile
Remove ar-target and shared targets, at build time now we traverse the tree only...
[uclibc-ng.git] / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2003 Erik Andersen <[email protected]>
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
28 TOPDIR=./
29 include Rules.mak
30
31 # need to have libc.so built, before we can build the others
32 PRE_DIRS = ldso libc
33 DIRS = ldso 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: finished
47
48 # In this section, we need .config
49 -include .config.cmd
50
51 finished: subdirs
52         $(SECHO)
53         $(SECHO) Finally finished compiling ...
54         $(SECHO)
55
56 include/bits/uClibc_config.h: .config
57         @if [ ! -x ./extra/config/conf ] ; then \
58             $(MAKE) -C extra/config conf; \
59         fi
60         $(RM) -r include/bits
61         $(INSTALL) -d include/bits
62         @./extra/config/conf -o extra/Configs/Config.in
63
64 # For the moment, we have to keep re-running this target 
65 # because the fix includes scripts rely on pre-processers 
66 # in order to generate the headers correctly :(.  That 
67 # means we can't use the $(HOSTCC) in order to get the 
68 # correct output.
69 ifeq ($(strip $(ARCH_HAS_MMU)),y)
70 export header_extra_args = 
71 else
72 export header_extra_args = -n
73 endif
74 headers: include/bits/uClibc_config.h
75         @$(SHELL_SET_X); \
76         ./extra/scripts/fix_includes.sh \
77                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
78                 $(header_extra_args)
79         @cd include/bits; \
80         set -e; \
81         for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
82                 $(LN) -fs $$i .; \
83         done; \
84         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
85                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
86                         $(LN) -fs $$i .; \
87                 done; \
88         fi
89         @cd include/sys; \
90         set -e; \
91         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
92                 $(LN) -fs $$i .; \
93         done; \
94         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
95                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
96                         $(LN) -fs $$i .; \
97                 done; \
98         fi
99         @cd $(TOPDIR); \
100         set -e; \
101         $(SHELL_SET_X); \
102         TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
103         if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
104                 $(RM) include/bits/sysnum.h.new; \
105         else \
106                 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
107         fi
108 ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
109         $(MAKE) -C libpthread headers
110 endif
111         $(MAKE) -C libc/sysdeps/linux/common headers
112         $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
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 ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
121         (cd 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 ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
127         (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
128         $(MAKE) -C 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 tags:
140         ctags -R
141
142 install: install_runtime install_dev finished2
143
144
145 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
146
147 # Installs header files and development library links.
148 install_dev:
149         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
150         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
151         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
152         if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
153                 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
154         else \
155                 extra_exclude="" ; \
156         fi ; \
157         tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
158                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ssp-internal.h
160 ifneq ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 ($(strip $(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 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         if [ -f $(TOPDIR)lib/libc.so ] ; then \
237                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
238                 sed -e '/^GROUP/d' $(TOPDIR)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
239         fi
240 ifeq ($(strip $(COMPAT_ATEXIT)),y)
241         if [ -f $(TOPDIR)lib/libc.so ] ; then \
242                 echo "GROUP ( $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) )" \
243                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
244         fi
245 else
246         if [ -f $(TOPDIR)lib/libc.so ] ; then \
247                 echo "GROUP ( $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) )" \
248                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
249         fi
250 endif
251 ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
252         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
253                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
254 endif
255 #       # If we build shared libraries then the static libs are PIC...
256 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
257         if [ -d lib ] ; then \
258                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
259                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
260                                 | sed -e 's/\.a$$/_pic.a/'`; \
261                 done ; \
262         fi
263 endif
264
265
266 # Installs run-time libraries
267 install_runtime:
268 ifeq ($(strip $(HAVE_SHARED)),y)
269         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
270         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
271                 $(PREFIX)$(RUNTIME_PREFIX)lib
272         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
273         @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
274             set -e; \
275                 $(SHELL_SET_X); \
276             $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
277                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
278         fi
279 endif
280
281 utils:
282         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
283
284 # Installs helper applications, such as 'ldd' and 'ldconfig'
285 install_utils: utils
286         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
287
288 finished2:
289         $(SECHO)
290         $(SECHO) Finished installing ...
291         $(SECHO)
292
293 else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
294
295 all: menuconfig
296
297 # configuration
298 # ---------------------------------------------------------------------------
299 extra/config/conf:
300         $(MAKE) -C extra/config conf
301
302 extra/config/mconf:
303         $(MAKE) -C extra/config ncurses mconf
304
305 menuconfig: extra/config/mconf
306         $(RM) -r include/bits
307         $(INSTALL) -d include/bits
308         @./extra/config/mconf extra/Configs/Config.in
309         $(MAKE) headers
310
311 config: extra/config/conf
312         $(RM) -r include/bits
313         $(INSTALL) -d include/bits
314         @./extra/config/conf extra/Configs/Config.in
315
316 oldconfig: extra/config/conf
317         $(RM) -r include/bits
318         $(INSTALL) -d include/bits
319         @./extra/config/conf -o extra/Configs/Config.in
320
321 randconfig: extra/config/conf
322         $(RM) -r include/bits
323         $(INSTALL) -d include/bits
324         @./extra/config/conf -r extra/Configs/Config.in
325
326 allyesconfig: extra/config/conf
327         $(RM) -r include/bits
328         $(INSTALL) -d include/bits
329         @./extra/config/conf -y extra/Configs/Config.in
330         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
331         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
332         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
333         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
334         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
335         @./extra/config/conf -o extra/Configs/Config.in
336
337 allnoconfig: extra/config/conf
338         $(RM) -r include/bits
339         $(INSTALL) -d include/bits
340         @./extra/config/conf -n extra/Configs/Config.in
341
342 defconfig: extra/config/conf
343         $(RM) -r include/bits
344         $(INSTALL) -d include/bits
345         @./extra/config/conf -d extra/Configs/Config.in
346
347 clean:
348         @$(RM) -r lib include/bits
349         $(RM) */*.so */*.a
350         $(RM) libc/misc/internals/interp.c
351         $(RM) include/fpu_control.h
352         $(MAKE) -C extra/locale clean
353         $(MAKE) -C ldso clean
354         $(MAKE) -C libpthread clean
355         $(MAKE) -C test clean
356         $(MAKE) -C utils clean
357         @set -e; \
358         for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
359                 $(RM) include/sys/$$i; \
360         done; \
361         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
362                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
363                         $(RM) include/sys/$$i; \
364                 done; \
365         fi
366         @$(RM) include/linux include/asm*
367         @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
368             $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
369         fi
370         - find . \( -name \*.o -o -name core -o -name .\#\* \) -exec $(RM) {} \;
371
372 distclean: clean
373         $(RM) .config .config.old .config.cmd
374         $(RM) extra/locale/*.txt
375         $(MAKE) -C extra clean
376
377 release: distclean
378         cd ..;                                  \
379         $(RM) -r uClibc-$(VERSION);             \
380         cp -dRf uClibc uClibc-$(VERSION);       \
381         find uClibc-$(VERSION)/ -type f         \
382             -name .\#* -exec $(RM) -r {} \; ;   \
383         find uClibc-$(VERSION)/ -type d         \
384             -name .svn -exec $(RM) -r {} \; ;   \
385                                                 \
386         tar -cvzf uClibc-$(VERSION).tar.gz uClibc-$(VERSION)/
387
388 endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
389
390 check:
391         $(MAKE) -C test
392
393 .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig utils
This page took 0.043173 seconds and 4 git commands to generate.