OSDN Git Service

It is remotely possible the utils might even compile this time
[uclinux-h8/uclibc-ng.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 STRIP= $(CROSS)strip
44 LN=ln
45
46 override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
47 override LDFLAGS=-s
48 ifeq ($(DODEBUG),y)
49     override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
50     override LDFLAGS=
51 endif
52
53 # Make certain these contain a final "/", but no "//"s.
54 RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
55 DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
56
57
58 TARGETS = ldd ldconfig readelf
59
60 ifeq ($(HAVE_SHARED),y)
61     LIBRARY_CACHE=#-DUSE_CACHE
62     ifeq ($(BUILD_UCLIBC_LDSO),y)
63         LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
64         DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)
65     else
66         LDSO=$(SYSTEM_LDSO)
67         DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
68    endif
69 endif
70
71
72 XXFLAGS=
73 ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
74 XXFLAGS= -D__LDSO_LDD_SUPPORT
75 else
76 XXFLAGS=
77 endif
78
79 LDADD_LIBFLOAT=
80 ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
81     CFLAGS += $(call check_gcc,-msoft-float,)
82     #LDFLAGS+= -Wa,-mno-fpu
83 ifeq ($(strip $(TARGET_ARCH)),arm)
84     LDADD_LIBFLOAT=-lfloat
85 endif
86 endif
87
88 ifeq ($(strip $(HAVE_SHARED)),y)
89 all:    $(TARGETS)
90 else
91 all:
92 endif
93
94 headers:
95         $(LN) -fs $(TOPDIR)include/elf.h
96
97 readelf: readelf.c
98         $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
99         $(STRIP) -x -R .note -R .comment $@
100
101 ldconfig:       ldconfig.c readsoname.c
102         $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
103                 -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
104                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
105                 $^ -o $@ $(LDADD_LIBFLOAT)
106         $(STRIP) -x -R .note -R .comment $@
107
108 ldd:    ldd.c
109         $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
110                 -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
111                 -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
112                 $^ -o $@ $(LDADD_LIBFLOAT)
113         $(STRIP) -x -R .note -R .comment $@
114
115 clean:
116         $(RM) $(TARGETS) *.o *~ core *.target elf.h
117
118
119 readelf.c readsoname.c ldconfig.c ldd.c:        headers
120
121 install: all
122 ifeq ($(strip $(HAVE_SHARED)),y)
123         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
124         $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
125         $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
126         $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
127         # For now, don't bother with readelf since surely the host
128         # system has binutils, or we couldn't have gotten this far...
129         #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
130 endif
131