OSDN Git Service

utils should be built all the time (iconv), disable building readelf
[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 CFLAGS+=$(SSP_ALL_CFLAGS)
23
24 TARGETS = ldd ldconfig
25
26 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
27 TARGET_ICONV = iconv
28 else
29 TARGET_ICONV =
30 endif
31
32 # NOTE: We build the utils AFTER we have a uClibc-targeted toolchain.
33
34 ifeq ($(strip $(HAVE_SHARED)),y)
35 all: $(TARGETS) $(TARGET_ICONV)
36 else
37 all: $(TARGET_ICONV)
38 endif
39
40 headers:
41         @$(LN) -fs $(TOPDIR)include/elf.h
42
43 readelf.c ldconfig.c ldd.c:     headers
44
45 readelf: readelf.c
46         $(CC) $(CFLAGS) $^ -o $@
47         $(STRIPTOOL) -s -x -R .note -R .comment $@
48
49 ifeq ($(strip $(UCLIBC_STATIC_LDCONFIG)),y)
50 LDCONFIG_CFLAGS := -static
51 else
52 LDCONFIG_CFLAGS := $(PIEFLAG) $(LDPIEFLAG)
53 endif
54 ldconfig: ldconfig.c
55         $(CC) $(CFLAGS) $(LDCONFIG_CFLAGS) \
56                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
57                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
58                 $^ -o $@
59         $(STRIPTOOL) -s -x -R .note -R .comment $@
60
61 ldd: ldd.c
62         $(CC) $(CFLAGS) $(PIEFLAG) $(LDPIEFLAG) \
63                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
64                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
65                 $^ -o $@
66         $(STRIPTOOL) -s -x -R .note -R .comment $@
67
68 iconv: ../libc/misc/wchar/wchar.c
69         $(CC) $(CFLAGS) $(PIEFLAG) $(LDPIEFLAG) \
70                 -DL_iconv_main \
71                 $^ -o $@
72         $(STRIPTOOL) -s -x -R .note -R .comment $@
73
74 ifeq ($(strip $(HAVE_SHARED)),y)
75 hostutils: ldd.host ldconfig.host readelf.host
76 else
77 hostutils: readelf.host
78 endif
79
80 ldd.host: ldd.c
81         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s \
82                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
83                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
84                 $^ -o $@
85
86 ldconfig.host: ldconfig.c
87         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s \
88                 -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
89                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
90                 $^ -o $@
91
92 readelf.host: readelf.c
93         $(HOSTCC) $(HOSTCFLAGS) -Wl,-s $^ -o $@
94
95 clean:
96         $(RM) $(TARGETS) *.o *~ core *.target elf.h iconv *.host
97
98 install: all
99 ifeq ($(strip $(HAVE_SHARED)),y)
100         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
101         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
102         $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
103         $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
104         #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
105 endif
106 ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
107         $(INSTALL) -m 755 iconv $(PREFIX)$(RUNTIME_PREFIX)usr/bin/iconv
108 endif