OSDN Git Service

Create libpthread_nonshared.a
[uclinux-h8/uClibc.git] / Makefile.in
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
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 \
13         release dist tags
14
15 include $(top_builddir)Rules.mak
16 sub_headers := headers
17
18 ifeq ($(HAVE_DOT_CONFIG),y)
19
20 all: pregen libs
21
22 # In this section, we need .config
23 -include .config.cmd
24
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
35
36 # last included to catch all the objects added by others (locales/threads)
37 include $(top_srcdir)libc/Makefile.in
38
39 include/bits/uClibc_config.h: extra/config/conf .config
40         $(INSTALL) -d $(dir $@)
41         @$< -o $(top_srcdir)extra/Configs/Config.in
42
43 # For the moment, we have to keep re-running this target 
44 # because the fix includes scripts rely on pre-processers 
45 # in order to generate the headers correctly :(.  That 
46 # means we can't use the $(HOSTCC) in order to get the 
47 # correct output.
48 ifeq ($(ARCH_USE_MMU),y)
49 export header_extra_args = 
50 else
51 export header_extra_args = -n
52 endif
53 HEADERS_BITS_COMMON := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common/bits/*.h))
54 HEADERS_BITS_ARCH   := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h))
55 HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_ARCH),$(HEADERS_BITS_COMMON))
56 headers: include/bits/uClibc_config.h
57         $(Q)$(MAKE) headers-y
58         $(Q)\
59         $(SHELL) $(top_srcdir)extra/scripts/fix_includes.sh \
60                 -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
61                 $(header_extra_args)
62         $(Q)\
63         set -e; \
64         if [ -f libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h ] ; then \
65                 $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/fpu_control.h include/ ; \
66         else \
67                 $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h include/ ; \
68         fi; \
69         for f in dl-osinfo.h hp-timing.h ; do \
70                 $(LN) -fs ../libc/sysdeps/linux/common/$$f include/ ; \
71         done
72         $(Q)\
73         cd include/bits; \
74         set -e; \
75         for i in $(HEADERS_BITS_COMMON) ; do \
76                 $(LN) -fs ../../libc/sysdeps/linux/common/bits/$$i .; \
77         done; \
78         for i in $(HEADERS_BITS_ARCH) ; do \
79                 $(LN) -fs ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$$i .; \
80         done
81         $(Q)\
82         cd include/sys; \
83         set -e; \
84         for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
85                 $(LN) -fs $$i .; \
86         done; \
87         if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
88                 for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
89                         $(LN) -fs $$i .; \
90                 done; \
91         fi
92         $(Q)\
93         set -e; \
94         cd $(top_builddir); \
95         tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \
96         [ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \
97         top_builddir=. CC="$(CC)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
98         if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \
99                 $(RM) $$tmp; \
100         else \
101                 mv -f $$tmp include/bits/sysnum.h; \
102         fi
103 ifeq ($(UCLIBC_HAS_LOCALE),y)
104         $(MAKE) locale_headers
105 endif
106
107 pregen: headers
108
109 install: install_runtime install_dev
110
111
112 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
113
114 # Installs header files.
115 install_headers:
116         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
117         printf ".svn\n.cvsignore\nCVS\n" > tar_exclude ; \
118         if [ "$(KERNEL_SOURCE)" = "$(PREFIX)$(DEVEL_PREFIX)" ] ; then \
119                 ls -1d include/linux include/asm* >> tar_exclude ; \
120         fi ; \
121         $(TAR) -chf - -X tar_exclude include \
122                 | $(TAR) -xf - -C $(PREFIX)$(DEVEL_PREFIX)
123         rm -f tar_exclude
124         printf '#ifndef _LIBC_INTERNAL_H\n#define _LIBC_INTERNAL_H 1\n#endif\n' > \
125                 $(PREFIX)$(DEVEL_PREFIX)include/libc-internal.h
126         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
127         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/_lfs_64.h
128         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_uintmaxtostr.h
129         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_sigaction.h
130         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_stat.h
131 ifneq ($(UCLIBC_HAS_FLOATS),y)
132         # Remove floating point related headers since float support is disabled.
133         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
134         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
135         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
136         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
137         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
138         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
139 endif
140 ifneq ($(UCLIBC_HAS_WCHAR),y)
141         # Remove wide char headers since wide char support is disabled.
142         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
143         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
144 endif
145 ifneq ($(UCLIBC_HAS_LOCALE),y)
146         # Remove iconv header since locale support is disabled.
147         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
148 endif
149 ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
150         # Remove printf header since custom print specifier support is disabled.
151         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
152 endif
153 ifneq ($(UCLIBC_HAS_XLOCALE),y)
154         # Remove xlocale header since extended locale support is disabled.
155         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
156 endif
157 ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
158         # Remove libintl header since gettext support is disabled.
159         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
160 endif
161 ifneq ($(UCLIBC_HAS_REGEX),y)
162         # Remove regex headers since regex support is disabled.
163         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
164         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
165 endif
166 ifneq ($(UCLIBC_HAS_WORDEXP),y)
167         # Remove wordexp header since wordexp support is disabled.
168         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
169 endif
170 ifneq ($(UCLIBC_HAS_FTW),y)
171         # Remove ftw header since ftw support is disabled.
172         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
173 endif
174 ifneq ($(UCLIBC_HAS_GLOB),y)
175         # Remove glob header since glob support is disabled.
176         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
177 endif
178 ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
179 ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
180         # Remove getopt header since gnu getopt support is disabled.
181         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
182 endif
183 endif
184 ifneq ($(HAS_SHADOW),y)
185         # Remove shadow header since shadow password support is disabled.
186         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
187 endif
188 ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
189         # Remove thread_db header since thread debug support is disabled.
190         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
191 endif
192 ifneq ($(UCLIBC_HAS_THREADS),y)
193         # Remove pthread headers since thread support is disabled.
194         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
195         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
196         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
197 endif
198 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
199         # Remove this as it is only used internally.
200         $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tls.h
201 endif
202         -@for i in `find $(PREFIX)$(DEVEL_PREFIX)include -type d` ; do \
203             chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
204         done
205         -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)include
206
207 # Installs development library links.
208 install_dev: install_headers
209         $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
210         -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
211 ifeq ($(HAVE_SHARED),y)
212         for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
213         sed -e 's/lib\///'` ; do \
214                 $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
215                 $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
216         done
217         if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
218                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
219                 sed     -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
220                         -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
221                         -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
222                         $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
223         fi
224 ifeq ($(UCLIBC_HAS_THREADS),y)
225 ifneq ($(LINUXTHREADS_OLD),y)
226         if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) ] ; then \
227                 $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
228                 cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
229                 echo "GROUP ( $(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) $(DEVEL_PREFIX)lib/libpthread_nonshared.a )" \
230                         >> $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
231         fi
232 endif
233 endif
234 ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
235         $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
236                 $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
237 endif
238 ifeq ($(DOPIC),y)
239 #       # If we build shared libraries then the static libs are PIC...
240 #       # Make _pic.a symlinks to make mklibs.py and similar tools happy.
241         if [ -d lib ] ; then \
242                 for i in `find lib/  -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
243                         $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
244                                 | sed -e 's/\.a$$/_pic.a/'`; \
245                 done ; \
246         fi
247 endif
248 endif
249
250 # Installs run-time libraries
251 install_runtime:
252 ifeq ($(HAVE_SHARED),y)
253         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
254         $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
255                 $(PREFIX)$(RUNTIME_PREFIX)lib
256         cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
257         @if [ -x lib/$(UCLIBC_LDSO_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
258             set -e; \
259                 $(SHELL_SET_X); \
260             $(INSTALL) -m 755 lib/$(UCLIBC_LDSO_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
261                         $(PREFIX)$(RUNTIME_PREFIX)lib; \
262         fi
263 endif
264
265 utils:
266         $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
267
268 # Installs helper applications, such as 'ldd' and 'ldconfig'
269 install_utils: utils
270         $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install
271
272 else # ifeq ($(HAVE_DOT_CONFIG),y)
273
274 all: menuconfig
275
276 headers:
277         @echo "Need to make a config file first, run: make menuconfig"
278         @false
279
280 endif # ifeq ($(HAVE_DOT_CONFIG),y)
281
282 # configuration
283 # ---------------------------------------------------------------------------
284 extra/config/conf extra/config/mconf:
285         $(MAKE) -C extra/config $(notdir $@)
286
287 menuconfig: extra/config/mconf
288         $(Q)./extra/config/mconf extra/Configs/Config.in
289
290 config: extra/config/conf
291         $(Q)./extra/config/conf extra/Configs/Config.in
292
293 oldconfig: extra/config/conf
294         $(Q)./extra/config/conf -o extra/Configs/Config.in
295
296 randconfig: extra/config/conf
297         $(Q)./extra/config/conf -r extra/Configs/Config.in
298
299 allyesconfig: extra/config/conf
300         $(Q)./extra/config/conf -y extra/Configs/Config.in
301         sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
302         sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
303         sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
304         sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
305         sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
306         $(Q)./extra/config/conf -o extra/Configs/Config.in
307
308 allnoconfig: extra/config/conf
309         $(Q)./extra/config/conf -n extra/Configs/Config.in
310
311 defconfig: extra/config/conf
312         $(Q)./extra/config/conf -d extra/Configs/Config.in
313
314 clean:
315         $(Q)$(RM) -r lib include/bits
316         $(RM) lib*/*.a ldso/*/*.a libpthread/*/*.a
317         $(RM) include/fpu_control.h include/dl-osinfo.h include/hp-timing.h
318         $(MAKE) -C extra/locale locale_clean
319         $(MAKE) headers_clean-y
320         $(MAKE) -s -C test clean
321         $(MAKE) -C utils utils_clean
322         @set -e; \
323         for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
324                 $(RM) include/sys/$$i; \
325         done; \
326         if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
327                 for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
328                         $(RM) include/sys/$$i; \
329                 done; \
330         fi
331         @$(RM) include/linux include/asm*
332         -find . \( -name \*.o -o -name \*.os -o -name \*.oS \) -exec $(RM) {} \;
333
334 distclean: clean
335         -find . \( -name core -o -name \*.orig -o -name \*~ \) -exec $(RM) {} \;
336         $(RM) .config .config.old .config.cmd
337         $(RM) extra/locale/*.tgz
338         $(MAKE) -C extra/config config_clean
339
340 dist release:
341         $(MAKE) -s distclean
342         $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.gz
343         svn -q export . ../uClibc-$(VERSION)
344         $(TAR) czf ../uClibc-$(VERSION).tar.gz -C .. uClibc-$(VERSION)
345         du -b ../uClibc-$(VERSION).tar.gz
346
347 test check:
348         $(Q)$(MAKE) -C test