summaryrefslogtreecommitdiff
path: root/Makefile.libs
blob: 6a3eb1fec4fa717424fd29d0974f9e4025b7b69d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Makefile for uClibc
#
# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
#
# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
#

#LIB_NAME:=libsome

ifneq ($(strip $(LIB_NAME)),)
ifeq ($(strip $(srcdir)),)
srcdir=$(top_srcdir)$(LIB_NAME)
endif
ifeq ($(strip $($(LIB_NAME)_DIR)),)
$(LIB_NAME)_DIR:=$(top_builddir)$(LIB_NAME)
endif
ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),)
$(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
endif

ifeq ($(strip $($(LIB_NAME)_SRC)),)
ifeq ($(strip $($(LIB_NAME)_MSRC)),)
$(LIB_NAME)_SRC:=$(wildcard $(srcdir)/*.c)
endif
else
ifeq ($(strip $($(LIB_NAME)_OBJ)),)
$(LIB_NAME)_OBJ:=$(patsubst $(srcdir)/%.c,$($(LIB_NAME)_DIR)/%.o,$($(LIB_NAME)_SRC))
endif
endif
$(LIB_NAME)_OBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_OBJ))

$(LIB_NAME)_MOBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_MOBJ))

$(LIB_NAME)_ARCH_OBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_ARCH_OBJ))

libso-y+=$(top_builddir)lib/$(LIB_NAME).so
liba-y+=$(top_builddir)lib/$(LIB_NAME).a
libclean-y+=$(LIB_NAME)_clean

$($(LIB_NAME)_OBJ): %.o : %.c
	$(compile.c)

$($(LIB_NAME)_OBJ_PIC): %.os : %.c
	$(compile.c) $(PICFLAG)

$($(LIB_NAME)_MOBJ): $($(LIB_NAME)_MSRC)
	$(compile.m)

$($(LIB_NAME)_MOBJ_PIC): $($(LIB_NAME)_MSRC)
	$(compile.m) $(PICFLAG)

$($(LIB_NAME)_ARCH_OBJ): %.o : %.c
	$(compile.c)

$($(LIB_NAME)_ARCH_OBJ_PIC): %.os : %.c
	$(compile.c) $(PICFLAG)

# this should be changed to .os after libc/misc/internals/ is done
interp:=$(top_builddir)libc/misc/internals/interp.o
ifeq ($(strip $(EXTRA_LINK_LIBS)),)
EXTRA_LINK_LIBS=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
endif

$(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a $(interp)
	$(INSTALL) -d $(top_builddir)lib
	$(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
	$(LD) $(LDFLAGS) -soname=$(notdir $@).$(MAJOR_VERSION) -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) \
		$(EXTRA_LINK_OPTS) $(SHARED_START_FILES) --whole-archive $(firstword $^) \
		--no-whole-archive $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
	$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
	$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@

$(top_builddir)lib/$(LIB_NAME).so1: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_ARCH_OBJ_PIC)
	$(INSTALL) -d $(top_builddir)lib
	$(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
	$(LD) $(LDFLAGS) -soname=$(notdir $@).$(MAJOR_VERSION) -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) \
		$(EXTRA_LINK_OPTS) $(SHARED_START_FILES) $^ \
		$(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
	$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
	$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@

$($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_ARCH_OBJ_PIC)
ifneq ($(strip $(STRIP_FLAGS)),)
	$(STRIPTOOL) $(STRIP_FLAGS) $^
else
	$(STRIPTOOL) -x -R .note -R .comment $^
endif
	$(AR) $(ARFLAGS) $@ $^
	#(AR) $(ARFLAGS) $@ $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC)
	#(AR) $(ARFLAGS) $@ $($(LIB_NAME)_ARCH_OBJ_PIC)

ifeq ($(DOPIC),y)
$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a
	$(RM) $@
	cp $< $@
else
$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OBJ) $($(LIB_NAME)_MOBJ) $($(LIB_NAME)_ARCH_OBJ)
	$(RM) $@
	$(STRIPTOOL) -x -R .note -R .comment $^
	$(AR) $(ARFLAGS) $@ $^
	#(AR) $(ARFLAGS) $@ $($(LIB_NAME)_OBJ) $($(LIB_NAME)_MOBJ)
	#(AR) $(ARFLAGS) $@ $($(LIB_NAME)_ARCH_OBJ)
endif

$(LIB_NAME)_clean:
	rm -f $($(LIB_NAME)_DIR)/*.{o,os,a}

endif