3 # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
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
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
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
19 # Pull in the user's uClibc configuration, but do not
20 # pull in Rules.mak.....
22 include $(TOPDIR).config
25 UCLIBC_LDSO=ld-uClibc.so.$(MAJOR_VERSION)
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)
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)))
43 STRIPTOOL= $(CROSS)strip
48 override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
51 override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
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))))))
60 TARGETS = ldd ldconfig readelf
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)
69 DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
75 ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
76 XXFLAGS= -D__LDSO_LDD_SUPPORT
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
90 ifeq ($(strip $(HAVE_SHARED)),y)
97 $(LN) -fs $(TOPDIR)include/elf.h
100 $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
101 $(STRIPTOOL) -x -R .note -R .comment $@
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 $@
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 $@
118 $(RM) $(TARGETS) *.o *~ core *.target elf.h
121 readelf.c readsoname.c ldconfig.c ldd.c: headers
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