OSDN Git Service

730d95c237f47953f550a2e868344dd705590845
[uclinux-h8/uClibc.git] / ldso / libdl / 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
21 TOPDIR=../../
22 include $(TOPDIR)Rules.mak
23
24 XXFLAGS=$(XWARNINGS) $(SSP_CFLAGS) $(SSP_ALL_CFLAGS)
25 ifeq ($(DODEBUG),y)
26 XXFLAGS+=-O0 -g3
27 else
28 XXFLAGS+=$(OPTIMIZATION)
29 endif
30 XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
31         -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
32         -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I$(TOPDIR)include
33
34 XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
35 ifeq ($(SUPPORT_LD_DEBUG),y)
36 XXFLAGS+=-D__SUPPORT_LD_DEBUG__
37 endif
38 XXFLAGS_NOPIC:=$(XXFLAGS)
39 ifeq ($(DOPIC),y)
40     XXFLAGS += $(PICFLAG) -DSHARED
41 endif
42
43 # BEWARE!!! At least mips* will die if -O0 is used!!!
44 ifeq ($(TARGET_ARCH),mips)
45 XXFLAGS := $(XXFLAGS:-O0=-O1)
46 endif
47
48 LIB_NAME := libdl
49 AR_LIB_NAME := $(TOPDIR)lib/$(LIB_NAME).a
50 SO_LIB_NAME := $(TOPDIR)lib/$(LIB_NAME).so
51 SO_FULL_NAME := $(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
52
53 CSRC := libdl.c
54 OBJS := libdl.o
55 PIC_OBJS := libdl_pic.o
56
57 # we do not get here, do we need a libdl.a, if ld.so is not ours?
58 #ifeq ($(HAVE_SHARED),y)
59 all: $(AR_LIB_NAME) $(SO_LIB_NAME)
60 #else
61 #all: $(AR_LIB_NAME)
62 #endif
63
64 $(AR_LIB_NAME): $(OBJS) ../ldso/$(TARGET_ARCH)/resolve.o
65         $(INSTALL) -d $(TOPDIR)lib
66         $(RM) $@
67         $(AR) $(ARFLAGS) $@ $^
68
69 shared_$(LIB_NAME).a: $(PIC_OBJS)
70         $(RM) $@
71         $(STRIPTOOL) -x -R .note -R .comment $^
72         $(AR) $(ARFLAGS) $@ $^
73
74 # this will be built only on the second round, when libc.so is present,
75 # else we would link against libc.a
76 $(SO_LIB_NAME): shared_$(LIB_NAME).a
77         if [ -f $(TOPDIR)lib/libc.so ] ; then \
78                 $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $@ ; \
79                 $(LD) $(LDFLAGS) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
80                         -o $(TOPDIR)lib/$(SO_FULL_NAME) -fini dl_cleanup --whole-archive $< \
81                         --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
82                         -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(TOPDIR)lib/$(UCLIBC_LDSO) $(LIBGCC) ; \
83                 $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) ; \
84                 $(LN) -sf $(SO_FULL_NAME) $@ ; \
85         fi
86
87 $(OBJS): %.o : %.c
88         $(CC) $(XXFLAGS_NOPIC) -c $< -o $@
89         $(STRIPTOOL) -x -R .note -R .comment $*.o
90
91 libdl_pic.o: libdl.c
92         $(CC) $(XXFLAGS) -c $< -o $@
93
94 clean:
95         $(RM) *.[oa] *~ core