4
# Copyright Ericsson AB 2010-2011. All Rights Reserved.
6
# The contents of this file are subject to the Erlang Public License,
7
# Version 1.1, (the "License"); you may not use this file except in
8
# compliance with the License. You should have received a copy of the
9
# Erlang Public License along with this software. If not, it can be
10
# retrieved online at http://www.erlang.org/.
12
# Software distributed under the License is distributed on an "AS IS"
13
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
# the License for the specific language governing rights and limitations
20
include $(DIAMETER_TOP)/make/target.mk
21
include $(DIAMETER_TOP)/make/$(TARGET)/rules.mk
23
include $(ERL_TOP)/make/target.mk
24
include $(ERL_TOP)/make/$(TARGET)/otp.mk
27
# ----------------------------------------------------
29
# ----------------------------------------------------
35
# ----------------------------------------------------
36
# Release directory specification
37
# ----------------------------------------------------
39
RELSYSDIR = $(RELEASE_PATH)/lib/diameter-$(VSN)
41
# Where to put/find things.
45
# Dumbed down to make 3.80. In 3.81 and later it's just $(realpath $(EBIN)).
46
ABS_EBIN := $(shell cd $(EBIN) && pwd)
48
# Where make should look for dependencies.
49
VPATH = .:base:compiler:transport:gen
51
# ----------------------------------------------------
53
# ----------------------------------------------------
57
# Modules generated from dictionary specifications.
58
DICT_MODULES = $(DICTS:%=gen/diameter_gen_%)
59
DICT_ERLS = $(DICT_MODULES:%=%.erl)
60
DICT_HRLS = $(DICT_MODULES:%=%.hrl)
62
# Modules to build before compiling dictionaries.
63
COMPILER_MODULES = $(notdir $(filter compiler/%, $(CT_MODULES))) \
66
# All handwritten modules from which a depend.mk is generated.
71
# Modules whose names are inserted into the app file.
76
# Modules for which to build beams.
82
# What to build for the 'opt' target.
84
$(patsubst %, $(EBIN)/%.$(EMULATOR), $(notdir $(TARGET_MODULES))) \
88
# Subdirectories of src to release modules into.
89
TARGET_DIRS = $(sort $(dir $(TARGET_MODULES)))
91
APP_FILE = diameter.app
92
APP_SRC = $(APP_FILE).src
93
APP_TARGET = $(EBIN)/$(APP_FILE)
95
APPUP_FILE = diameter.appup
96
APPUP_SRC = $(APPUP_FILE).src
97
APPUP_TARGET = $(EBIN)/$(APPUP_FILE)
99
# ----------------------------------------------------
101
# ----------------------------------------------------
104
ERL_COMPILE_FLAGS += -Ddebug
107
ERL_COMPILE_FLAGS += \
108
+'{parse_transform,sys_pre_attributes}' \
109
+'{attribute,insert,app_vsn,$(APP_VSN)}' \
115
# -pa is to be able to include_lib from the include directory: the
116
# path must contain the application name.
118
# ----------------------------------------------------
120
# ----------------------------------------------------
122
# erl/hrl from dictionary file.
123
gen/diameter_gen_%.erl gen/diameter_gen_%.hrl: dict/%.dia
124
../bin/diameterc -o gen -i $(EBIN) $<
129
@$(MAKE) TYPE=debug opt
131
# The dictionary parser.
132
gen/$(DICT_YRL).erl: compiler/$(DICT_YRL).yrl
133
$(ERLC) -Werror -o $(@D) $<
135
# Generate the app file.
136
$(APP_TARGET): $(APP_SRC) ../vsn.mk modules.mk
137
M=`echo $(notdir $(APP_MODULES)) | tr ' ' ,`; \
138
sed -e 's;%VSN%;$(VSN);' \
139
-e "s;%MODULES%;$$M;" \
142
$(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk
143
sed -e 's;%VSN%;$(VSN);' $< > $@
145
app: $(APP_TARGET) $(APPUP_TARGET)
150
list = echo $(1):; echo $($(1)) | tr ' ' '\n' | sort | sed 's@^@ @'
153
@echo ========================================
156
@$(call list,DICT_YRL)
158
@$(call list,RT_MODULES)
160
@$(call list,CT_MODULES)
162
@$(call list,TARGET_MODULES)
164
@$(call list,TARGET_DIRS)
166
@$(call list,EXTERNAL_HRLS)
168
@$(call list,INTERNAL_HRLS)
170
@$(call list,EXAMPLES)
173
@echo ========================================
176
rm -f $(TARGET_FILES) gen/*
179
# ----------------------------------------------------
181
# ----------------------------------------------------
184
include $(DIAMETER_TOP)/make/release_targets.mk
186
include $(ERL_TOP)/make/otp_release_targets.mk
189
# Can't $(INSTALL_DIR) more than one directory at a time on Solaris.
192
for d in bin ebin examples include src/dict $(TARGET_DIRS:%/=src/%); do \
193
$(INSTALL_DIR) $(RELSYSDIR)/$$d; \
195
$(INSTALL_SCRIPT) $(BINS:%=../bin/%) $(RELSYSDIR)/bin
196
$(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin
197
$(INSTALL_DATA) $(EXAMPLES:%=../examples/%) $(RELSYSDIR)/examples
198
$(INSTALL_DATA) $(EXTERNAL_HRLS:%=../include/%) $(DICT_HRLS) \
200
$(INSTALL_DATA) $(DICTS:%=dict/%.dia) $(RELSYSDIR)/src/dict
201
$(MAKE) $(TARGET_DIRS:%/=release_src_%)
203
$(TARGET_DIRS:%/=release_src_%): release_src_%:
204
$(INSTALL_DATA) $(filter $*/%, $(TARGET_MODULES:%=%.erl) \
206
$(filter $*/%, compiler/$(DICT_YRL).yrl) \
211
# ----------------------------------------------------
213
# ----------------------------------------------------
215
gen/diameter_gen_base_accounting.erl gen/diameter_gen_relay.erl \
216
gen/diameter_gen_base_accounting.hrl gen/diameter_gen_relay.hrl: \
217
$(EBIN)/diameter_gen_base_rfc3588.$(EMULATOR)
219
gen/diameter_gen_base_rfc3588.erl gen/diameter_gen_base_rfc3588.hrl: \
220
$(COMPILER_MODULES:%=$(EBIN)/%.$(EMULATOR))
222
$(DICT_MODULES:gen/%=$(EBIN)/%.$(EMULATOR)): \
223
$(INCDIR)/diameter.hrl \
224
$(INCDIR)/diameter_gen.hrl
228
# Generate dependencies makefile.
229
depend.mk: depend.sed $(MODULES:%=%.erl) Makefile
230
(for f in $(MODULES); do \
231
(echo $$f; cat $$f.erl) | sed -f $<; \
237
.PHONY: app clean depend dict info release_subdir
238
.PHONY: debug opt release_docs_spec release_spec
239
.PHONY: $(TARGET_DIRS:%/=%) $(TARGET_DIRS:%/=release_src_%)
241
# Keep intermediate files.
242
.SECONDARY: $(DICT_ERLS) $(DICT_HRLS) gen/$(DICT_YRL:%=%.erl)
244
# ----------------------------------------------------
245
# Targets using secondary expansion (make >= 3.81)
246
# ----------------------------------------------------
250
# Make beams from a subdirectory.
251
$(TARGET_DIRS:%/=%): \
253
$(EBIN)/%.$(EMULATOR), \
254
$$(filter $$@/%, $(TARGET_MODULES) compiler/$(DICT_YRL)))