forked from kamailio/kamailio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.libs
162 lines (126 loc) · 4.35 KB
/
Makefile.libs
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Kamailio build system
#
# module Makefile
#(to be included from each library makefile)
#
# NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library
# makefile
#
ifneq ($(makefile_defs_included), 1)
$(error "the local makefile does not include Makefile.defs!")
endif
ifneq (,$(filter install% %install install, $(MAKECMDGOALS)))
compile_for_install:=yes
ifeq ($(quiet),verbose)
$(info install mode)
endif # verbose
endif
ifeq ($(NAME),)
$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
endif
ifeq ($(MAJOR_VER),)
$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
endif
ifeq ($(MINOR_VER),)
$(error NAME, MAJOR_VER and MINOR_VER must be defined in the library Makefile)
endif
ifeq ($(BUGFIX_VER),)
BUGFIX_VER:=0
endif
# if config was not loaded (makefile_defs!=1) ignore
# the rest of makefile and try only to remake the config
ifeq ($(makefile_defs),1)
ifeq ($(OS), darwin)
LIB_NAME:= \
$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME).$(MAJOR_VER)$(LIB_SUFFIX)
LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
# on darwin we add an extra dependency on a file containing the install
# name (we want to rebuild the library if the install path changed)
# this is needed because instead of a rpath link option, on darwin the
# path to a linked library is taken from the library itself (the path
# is built-in the library)
LIBINAME_F:=libiname.lst
NAME_LD_FLAGS= -compatibility_version $(MAJOR_VER).$(MINOR_VER) \
-current_version $(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER) \
-install_name $(LIB_INSTALL_NAME)
else
LIB_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER).$(MINOR_VER)
LIB_RUNTIME_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX).$(MAJOR_VER)
LIB_LINK_NAME:=$(LIB_PREFIX)$(NAME)$(LIB_SUFFIX)
NAME_LD_FLAGS= $(LIB_SONAME)$(LIB_RUNTIME_NAME)
LIBINAME_F:=
endif
ifeq ($(strip $(compile_for_install)),yes)
LIB_INSTALL_NAME:=$(lib_target)/$(LIB_RUNTIME_NAME)
else
LIB_INSTALL_NAME:=$(shell pwd)/$(LIB_RUNTIME_NAME)
endif
COREPATH ?=../..
ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
$(COREPATH)/Makefile.libs $(COREPATH)/config.mak
ifeq ($(MAKELEVEL), 0)
# make called directly in the library dir!
else
# called by the main Makefile
ALLDEP+=$(COREPATH)/Makefile $(COREPATH)/Makefile.defs
endif
include $(COREPATH)/Makefile.sources
CFLAGS:=$(LIB_CFLAGS)
LDFLAGS:=$(LIB_LDFLAGS) $(NAME_LD_FLAGS)
NAME:=$(LIB_NAME)
include $(COREPATH)/Makefile.targets
include $(COREPATH)/Makefile.rules
ifeq (,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
ifneq ($(strip $(LIBINAME_F)),)
-include $(LIBINAME_F)
ifneq ($(strip $(LIB_INSTALL_NAME)), $(strip $(COMPILED_INAME)))
$(shell rm -f $(LIBINAME_F))
endif
endif
endif
$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) $(LIBINAME_F)
$(LIB_RUNTIME_NAME):
-@ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
$(LIB_LINK_NAME):
ifeq ($(OS), freebsd)
-@ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
else
-@ln -s $(LIB_NAME) $(LIB_LINK_NAME)
endif
.PHONY: link_clean
link_clean:
-@rm -f $(LIB_RUNTIME_NAME)
-@rm -f $(LIB_LINK_NAME)
local-clean: link_clean
.PHONY: libiname_clean
libiname_clean:
-@rm -f libiname.lst
local-clean: libiname_clean
$(lib_prefix)/$(lib_dir):
mkdir -p $(lib_prefix)/$(lib_dir)
.PHONY: install
install: $(LIB_NAME) $(lib_prefix)/$(lib_dir) $(LIBINAME_F)
ifeq ($(OS), freebsd)
$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
rm -f $(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME)
cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
else
$(INSTALL_TOUCH) $(lib_prefix)/$(lib_dir)/$(LIB_NAME)
$(INSTALL_LIB) $(LIB_NAME) $(lib_prefix)/$(lib_dir)
rm -f $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) \
$(lib_prefix)/$(lib_dir)/$(LIB_LINK_NAME)
cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)
cd $(lib_prefix)/$(lib_dir) ; ln -s $(LIB_NAME) $(LIB_LINK_NAME)
endif
.PHONY:install-if-newer
install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME)
$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
@$(MAKE) install
ifneq ($(strip $(LIBINAME_F)),)
$(LIBINAME_F): $(ALLDEP)
@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
endif
endif # ifeq ($(makefile_defs),1)
include $(COREPATH)/Makefile.cfg