summaryrefslogtreecommitdiff
path: root/makefiles/gmake/libs.mk
blob: c074b76740e73368afc639881e88d847377b7f64 (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
# provides explicit library rules
#
# requires:
# - STATIC_LIB: name of the static library
# - DYNAMIC_LIB: soname and versions of the shared library
# - all others like OBJS, LIBS, SH_OBJS, LDFLAGS
#
# provides:
# - targets to build the static and dynamic version of the project's library
#

ifeq "$(PLATFORM)" "LINUX"
ifeq "$(COMPILER)" "tcc"
SO_FLAGS = -shared
else
ifeq "$(COMPILER)" "pcc"
SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
else
SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif
endif
endif

ifeq "$(PLATFORM)" "SUNOS"
ifeq "$(COMPILER)" "gcc"
SO_FLAGS = -shared -Wl,-h,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif
ifeq "$(COMPILER)" "spro"
SO_FLAGS = -G -h $(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif
endif

ifeq "$(PLATFORM)" "FREEBSD"
SO_FLAGS = -shared -Wl,-x,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif

ifeq "$(PLATFORM)" "OPENBSD"
SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif

ifeq "$(PLATFORM)" "NETBSD"
SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif

ifeq "$(PLATFORM)" "CYGWIN"
SO_FLAGS = -shared -Wl,-soname,$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR)
endif

ifneq "$(STATIC_LIB)" ""
$(STATIC_LIB) : $(OBJS) $(CPP_OBJS)
	$(AR) cr $@ $(OBJS) $(CPP_OBJS)
else
$(STATIC_LIB) :
endif

ifneq "$(DYNAMIC_LIB)" ""
$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) : $(SH_OBJS)
	$(LINK) $(SO_FLAGS) -o $@ $(LDFLAGS) $(SH_OBJS) $(LIBS)
else
$(DYNAMIC_LIB).$(DYNAMIC_LIB_MAJOR).$(DYNAMIC_LIB_MINOR).$(DYNAMIC_LIB_PATCH) :
endif

ifneq "$(TEST_DYNAMIC_LIB)" ""
$(TEST_DYNAMIC_LIB).$(TEST_DYNAMIC_LIB_MAJOR).$(TEST_DYNAMIC_LIB_MINOR).$(TEST_DYNAMIC_LIB_PATCH) : $(SH_OBJS)
	$(LINK) $(SO_FLAGS) -o $@ $(LDFLAGS) $(SH_OBJS) $(LIBS)
else
$(TEST_DYNAMIC_LIB).$(TEST_DYNAMIC_LIB_MAJOR).$(TEST_DYNAMIC_LIB_MINOR).$(TEST_DYNAMIC_LIB_PATCH) :
endif