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