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 silentoldconfig randconfig \
12 defconfig allyesconfig allnoconfig clean distclean \
15 include $(top_builddir)Rules.mak
16 sub_headers := headers
18 ifeq ($(HAVE_DOT_CONFIG),y)
22 # In this section, we need .config
25 include $(top_srcdir)ldso/Makefile.in
26 include $(top_srcdir)libcrypt/Makefile.in
27 include $(top_srcdir)libintl/Makefile.in
28 include $(top_srcdir)libm/Makefile.in
29 include $(top_srcdir)libnsl/Makefile.in
30 include $(top_srcdir)libresolv/Makefile.in
31 include $(top_srcdir)libutil/Makefile.in
32 include $(top_srcdir)libpthread/Makefile.in
33 include $(top_srcdir)librt/Makefile.in
34 include $(top_srcdir)extra/locale/Makefile.in
36 # last included to catch all the objects added by others (locales/threads)
37 include $(top_srcdir)libc/Makefile.in
39 include/bits/uClibc_config.h: extra/config/conf .config
40 $(Q)$(INSTALL) -d $(dir $@)
41 $(Q)@$< -o $(top_srcdir)extra/Configs/Config.in
42 $(top_srcdir)extra/scripts/conf-header.sh .config > include/bits/uClibc_config.h
45 # For the moment, we have to keep re-running this target
46 # because the fix includes scripts rely on pre-processers
47 # in order to generate the headers correctly :(. That
48 # means we can't use the $(HOSTCC) in order to get the
50 ifeq ($(ARCH_USE_MMU),y)
51 export header_extra_args =
53 export header_extra_args = -n
55 HEADERS_BITS_COMMON := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common/bits/*.h))
56 HEADERS_BITS_ARCH := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h))
57 HEADERS_BITS_SUBARCH :=
58 ifneq ($(TARGET_SUBARCH),)
59 HEADERS_BITS_SUBARCH := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/*.h))
61 HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_ARCH) $(HEADERS_BITS_SUBARCH),$(HEADERS_BITS_COMMON))
62 headers: include/bits/uClibc_config.h
66 if [ -e libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
67 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
69 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
71 for f in dl-osinfo.h hp-timing.h ; do \
72 $(LN) -fs ../libc/sysdeps/linux/common/$$f include/ ; \
77 for i in $(HEADERS_BITS_COMMON) ; do \
78 $(LN) -fs ../../libc/sysdeps/linux/common/bits/$$i .; \
80 for i in $(HEADERS_BITS_ARCH) ; do \
81 $(LN) -fs ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$$i .; \
83 for i in $(HEADERS_BITS_SUBARCH) ; do \
84 $(LN) -fs ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/$$i .; \
89 for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
92 if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
93 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
97 ifeq ($(UCLIBC_HAS_LOCALE),y)
98 $(MAKE) -C extra/locale locale_headers
105 cd $(top_builddir); \
106 tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \
107 [ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \
108 KERNEL_HEADERS="${KERNEL_HEADERS}" top_builddir=. CC="$(CC) $(CPU_CFLAGS)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
109 if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \
112 mv -f $$tmp include/bits/sysnum.h; \
116 install: install_runtime install_dev
119 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
121 $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
124 # Installs kernel header files (linux/*, asm/*, asm-generic/*).
125 install_kernel_headers: headers
126 top_builddir=$(top_builddir) \
127 $(top_srcdir)extra/scripts/install_kernel_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
129 # Installs header files.
130 install_headers: headers $(top_builddir)extra/scripts/unifdef
131 $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
132 top_builddir=$(top_builddir) \
133 $(top_srcdir)extra/scripts/install_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
134 printf '#ifndef _LIBC_INTERNAL_H\n#define _LIBC_INTERNAL_H 1\n#endif\n' > \
135 $(PREFIX)$(DEVEL_PREFIX)include/libc-internal.h
136 echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
137 $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
138 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
139 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/_lfs_64.h
140 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_uintmaxtostr.h
141 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_sigaction.h
142 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_stat.h
143 ifneq ($(UCLIBC_HAS_FLOATS),y)
144 # Remove floating point related headers since float support is disabled.
145 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
146 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
147 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
148 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
149 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
150 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
152 ifneq ($(UCLIBC_HAS_FENV),y)
153 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fenv.h \
154 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenv.h \
155 $(PREFIX)$(DEVEL_PREFIX)include/bits/fenvinline.h
157 ifneq ($(UCLIBC_HAS_WCHAR),y)
158 # Remove wide char headers since wide char support is disabled.
159 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
160 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
162 ifneq ($(UCLIBC_HAS_LOCALE),y)
163 # Remove iconv header since locale support is disabled.
164 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
166 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
167 # Remove printf header since custom print specifier support is disabled.
168 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
170 ifneq ($(UCLIBC_HAS_XLOCALE),y)
171 # Remove xlocale header since extended locale support is disabled.
172 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
174 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
175 # Remove libintl header since gettext support is disabled.
176 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
178 ifneq ($(UCLIBC_HAS_REGEX),y)
179 # Remove regex headers since regex support is disabled.
180 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
181 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
183 ifneq ($(UCLIBC_HAS_WORDEXP),y)
184 # Remove wordexp header since wordexp support is disabled.
185 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
187 ifneq ($(UCLIBC_HAS_FTW),y)
188 # Remove ftw header since ftw support is disabled.
189 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
191 ifneq ($(UCLIBC_HAS_GLOB),y)
192 # Remove glob header since glob support is disabled.
193 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
195 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
196 ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
197 # Remove getopt header since gnu getopt support is disabled.
198 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
201 ifneq ($(UCLIBC_HAS_SHADOW),y)
202 # Remove shadow header since shadow password support is disabled.
203 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
205 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
206 # Remove thread_db header since thread debug support is disabled.
207 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
209 ifneq ($(UCLIBC_HAS_THREADS),y)
210 # Remove pthread headers since thread support is disabled.
211 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
212 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
213 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
215 ifneq ($(HAVE_SHARED),y)
216 # Remove dlfcn header if we don't have shared libraries.
217 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dlfcn.h
218 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/dlfcn.h
220 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
221 # Remove this as it is only used internally.
222 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tls.h
224 ifneq ($(UCLIBC_HAS_GNU_ERROR),y)
225 # Remove error.h upon request
226 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/error.h
228 ifneq ($(UCLIBC_HAS_BSD_ERR),y)
229 # Remove err.h upon request
230 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/err.h
232 ifneq ($(UCLIBC_SUSV3_LEGACY),y)
233 # Remove timeb.h since the LEGACY ftime() was disabled upon request
234 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/timeb.h
236 ifneq ($(UCLIBC_HAS_EPOLL),y)
237 # Remove epoll.h since epoll_*() were disabled upon request
238 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/epoll.h
240 ifneq ($(UCLIBC_HAS_XATTR),y)
241 # Remove xattr.h since extended attributes were disabled upon request
242 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/xattr.h
244 ifneq ($(UCLIBC_HAS_PTY),y)
245 # Remove pty.h since PTY support was disabled upon request
246 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/pty.h
248 ifneq ($(UCLIBC_LINUX_SPECIFIC),y)
249 # Remove linux-specific headers as requested
250 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/inotify.h
251 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/perm.h
252 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/personality.h
254 ifneq ($(UCLIBC_SV4_DEPRECATED),y)
255 # Remove ustat.h since deprecated SV4 support was disabled upon request
256 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ustat.h
257 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/ustat.h
258 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/ustat.h
260 ifeq ($(UCLIBC_HAS_REALTIME)$(UCLIBC_HAS_ADVANCED_REALTIME),)
261 # Remove SUSv-realtime related message-queue headers upon request
262 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/mqueue.h
263 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/mqueue.h
264 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/mqueue.h
266 ifneq ($(UCLIBC_HAS_REALTIME),y)
267 # Remove SUSv-realtime related headers upon request
268 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sched.h
269 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/sched.h
270 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/sched.h
271 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
272 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/semaphore.h
273 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/semaphore.h
275 ifneq ($(UCLIBC_HAS_SOCKET),y)
276 # Remove socket related headers upon request
277 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/socket.h
278 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/socket.h
279 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/socketvar.h
281 ifneq ($(UCLIBC_HAS_CRYPT),y)
282 # Remove crypt.h since libcrypt was disabled upon request
283 $(RM) $(PREFIX)$(DEVEL_PREFIX)include/crypt.h
286 # Installs development library links.
287 install_dev: install_headers
288 $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
289 -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
290 ifeq ($(HAVE_SHARED),y)
291 for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
292 sed -e 's/lib\///'` ; do \
293 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
294 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
296 if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
297 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
298 sed -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
299 -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
300 -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
301 $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
303 ifeq ($(UCLIBC_HAS_THREADS),y)
304 ifneq ($(LINUXTHREADS_OLD),y)
305 if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) ] ; then \
306 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
307 cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
308 echo "GROUP ( $(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) $(DEVEL_PREFIX)lib/libpthread_nonshared.a )" \
309 >> $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
313 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
314 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
315 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
318 # # If we build shared libraries then the static libs are PIC...
319 # # Make _pic.a symlinks to make mklibs.py and similar tools happy.
320 if [ -d lib ] ; then \
321 for i in `find lib/ -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
322 $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
323 | sed -e 's/\.a$$/_pic.a/'`; \
328 ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
329 for file in lib/lib*.gdb; do \
330 if test -f $$file; then \
331 $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \
332 $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \
333 $(PREFIX)$(DEVEL_PREFIX)lib; \
338 # Installs run-time libraries
340 ifeq ($(HAVE_SHARED),y)
341 $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
342 $(INSTALL) -m 644 lib/lib*-$(VERSION).so \
343 $(PREFIX)$(RUNTIME_PREFIX)lib
344 cd lib && $(TAR) -cf - *.so.* | $(TAR) -xf - -C $(PREFIX)$(RUNTIME_PREFIX)lib
345 @if [ -x lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so ] ; then \
348 $(INSTALL) -m 755 lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so \
349 $(PREFIX)$(RUNTIME_PREFIX)lib; \
354 $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
356 # Installs helper applications, such as 'ldd' and 'ldconfig'
358 $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install
360 else # ifeq ($(HAVE_DOT_CONFIG),y)
365 @echo "Need to make a config file first, run: make menuconfig"
368 endif # ifeq ($(HAVE_DOT_CONFIG),y)
371 $(INSTALL) -d include/bits
374 # ---------------------------------------------------------------------------
375 extra/config/conf extra/config/mconf: include/bits
376 # TODO: this results in "make[1]: `conf' is up to date" printed
377 # on every rebuild, because extra/config/conf is already built
378 # on previous make run. Make it "test -x $@ || ..." (simple & a bit wrong)
379 # or "make -q -C extra/config $(notdir $@) || ..." (less readable)?
380 $(Q)$(MAKE) -C extra/config $(notdir $@)
382 menuconfig: extra/config/mconf include/bits
383 $(Q)./extra/config/mconf extra/Configs/Config.in
385 config: extra/config/conf include/bits
386 $(Q)./extra/config/conf extra/Configs/Config.in
388 oldconfig: extra/config/conf include/bits
389 $(Q)./extra/config/conf -o extra/Configs/Config.in
391 silentoldconfig: extra/config/conf include/bits
392 $(Q)./extra/config/conf -s extra/Configs/Config.in
394 randconfig: extra/config/conf include/bits
395 $(Q)./extra/config/conf -r extra/Configs/Config.in
397 allyesconfig: extra/config/conf include/bits
398 $(Q)./extra/config/conf -y extra/Configs/Config.in
399 sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
400 sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
401 sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
402 sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
403 sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
404 $(Q)./extra/config/conf -o extra/Configs/Config.in
406 allnoconfig: extra/config/conf include/bits
407 $(Q)./extra/config/conf -n extra/Configs/Config.in
409 defconfig: extra/config/conf include/bits
410 $(Q)./extra/config/conf -d extra/Configs/Config.in \
411 -D extra/Configs/defconfigs/$(ARCH)
414 $(Q)$(RM) -r lib include/bits
415 $(RM) ldso/*/*.a libpthread/*/*.a libc/*.a libcrypt/*.a libintl/*.a \
416 libm/*.a libnsl/*.a libpthread/*.a libresolv/*.a librt/*.a \
417 libutil/*.a lib/*.a \
418 include/fpu_control.h include/dl-osinfo.h include/hp-timing.h
419 $(MAKE) objclean-y headers_clean-y
420 $(MAKE) -s -C test clean
421 $(MAKE) -C utils utils_clean
423 for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
424 $(RM) include/sys/$$i; \
426 if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
427 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
428 $(RM) include/sys/$$i; \
431 @$(RM) include/linux include/asm*
432 $(RM) $(top_builddir)extra/scripts/unifdef
435 -find . \( -name core -o -name \*.orig -o -name \*~ -o -name .\*.dep \) -exec $(RM) {} \;
436 $(RM) .config .config.old .config.cmd
437 $(RM) extra/locale/*.tgz
438 $(MAKE) -C extra/config distclean
441 $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
442 svn -q export . ../uClibc-$(VERSION)
443 $(TAR) cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
444 du -b ../uClibc-$(VERSION).tar.bz2