forked from kamailio/kamailio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.utils
152 lines (109 loc) · 3.26 KB
/
Makefile.utils
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
# Kamailio build system
#
# utils Makefile
#(to be included from each util/ subdirectory)
#
#
# Variables that should be defined in the util Makefiles, prior to including
# this makefile:
#
# NAME - util binary name, with no path (MUST).
#
# COREPATH - path to the main/core directory (OPTIONAL, default ../..)
#
# DEFS - local extra defines (OPTIONAL)
#
# LIBS - local extra libs (OPTIONAL)
#
# SER_LIBS - ser/sr libs that should be compiled, linked against and installed
# along the binary. The format is: <path>/<shortname>, e.g.
# SER_LIBS=../../lib/srdb2/srdb2 for libsrdb2 with the sources
# in ../../lib/srdb2. (OPTIONAL)
#
UTIL_NAME=$(NAME)
# default path to the core makefiles
COREPATH ?=../..
ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
$(COREPATH)/Makefile.utils $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak
#override modules value, an util cannot have submodules
override modules=
override static_modules=
override static_modules_path=
# temporary def (visible only in the util makefile, not exported)
DEFS += -DMOD_NAME="utils/$(UTIL_NAME)"
ifneq ($(makefile_defs_included),1)
$(error "the local makefile does not include Makefile.defs!")
endif
ifeq ($(MAKELEVEL), 0)
# make called directly in the module dir!
else
# called by the main Makefile
ALLDEP+=$(COREPATH)/Makefile
endif
include $(COREPATH)/Makefile.sources
# if config was not loaded (makefile_defs!=1) ignore
# the rest of makefile and try only to remake the config
ifeq ($(makefile_defs),1)
# set CFLAGS & LDFLAGS
CFLAGS:=$(UTILS_CFLAGS)
LDFLAGS:=$(UTILS_LDFLAGS)
err_fail?=1
include $(COREPATH)/Makefile.dirs
include $(COREPATH)/Makefile.targets
include $(COREPATH)/Makefile.rules
include $(COREPATH)/Makefile.shared
# default: if not overwritten by the main Makefile, install in bin_dir
util_dst=$(bin_prefix)/$(bin_dir)
$(util_dst):
mkdir -p $(util_dst)
modules:
.PHONY: install
.PHONY: install-libs
install: $(NAME) $(util_dst) install-libs install-util-man
$(INSTALL_TOUCH) $(util_dst)/$(NAME)
$(INSTALL_BIN) $(NAME) $(util_dst)
ifneq (,$(SER_LIBS))
install-libs:
@for lib in $(dir $(SER_LIBS)); do \
$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
done; true
else
install-libs:
endif # $(SER_LIBS)
.PHONY: install-if-newer
install-if-newer: $(util_dst)/$(NAME)
$(util_dst)/$(NAME): $(NAME)
@$(MAKE) install
# README build rules
ifneq (,$(wildcard doc/Makefile))
#doc/Makefile present => we can generate README
README: doc/*.xml
$(MAKE) -C doc $(UTIL_NAME).txt
mv doc/$(UTIL_NAME).txt $@
else
# do nothing
README:
endif
#man page build rules
ifneq (,$(wildcard $(UTIL_NAME).xml))
$(UTIL_NAME).7: $(UTIL_NAME).xml
$(DOCBOOK) -s ../../doc/stylesheets/serdoc2man.xsl $<
man: $(UTIL_NAME).7
else
man:
endif
$(man_prefix)/$(man_dir)/man8:
mkdir -p $(man_prefix)/$(man_dir)/man8
.PHONY: install-util-man
#src-name man page install rules
ifneq (,$(wildcard $(UTIL_SRC_NAME).8))
install-util-man: $(man_prefix)/$(man_dir)/man8
sed -e "s#$(UTIL_SRC_NAME)#$(UTIL_NAME)#g" \
-e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
< $(UTIL_SRC_NAME).8 > $(man_prefix)/$(man_dir)/man8/$(UTIL_NAME).8
chmod 644 $(man_prefix)/$(man_dir)/man8/$(UTIL_NAME).8
else
install-util-man:
endif
endif # ifeq($(makefile_defs),1)
include $(COREPATH)/Makefile.cfg