3 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
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 \
15 include $(top_builddir)Rules.mak
17 # need to have libc.so built, before we can build the others
18 ifeq ($(HAVE_SHARED),y)
20 DIRS = ldso libcrypt libresolv libnsl libutil librt
23 DIRS = libcrypt libresolv libnsl libutil librt
25 ifeq ($(UCLIBC_HAS_FLOATS),y)
28 ifeq ($(UCLIBC_HAS_THREADS),y)
31 ifeq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
35 ifeq ($(HAVE_DOT_CONFIG),y)
39 # In this section, we need .config
44 $(SECHO) Finally finished compiling ...
47 include/bits/uClibc_config.h: .config
48 @if [ ! -x $(top_builddir)extra/config/conf ] ; then \
49 $(MAKE) -C $(top_builddir)extra/config conf; \
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
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
60 ifeq ($(ARCH_HAS_MMU),y)
61 export header_extra_args =
63 export header_extra_args = -n
65 headers: $(top_srcdir)include/bits/uClibc_config.h
67 $(top_srcdir)extra/scripts/fix_includes.sh \
68 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
70 if [ -f libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
71 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
73 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
75 $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h include/
76 @cd $(top_builddir)include/bits; \
78 for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
81 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
82 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
86 @cd $(top_builddir)include/sys; \
88 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
91 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
92 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
96 @cd $(top_builddir); \
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; \
103 $(RM) include/bits/sysnum.h; \
104 mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
106 ifeq ($(HAVE_SHARED),y)
107 $(MAKE) -C ldso headers-y
109 ifeq ($(UCLIBC_HAS_THREADS),y)
110 $(MAKE) -C libpthread headers-y
112 $(MAKE) -C libc/sysdeps/linux headers-y
114 # Command used to download source code
115 WGET:=wget --passive-ftp
117 LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
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) ; \
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
131 pre_subdirs: $(patsubst %, _pre_dir_%, $(PRE_DIRS))
132 $(patsubst %, _pre_dir_%, $(PRE_DIRS)): pregen
133 $(MAKE) -C $(patsubst _pre_dir_%, %, $@)
135 subdirs: $(patsubst %, _dir_%, $(DIRS))
136 $(patsubst %, _dir_%, $(DIRS)): pre_subdirs
137 $(MAKE) -C $(patsubst _dir_%, %, $@)
139 install: install_runtime install_dev finished2
142 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
144 # Installs header files.
146 $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
147 if [ "$(KERNEL_SOURCE)" == "$(DEVEL_PREFIX)" ] ; then \
148 extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
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
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
170 ifneq ($(UCLIBC_HAS_LOCALE),y)
171 # Remove iconv header since locale support is disabled.
172 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
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
178 ifneq ($(UCLIBC_HAS_XLOCALE),y)
179 # Remove xlocale header since extended locale support is disabled.
180 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
182 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
183 # Remove libintl header since gettext support is disabled.
184 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
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
191 ifneq ($(UCLIBC_HAS_WORDEXP),y)
192 # Remove wordexp header since wordexp support is disabled.
193 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
195 ifneq ($(UCLIBC_HAS_FTW),y)
196 # Remove ftw header since ftw support is disabled.
197 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
199 ifneq ($(UCLIBC_HAS_GLOB),y)
200 # Remove glob header since glob support is disabled.
201 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
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
207 ifneq ($(HAS_SHADOW),y)
208 # Remove shadow header since shadow password support is disabled.
209 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
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
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
221 -@for i in `find $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
222 chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
224 -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
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; \
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; \
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
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/'`; \
259 # Installs run-time libraries
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 \
269 $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
270 $(PREFIX)$(RUNTIME_PREFIX)lib; \
275 $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
277 # Installs helper applications, such as 'ldd' and 'ldconfig'
279 $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
283 $(SECHO) Finished installing ...
286 else # ifeq ($(HAVE_DOT_CONFIG),y)
291 @echo "Need to make a config file first, run: make menuconfig"
294 endif # ifeq ($(HAVE_DOT_CONFIG),y)
297 # ---------------------------------------------------------------------------
299 $(MAKE) -C extra/config conf
302 $(MAKE) -C extra/config ncurses mconf
304 menuconfig: extra/config/mconf
305 $(RM) -r include/bits
306 $(INSTALL) -d include/bits
307 @./extra/config/mconf extra/Configs/Config.in
310 config: extra/config/conf
311 $(RM) -r include/bits
312 $(INSTALL) -d include/bits
313 @./extra/config/conf extra/Configs/Config.in
315 oldconfig: extra/config/conf
316 $(RM) -r include/bits
317 $(INSTALL) -d include/bits
318 @./extra/config/conf -o extra/Configs/Config.in
320 randconfig: extra/config/conf
321 $(RM) -r include/bits
322 $(INSTALL) -d include/bits
323 @./extra/config/conf -r extra/Configs/Config.in
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
336 allnoconfig: extra/config/conf
337 $(RM) -r include/bits
338 $(INSTALL) -d include/bits
339 @./extra/config/conf -n extra/Configs/Config.in
341 defconfig: extra/config/conf
342 $(RM) -r include/bits
343 $(INSTALL) -d include/bits
344 @./extra/config/conf -d extra/Configs/Config.in
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
359 for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
360 $(RM) include/sys/$$i; \
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; \
367 @$(RM) include/linux include/asm*
368 -find . \( -name \*.o -o -name \*.os -o -name \*.oS \) -exec $(RM) {} \;
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
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
386 .PHONY: dummy subdirs release dist distclean clean config oldconfig menuconfig utils