Sync with 5.2.0
[deliverable/titan.core.git] / compiler2 / Makefile
CommitLineData
970ed795
EL
1###############################################################################
2# Copyright (c) 2000-2014 Ericsson Telecom AB
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# Makefile for the integrated (TTCN-3 and ASN.1) compiler
9# and the makefile generator
10
11TOP := ..
12include $(TOP)/Makefile.cfg
13
14ifeq ($(USAGE_STATS), yes)
15SOLARIS_LIBS := -lresolv -lsocket -lnsl
16SOLARIS8_LIBS := -lresolv -lsocket -lnsl
17LINUX_LIBS := -lpthread -lrt
18endif
19
20ifeq ($(findstring g++, $(CXX)), g++)
21 CXXFLAGS += -fno-exceptions
22endif
23
24ifdef REGEX_DIR
25 CPPFLAGS += -I$(REGEX_DIR)/include
26endif
27
28ifdef OPENSSL_DIR
29ifneq ($(OPENSSL_DIR), default)
30 CPPFLAGS += -I$(OPENSSL_DIR)/include
31 LDFLAGS += -L$(OPENSSL_DIR)/lib
32endif
33endif
34
35ifdef XMLDIR
36ifeq ($(XMLDIR), default)
37 XMLDIR := /usr
38 # do not add -L/usr/lib to LDFLAGS, it's redundant
39else
40 LDFLAGS += -L$(XMLDIR)/lib
41endif
42
43 CPPFLAGS += -I$(XMLDIR)/include/libxml2
44endif
45
46ifdef SRCDIR
47 CPPFLAGS += -Iasn1
48endif
49
50# Too many "comparison between signed and unsigned"
51CCFLAGS += -Wno-sign-compare
52
53ifndef MINGW
54TARGETS := compiler$(EXESUFFIX) ttcn3_makefilegen$(EXESUFFIX) tcov2lcov$(EXESUFFIX)
55MANPAGES := compiler.1 ttcn3_makefilegen.1
56else
57TARGETS := compiler$(EXESUFFIX)
58MANPAGES := compiler.1
59MAYBE_PDFS := $(MANPAGES:.1=.pdf)
60endif
61
62PDFS := $(MANPAGES:.1=.pdf)
63
64COMPILER_SOURCES := encdec.c enum.c functionref.c record.c record_of.c union.c \
65PredefFunc.cc AST.cc Code.cc Constraint.cc CompilerError.cc \
66CompField.cc CompType.cc EnumItem.cc Identifier.cc Int.cc \
67main.cc Real.cc Setting.cc SigParam.cc string.cc subtype.cc Stopwatch.cc \
68Type.cc Type_chk.cc Type_codegen.cc TypeCompat.cc \
69Typestuff.cc ustring.cc Value.cc Valuestuff.cc XerAttributes.cc subtypestuff.cc CodeGenHelper.cc
70
af710487 71MFGEN_SOURCES := makefile.c xpather.cc ProjectGenHelper.cc
970ed795
EL
72
73TCOV2LCOV_SOURCES := tcov2lcov.cc
74
75SOURCES := $(COMPILER_SOURCES) $(MFGEN_SOURCES) $(TCOV2LCOV_SOURCES)
76
77# All sources are static in this directory
78STATIC_SOURCES := $(SOURCES)
79
80COMPILER_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(COMPILER_SOURCES)))
81
82MFGEN_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(MFGEN_SOURCES)))
83
84TCOV2LCOV_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(TCOV2LCOV_SOURCES)))
85
86OBJECTS := $(COMPILER_OBJECTS) $(MFGEN_OBJECTS) $(TCOV2LCOV_OBJECTS)
87
88# Used by both the compiler and makefilegen
89COMMON_OBJECTS := $(addprefix ../common/, memory.o path.o userinfo.o JSON_Tokenizer.o)
90
91TCOV2LCOV_COMMON_OBJECTS := ../common/memory.o
92
93ifeq ($(LICENSING), yes)
94 COMMON_OBJECTS += ../common/license.o
95 TCOV2LCOV_COMMON_OBJECTS += ../common/license.o
96endif
97
98ifdef REGEX_DIR
99 COMMON_OBJECTS += $(REGEX_DIR)/lib/regex.o
100endif
101
102COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \
103$(addprefix ../common/, new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o ModuleVersion.o)
104
105ifeq ($(USAGE_STATS), yes)
106COMPILER_COMMON_OBJECTS += ../common/usage_stats.o
107endif
108
109MFGEN_COMMON_OBJECTS := $(COMMON_OBJECTS) ../common/new.o
110
111DEPFILES := $(patsubst %.cc,%.d,$(patsubst %.c,%.d,$(COMPILER_SOURCES) \
112$(MFGEN_SOURCES)))
113
114SUBDIRS := asn1 ttcn3
115
116.PHONY: asn1_dir ttcn3_dir
117
118all run: $(TARGETS)
119
120asn1/libasn1_compiler.a: asn1_dir ;
121
122ttcn3/libttcn3_compiler.a: ttcn3_dir ;
123
124asn1_dir:
125 $(MAKE) -C asn1
126
127ttcn3_dir:
128 $(MAKE) -C ttcn3
129
130pdf: $(PDFS)
131
132install: $(TARGETS) $(MAYBE_PDFS)
133ifeq ($(DEBUG), no)
134 $(STRIP) $(TARGETS)
135endif
136 mkdir -p $(BINDIR)
137 cp $(TARGETS) $(BINDIR)
138ifdef MINGW
139 mkdir -p $(MANDIR)
140 cp $(PDFS) $(MANDIR)
141else
142 cp tcov.xsd tcov.xsl $(INCDIR)
143 cp titanver $(BINDIR)
144 chmod a+x $(BINDIR)/titanver
145 $(RM) $(BINDIR)/ttcn3_compiler$(EXESUFFIX) \
146 $(BINDIR)/asn1_compiler$(EXESUFFIX) $(BINDIR)/makefilegen$(EXESUFFIX)
147 ln -s compiler$(EXESUFFIX) $(BINDIR)/ttcn3_compiler$(EXESUFFIX)
148 ln -s compiler$(EXESUFFIX) $(BINDIR)/asn1_compiler$(EXESUFFIX)
149 ln -s ttcn3_makefilegen$(EXESUFFIX) $(BINDIR)/makefilegen$(EXESUFFIX)
150 mkdir -p $(MANDIR)/man1
151 cp $(MANPAGES) $(MANDIR)/man1
152 $(RM) $(MANDIR)/man1/ttcn3_compiler.1 $(MANDIR)/man1/asn1_compiler.1 \
153 $(MANDIR)/man1/makefilegen.1
154 ln -s compiler.1 $(MANDIR)/man1/ttcn3_compiler.1
155 ln -s compiler.1 $(MANDIR)/man1/asn1_compiler.1
156 ln -s ttcn3_makefilegen.1 $(MANDIR)/man1/makefilegen.1
157endif
158
159# The compiler always links to OpenSSL (even without LICENSING)
160# because it uses bignums.
161compiler$(EXESUFFIX): asn1/libasn1_compiler.a ttcn3/libttcn3_compiler.a \
162$(COMPILER_OBJECTS) $(COMPILER_COMMON_OBJECTS)
163 $(CXX) $(LDFLAGS) -o $@ $(COMPILER_OBJECTS) $(COMPILER_COMMON_OBJECTS) \
164 asn1/libasn1_compiler.a ttcn3/libttcn3_compiler.a \
165 -lcrypto $(RSLICLIB) $(MINGW_LIBS) $($(PLATFORM)_LIBS)
166
167ttcn3_makefilegen$(EXESUFFIX): $(MFGEN_OBJECTS) $(MFGEN_COMMON_OBJECTS) \
168ttcn3/ttcn3_preparser.lex.o asn1/asn1_preparser.lex.o
169 $(CXX) $(LDFLAGS) -o $@ $^ -lxml2 $(LICENSE_LIBS) $(MINGW_LIBS)
170
171tcov2lcov$(EXESUFFIX): $(TCOV2LCOV_OBJECTS) $(TCOV2LCOV_COMMON_OBJECTS)
172 $(CXX) $(LDFLAGS) -o $@ $^ -lxml2 $(LICENSE_LIBS) $(MINGW_LIBS)
173
174include ../Makefile.genrules
175
176# Target-specific variable alteration
177# Target-specific += causes make 3.79.1 to crash, hence this old style
178makefile.o: CPPFLAGS := $(CPPFLAGS) -DCXX='"$(CXX)"'
179
180# Pre-seed dependencies. Value.cc and Valuestuff.cc include asn1/asn1p.tab.hh
181# However, if asn1/asn1p.y is modified, these files are not rebuilt because
182# the Value.d contains a dependency on asn1/asn1p.tab.hh, which is not yet
183# regenerated.
184#
185# 1. asn1/asn1p.y is modified
186# 2. "make" checks dependencies of Value.o; decides nothing to do
187# 3. "make -C asn1" rebuilds asn1p.y, updating asn1p.tab.hh
188# 4. Value.o is now out of date
189# 5. "make" issued a second time decides that Value.o is out of date
190Value.d Value.o : asn1/asn1p.tab.hh
191Valuestuff.d Valuestuff.o : asn1/asn1p.tab.hh
192Constraint.d Constraint.o : asn1/asn1p.tab.hh
This page took 0.035792 seconds and 5 git commands to generate.