Commit | Line | Data |
---|---|---|
970ed795 | 1 | ############################################################################### |
3abe9331 | 2 | # Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
3 | # All rights reserved. This program and the accompanying materials |
4 | # are made available under the terms of the Eclipse Public License v1.0 | |
5 | # which accompanies this distribution, and is available at | |
6 | # http://www.eclipse.org/legal/epl-v10.html | |
7 | ############################################################################### | |
8 | TOPDIR := ../.. | |
9 | include ../../Makefile.regression | |
10 | ||
11 | ORIG ?= . | |
12 | ||
13 | ifdef SRCDIR | |
14 | ORIGSRC := $(ABS_SRC) | |
15 | #$(warning yes SRC, $(ORIGSRC)) | |
16 | else | |
17 | ORIGSRC := $(ORIG) | |
18 | #$(warning no SRC, $(ORIGSRC)) | |
19 | endif | |
20 | ||
21 | # WARNING! This Makefile can be used with GNU make only. | |
22 | # Other versions of make may report syntax errors in it. | |
23 | ||
24 | # | |
25 | # Do NOT touch this line... | |
26 | # | |
27 | .PHONY: all check clean dep objects preprocess | |
28 | .SUFFIXES: .d | |
29 | ||
30 | # | |
31 | # Set these variables... | |
32 | # | |
33 | ||
34 | # C preprocessor used for TTCN-3 files: | |
35 | CPP = cpp | |
36 | ||
37 | # Flags for the C++ preprocessor (and makedepend as well): | |
38 | CPPFLAGS += -D$(PLATFORM) | |
39 | ||
40 | # Flags for the C++ compiler: (-Wall already in) | |
41 | CXXFLAGS += -g -W -Wformat=2 | |
42 | ||
43 | # Flags for the linker: | |
a38c6d4c | 44 | #LDFLAGS += -g -rdynamic |
970ed795 EL |
45 | WIN32_LIBS += -liconv |
46 | FREEBSD_LIBS += -liconv | |
47 | ||
48 | # Local flags for Titan (can be overridden from the environment or commandline) | |
49 | TTCNFLAGS += -b -r -x | |
50 | ||
51 | # Flags for the TTCN-3 and ASN.1 compiler | |
52 | # (common flags already set in Makefile.regression) | |
53 | COMPILER_FLAGS += $(TTCNFLAGS) | |
54 | ||
55 | # $(sort ) also eliminates duplicates | |
56 | COMPILER_FLAGS := $(sort $(COMPILER_FLAGS)) | |
57 | ||
58 | # Execution mode: (either ttcn3 or ttcn3-parallel) | |
59 | TTCN3_LIB := ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) | |
60 | ||
61 | # | |
62 | # You may change these variables. Add your files if necessary... | |
63 | # | |
64 | ||
65 | # TTCN-3 modules to preprocess: | |
66 | TTCN3_PP_MODULES := $(wildcard $(ORIGSRC)/../TTCNandXML/*.ttcnpp) | |
67 | ||
68 | # Files to include in TTCN-3 preprocessed modules: | |
69 | TTCN3_INCLUDES := $(TOP_SRC)/XML/macros.ttcnin | |
70 | ||
71 | # ASN.1 modules of this project: | |
72 | ASN1_MODULES := | |
73 | ||
74 | # TTCN-3 source files generated by the C preprocessor: | |
75 | PREPROCESSED_TTCN3_MODULES := $(TTCN3_PP_MODULES:.ttcnpp=.ttcn) | |
76 | ||
77 | ||
78 | # TTCN-3 modules of this project: | |
79 | ALL_TTCN3_MODULES := $(wildcard $(ORIGSRC)/../TTCNandXML/*.ttcn) | |
80 | # Eliminate preprocessed modules | |
81 | TTCN3_MODULES := $(filter-out $(PREPROCESSED_TTCN3_MODULES), $(ALL_TTCN3_MODULES)) | |
82 | TTCN3_MODULES += $(TOP_SRC)/iconv/converter.ttcn | |
83 | ||
84 | # C++ source & header files generated from the TTCN-3 & ASN.1 modules of | |
85 | # this project: | |
86 | GENERATED_SOURCES := $(notdir $(TTCN3_MODULES:.ttcn=.cc) $(PREPROCESSED_TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.cc)) | |
87 | GENERATED_HEADERS := $(GENERATED_SOURCES:.cc=.hh) | |
88 | ifdef CODE_SPLIT | |
89 | GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) | |
90 | endif | |
91 | ||
92 | ||
93 | # C/C++ Source & header files of Test Ports, external functions and | |
94 | # other modules: | |
95 | USER_SOURCES := iconver.cc Flatten.cc | |
96 | USER_HEADERS := $(USER_SOURCES:.cc=.hh) | |
97 | ||
98 | # Object files of this project that are needed for the executable test suite: | |
99 | OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(USER_SOURCES:.cc=.o) | |
100 | ||
101 | # The name of the executable test suite: | |
102 | TARGET = TTCNandXML$(RT2_SUFFIX)$(EXESUFFIX) | |
103 | ||
104 | ||
105 | # | |
106 | # Rules for building the executable... | |
107 | # | |
108 | ||
109 | all: $(TARGET) ; | |
110 | ||
111 | target: $(TARGET) ; | |
112 | ||
113 | objects: $(OBJECTS) ; | |
114 | ||
115 | ifeq ($(findstring dynamic,$(TTCN3_LIB)),) | |
116 | # not dynamic | |
117 | CORELIB_BINARY := $(TTCN3_DIR)/lib/lib$(TTCN3_LIB).a | |
118 | else | |
119 | CORELIB_BINARY := $(TTCN3_DIR)/lib/lib$(TTCN3_LIB).so | |
120 | endif | |
121 | ||
122 | $(TARGET): $(OBJECTS) $(CORELIB_BINARY) | |
123 | $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) \ | |
124 | -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ | |
125 | -L$(OPENSSL_DIR)/lib -lcrypto \ | |
126 | $($(PLATFORM)_LIBS) \ | |
127 | || $(TTCN3_DIR)/bin/titanver $(OBJECTS) | |
128 | ||
129 | .cc.o .c.o: | |
130 | @echo '(C++)' $<; $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< | |
131 | ||
132 | .cc.d .c.d: | |
133 | @echo Creating dependency file for '$<'; set -e; \ | |
134 | $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< \ | |
135 | | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ | |
136 | [ -s $@ ] || rm -f $@ | |
137 | ||
138 | %.ttcn: %.ttcnpp $(TTCN3_INCLUDES) | |
139 | $(CPP) -x c -nostdinc $(CPPFLAGS_TTCN3) $< $@ | |
140 | ||
141 | preprocess: $(PREPROCESSED_TTCN3_MODULES) ; | |
142 | ||
143 | $(GENERATED_SOURCES) $(GENERATED_HEADERS): compile | |
144 | @if [ ! -f $@ ]; then $(RM) compile; $(MAKE) compile; fi | |
145 | ||
146 | # | |
147 | ############################################################################ | |
148 | # | |
149 | ||
150 | compile: $(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES) $(firstword $(TTCN3_COMPILER)) | |
151 | $(TTCN3_COMPILER) $(COMPILER_FLAGS) $(filter-out $(TTCN3_COMPILER), $^) | |
152 | touch $@ | |
153 | ||
154 | clean: | |
155 | -$(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ | |
156 | $(GENERATED_SOURCES) $(PREPROCESSED_TTCN3_MODULES) compile \ | |
157 | tags *.log *.stackdump | |
158 | ||
159 | distclean: clean | |
160 | -$(RM) $(DEPFILES) | |
161 | ||
162 | # | |
163 | # Add your rules here if necessary... | |
164 | # | |
165 | ||
166 | install: | |
167 | @echo You cannot be serious! | |
168 | ||
169 | re: | |
170 | rm -f compile | |
171 | ||
172 | RUN := $(shell which colortitan 2>/dev/null) | |
173 | ifeq ($(firstword $(RUN)),no) | |
174 | # stupid /bin/which on Solaris writes errors to stdout instead of stderr | |
175 | RUN := | |
176 | endif | |
177 | ||
178 | run: $(TARGET) config.cfg | |
179 | $(RUN) ./$^ | |
180 | ||
181 | debug: | |
182 | $(MAKE) run RUN='gdb --args' | |
183 | ||
184 | vpath %.cc $(TOP_SRC)/iconv | |
185 | ||
186 | ||
187 | dep: ; | |
188 | ||
189 | DEPFILES := $(OBJECTS:.o=.d) | |
190 | ||
191 | ifeq (,$(findstring n,$(MAKEFLAGS))) | |
192 | ifeq (,$(filter clean distclean,$(MAKECMDGOALS))) | |
193 | -include $(DEPFILES) | |
194 | endif | |
195 | endif | |
196 | ||
197 | ifdef SRCDIR | |
198 | $(foreach src, $(USER_SOURCES), $(eval vpath $(src) $(ABS_SRC))) | |
199 | endif |