OSDN Git Service

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