OSDN Git Service

Updated for the CRIS port.
[uclinux-h8/uClibc.git] / ldso / ldso / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
5 #
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Library General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option) any
9 # later version.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Library General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
21 # other sundry sources.  Files within this library are copyright by their
22 # respective copyright holders.
23
24
25 TOPDIR=../../
26 DOPIC=true
27 include $(TOPDIR)Rules.mak
28 LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
29 LIBGCC:=$(shell $(CC) -print-libgcc-file-name)
30
31 # Enable this to enable all the code needed to support traditional ldd
32 # (i.e. where the shared library loader does all the heavy lifting)
33 # Since this currently only saves about 300 bytes, I'm going to leave 
34 # it enabled...
35 XXFLAGS+= -DLD_TRACE
36
37 # Enable this to enable all the code needed for debugging the runtime 
38 # linking of an application using the LD_DEBUG environment variable:
39 #   LD_DEBUG=token1,token2,..  prog
40 # enables diagnostics to the stderr.
41 # For now there are these tokens possible:
42 #    bindings      displays the resolve processing (function calls); detail shows the relocation patch
43 #    detail        provide more information for some options
44 #    move          display copy processings
45 #    reloc         display relocation processing; detail shows the relocation patch
46 #    symbols       display symbol table processing
47 #
48 # The additional environment variable:
49 #    LD_DEBUG_OUTPUT=file
50 # redirects the diagnostics to an output file created using
51 # the specified name and the process id as a suffix.
52 #
53 # try this
54 # $ LD_DEBUG=binding,move,symbols,reloc,detail LD_DEBUG_OUTPUT=appname ./appname
55 #
56 #XXFLAGS+= -DSUPPORT_LD_DEBUG
57
58 # Enable this for the very very early debugging.  Really only useful
59 # for people porting to new architectures.
60 #XXFLAGS+= -DLD_DEBUG
61
62 # Enable this to never actually fixup symbols...
63 #XXFLAGS+= -DLD_NEVER_FIXUP_SYMBOLS
64
65 XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
66         -DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
67         -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
68 LDFLAGS=-shared --warn-common --export-dynamic --sort-common \
69         -z combreloc --discard-locals --discard-all
70 CSRC= ldso.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
71 COBJS=$(patsubst %.c,%.o, $(CSRC))
72 ASRC=$(shell ls $(TARGET_ARCH)/*.S)
73 AOBJS=$(patsubst %.S,%.o, $(ASRC))
74 OBJS=$(AOBJS) $(COBJS)
75
76 ifeq ($(strip $(TARGET_ARCH)),cris)
77 LDFLAGS+=-mcrislinux
78 endif
79
80 ifneq ($(strip $(DODEBUG)),true)
81 LDFLAGS+=-s
82 endif
83
84 all: lib
85
86 lib:: ldso.h $(OBJS) $(DLINK_OBJS)
87         $(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \
88                 -o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC);
89         install -d $(TOPDIR)lib 
90         install -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
91         (cd $(TOPDIR)lib && ln -sf $(LDSO_FULLNAME) $(UCLIBC_LDSO))
92
93 ldso.h: Makefile
94         echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > ldso.h
95         echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> ldso.h
96
97
98 $(COBJS): %.o : %.c
99         $(CC) $(CFLAGS) $(XXFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
100         $(STRIPTOOL) -x -R .note -R .comment $*.o
101
102 $(AOBJS): %.o : %.S
103         $(CC) $(CFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
104         $(STRIPTOOL) -x -R .note -R .comment $*.o
105
106 ldso.o: ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c \
107         ld_hash.h ld_string.h ld_syscall.h ldso.h linuxelf.h
108
109 clean::
110         $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
111