OSDN Git Service

Rip out Peter's unacceptable "fix" and do the sane thing instead; build
[uclinux-h8/uClibc.git] / utils / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
4 #
5 # This program is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Library General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option) any
8 # later version.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Library General Public License
16 # along with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 TOPDIR=../
20 include $(TOPDIR)Rules.mak
21
22 TARGETS = ldd ldconfig readelf
23
24 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
25 TARGET_ICONV = iconv
26 else
27 TARGET_ICONV =
28 endif
29
30 # NOTE: We build the utils AFTER we have a uClibc-targeted toolchain.
31
32 ifeq ($(strip $(HAVE_SHARED)),y)
33 all:    $(TARGETS) $(TARGET_ICONV)
34 else
35 all:    $(TARGET_ICONV)
36 endif
37
38 headers:
39         @$(LN) -fs $(TOPDIR)include/elf.h
40
41 readelf: readelf.c
42         $(CC) $(CFLAGS) -Wl,-s $^ -o $@
43         $(STRIPTOOL) -x -R .note -R .comment $@
44
45 ldconfig:       ldconfig.c readsoname.c
46         $(CC) $(CFLAGS) -Wl,-s -static \
47                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
48                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
49                 $^ -o $@
50         $(STRIPTOOL) -x -R .note -R .comment $@
51
52 ldd:    ldd.c
53         $(CC) $(CFLAGS) $(PIEFLAG) $(LDPIEFLAG) -Wl,-s \
54                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
55                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
56                 $^ -o $@
57         $(STRIPTOOL) -x -R .note -R .comment $@
58
59 iconv: ../libc/misc/wchar/wchar.c
60         $(CC) $(CFLAGS) $(PIEFLAG) $(LDPIEFLAG) -Wl,-s \
61                 -DL_iconv_main \
62                 $^ -o $@
63         $(STRIPTOOL) -x -R .note -R .comment $@
64
65 ifeq ($(strip $(HAVE_SHARED)),y)
66 hostutils: ldd.host ldconfig.host readelf.host
67 else
68 hostutils: readelf.host
69 endif
70
71 ldd.host:       ldd.c
72         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s \
73                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
74                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
75                 $^ -o $@
76
77 ldconfig.host:  ldconfig.c readsoname.c
78         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s \
79                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
80                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
81                 $^ -o $@
82
83 readelf.host: readelf.c
84         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s $^ -o $@
85
86 clean:
87         $(RM) $(TARGETS) *.o *~ core *.target elf.h iconv *.host
88
89
90 readelf.c readsoname.c ldconfig.c ldd.c:        headers
91
92 install: all
93 ifeq ($(strip $(HAVE_SHARED)),y)
94         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
95         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
96         $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
97         $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
98         #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
99 endif
100 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
101         $(INSTALL) -m 755 iconv $(PREFIX)$(RUNTIME_PREFIX)usr/bin/iconv
102 endif