OSDN Git Service

Protect against quoting changes.
[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 # Pull in the user's uClibc configuration, but do not
20 # pull in Rules.mak.....
21 TOPDIR=../
22 include $(TOPDIR).config
23
24 MAJOR_VERSION=0
25 UCLIBC_LDSO=ld-uClibc.so.$(MAJOR_VERSION)
26
27 # A nifty macro to make testing gcc features easier
28 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
29         then echo "$(1)"; else echo "$(2)"; fi)
30
31 # use '-Os' optimization if available, else use -O2, allow Config to override
32 OPTIMIZATION=$(call check_gcc,-Os,-O2)
33 UWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
34 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
35
36 ifndef CROSS
37 CROSS=
38 endif
39 CC= $(CROSS)gcc
40 AR= $(CROSS)ar
41 LD= $(CROSS)ld
42 NM= $(CROSS)nm
43 STRIPTOOL= $(CROSS)strip
44
45 INSTALL= install
46 LN= ln
47 RM= rm -f
48 override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
49 override LDFLAGS=-s
50 ifeq ($(DODEBUG),y)
51     override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
52     override LDFLAGS=
53 endif
54
55 # Make certain these contain a final "/", but no "//"s.
56 RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
57 DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
58
59
60 TARGETS = ldd ldconfig readelf
61
62 ifeq ($(HAVE_SHARED),y)
63     LIBRARY_CACHE=#-DUSE_CACHE
64     ifeq ($(BUILD_UCLIBC_LDSO),y)
65         LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
66         DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)
67     else
68         LDSO=$(SYSTEM_LDSO)
69         DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
70    endif
71 endif
72
73
74 XXFLAGS=
75 ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
76 XXFLAGS= -D__LDSO_LDD_SUPPORT
77 else
78 XXFLAGS=
79 endif
80
81 LDADD_LIBFLOAT=
82 ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
83     CFLAGS += $(call check_gcc,-msoft-float,)
84     #LDFLAGS+= -Wa,-mno-fpu
85 ifeq ($(strip $(subst ",, $(strip $(TARGET_ARCH)))),arm)
86     LDADD_LIBFLOAT=-lfloat
87 endif
88 endif
89
90 ifeq ($(strip $(HAVE_SHARED)),y)
91 all:    $(TARGETS)
92 else
93 all:
94 endif
95
96 headers:
97         $(LN) -fs $(TOPDIR)include/elf.h
98
99 readelf: readelf.c
100         $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
101         $(STRIPTOOL) -x -R .note -R .comment $@
102
103 ldconfig:       ldconfig.c readsoname.c
104         $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
105                 -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
106                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
107                 $^ -o $@ $(LDADD_LIBFLOAT)
108         $(STRIPTOOL) -x -R .note -R .comment $@
109
110 ldd:    ldd.c
111         $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
112                 -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
113                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
114                 $^ -o $@ $(LDADD_LIBFLOAT)
115         $(STRIPTOOL) -x -R .note -R .comment $@
116
117 clean:
118         $(RM) $(TARGETS) *.o *~ core *.target elf.h
119
120
121 readelf.c readsoname.c ldconfig.c ldd.c:        headers
122
123 install: all
124 ifeq ($(strip $(HAVE_SHARED)),y)
125         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
126         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
127         $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
128         $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
129         # For now, don't bother with readelf since surely the host
130         # system has binutils, or we couldn't have gotten this far...
131         #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
132 endif
133