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)))
46 override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
49 override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
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))))))
58 TARGETS = ldd ldconfig readelf
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)
67 DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
73 ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
74 XXFLAGS= -D__LDSO_LDD_SUPPORT
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
88 ifeq ($(strip $(HAVE_SHARED)),y)
95 $(LN) -fs $(TOPDIR)include/elf.h
98 $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
99 $(STRIP) -x -R .note -R .comment $@
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 $@
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 $@
116 $(RM) $(TARGETS) *.o *~ core *.target elf.h
119 readelf.c readsoname.c ldconfig.c ldd.c: headers
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