| 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 | |
| 11 | TOP := .. |
| 12 | include $(TOP)/Makefile.cfg |
| 13 | |
| 14 | ifeq ($(USAGE_STATS), yes) |
| 15 | SOLARIS_LIBS := -lresolv -lsocket -lnsl |
| 16 | SOLARIS8_LIBS := -lresolv -lsocket -lnsl |
| 17 | LINUX_LIBS := -lpthread -lrt |
| 18 | endif |
| 19 | |
| 20 | ifeq ($(findstring g++, $(CXX)), g++) |
| 21 | CXXFLAGS += -fno-exceptions |
| 22 | endif |
| 23 | |
| 24 | ifdef REGEX_DIR |
| 25 | CPPFLAGS += -I$(REGEX_DIR)/include |
| 26 | endif |
| 27 | |
| 28 | ifdef OPENSSL_DIR |
| 29 | ifneq ($(OPENSSL_DIR), default) |
| 30 | CPPFLAGS += -I$(OPENSSL_DIR)/include |
| 31 | LDFLAGS += -L$(OPENSSL_DIR)/lib |
| 32 | endif |
| 33 | endif |
| 34 | |
| 35 | ifdef XMLDIR |
| 36 | ifeq ($(XMLDIR), default) |
| 37 | XMLDIR := /usr |
| 38 | # do not add -L/usr/lib to LDFLAGS, it's redundant |
| 39 | else |
| 40 | LDFLAGS += -L$(XMLDIR)/lib |
| 41 | endif |
| 42 | |
| 43 | CPPFLAGS += -I$(XMLDIR)/include/libxml2 |
| 44 | endif |
| 45 | |
| 46 | ifdef SRCDIR |
| 47 | CPPFLAGS += -Iasn1 |
| 48 | endif |
| 49 | |
| 50 | # Too many "comparison between signed and unsigned" |
| 51 | CCFLAGS += -Wno-sign-compare |
| 52 | |
| 53 | ifndef MINGW |
| 54 | TARGETS := compiler$(EXESUFFIX) ttcn3_makefilegen$(EXESUFFIX) tcov2lcov$(EXESUFFIX) |
| 55 | MANPAGES := compiler.1 ttcn3_makefilegen.1 |
| 56 | else |
| 57 | TARGETS := compiler$(EXESUFFIX) |
| 58 | MANPAGES := compiler.1 |
| 59 | MAYBE_PDFS := $(MANPAGES:.1=.pdf) |
| 60 | endif |
| 61 | |
| 62 | PDFS := $(MANPAGES:.1=.pdf) |
| 63 | |
| 64 | COMPILER_SOURCES := encdec.c enum.c functionref.c record.c record_of.c union.c \ |
| 65 | PredefFunc.cc AST.cc Code.cc Constraint.cc CompilerError.cc \ |
| 66 | CompField.cc CompType.cc EnumItem.cc Identifier.cc Int.cc \ |
| 67 | main.cc Real.cc Setting.cc SigParam.cc string.cc subtype.cc Stopwatch.cc \ |
| 68 | Type.cc Type_chk.cc Type_codegen.cc TypeCompat.cc \ |
| 69 | Typestuff.cc ustring.cc Value.cc Valuestuff.cc XerAttributes.cc subtypestuff.cc CodeGenHelper.cc |
| 70 | |
| 71 | MFGEN_SOURCES := makefile.c xpather.cc |
| 72 | |
| 73 | TCOV2LCOV_SOURCES := tcov2lcov.cc |
| 74 | |
| 75 | SOURCES := $(COMPILER_SOURCES) $(MFGEN_SOURCES) $(TCOV2LCOV_SOURCES) |
| 76 | |
| 77 | # All sources are static in this directory |
| 78 | STATIC_SOURCES := $(SOURCES) |
| 79 | |
| 80 | COMPILER_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(COMPILER_SOURCES))) |
| 81 | |
| 82 | MFGEN_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(MFGEN_SOURCES))) |
| 83 | |
| 84 | TCOV2LCOV_OBJECTS := $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(TCOV2LCOV_SOURCES))) |
| 85 | |
| 86 | OBJECTS := $(COMPILER_OBJECTS) $(MFGEN_OBJECTS) $(TCOV2LCOV_OBJECTS) |
| 87 | |
| 88 | # Used by both the compiler and makefilegen |
| 89 | COMMON_OBJECTS := $(addprefix ../common/, memory.o path.o userinfo.o JSON_Tokenizer.o) |
| 90 | |
| 91 | TCOV2LCOV_COMMON_OBJECTS := ../common/memory.o |
| 92 | |
| 93 | ifeq ($(LICENSING), yes) |
| 94 | COMMON_OBJECTS += ../common/license.o |
| 95 | TCOV2LCOV_COMMON_OBJECTS += ../common/license.o |
| 96 | endif |
| 97 | |
| 98 | ifdef REGEX_DIR |
| 99 | COMMON_OBJECTS += $(REGEX_DIR)/lib/regex.o |
| 100 | endif |
| 101 | |
| 102 | COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \ |
| 103 | $(addprefix ../common/, new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o ModuleVersion.o) |
| 104 | |
| 105 | ifeq ($(USAGE_STATS), yes) |
| 106 | COMPILER_COMMON_OBJECTS += ../common/usage_stats.o |
| 107 | endif |
| 108 | |
| 109 | MFGEN_COMMON_OBJECTS := $(COMMON_OBJECTS) ../common/new.o |
| 110 | |
| 111 | DEPFILES := $(patsubst %.cc,%.d,$(patsubst %.c,%.d,$(COMPILER_SOURCES) \ |
| 112 | $(MFGEN_SOURCES))) |
| 113 | |
| 114 | SUBDIRS := asn1 ttcn3 |
| 115 | |
| 116 | .PHONY: asn1_dir ttcn3_dir |
| 117 | |
| 118 | all run: $(TARGETS) |
| 119 | |
| 120 | asn1/libasn1_compiler.a: asn1_dir ; |
| 121 | |
| 122 | ttcn3/libttcn3_compiler.a: ttcn3_dir ; |
| 123 | |
| 124 | asn1_dir: |
| 125 | $(MAKE) -C asn1 |
| 126 | |
| 127 | ttcn3_dir: |
| 128 | $(MAKE) -C ttcn3 |
| 129 | |
| 130 | pdf: $(PDFS) |
| 131 | |
| 132 | install: $(TARGETS) $(MAYBE_PDFS) |
| 133 | ifeq ($(DEBUG), no) |
| 134 | $(STRIP) $(TARGETS) |
| 135 | endif |
| 136 | mkdir -p $(BINDIR) |
| 137 | cp $(TARGETS) $(BINDIR) |
| 138 | ifdef MINGW |
| 139 | mkdir -p $(MANDIR) |
| 140 | cp $(PDFS) $(MANDIR) |
| 141 | else |
| 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 |
| 157 | endif |
| 158 | |
| 159 | # The compiler always links to OpenSSL (even without LICENSING) |
| 160 | # because it uses bignums. |
| 161 | compiler$(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 | |
| 167 | ttcn3_makefilegen$(EXESUFFIX): $(MFGEN_OBJECTS) $(MFGEN_COMMON_OBJECTS) \ |
| 168 | ttcn3/ttcn3_preparser.lex.o asn1/asn1_preparser.lex.o |
| 169 | $(CXX) $(LDFLAGS) -o $@ $^ -lxml2 $(LICENSE_LIBS) $(MINGW_LIBS) |
| 170 | |
| 171 | tcov2lcov$(EXESUFFIX): $(TCOV2LCOV_OBJECTS) $(TCOV2LCOV_COMMON_OBJECTS) |
| 172 | $(CXX) $(LDFLAGS) -o $@ $^ -lxml2 $(LICENSE_LIBS) $(MINGW_LIBS) |
| 173 | |
| 174 | include ../Makefile.genrules |
| 175 | |
| 176 | # Target-specific variable alteration |
| 177 | # Target-specific += causes make 3.79.1 to crash, hence this old style |
| 178 | makefile.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 |
| 190 | Value.d Value.o : asn1/asn1p.tab.hh |
| 191 | Valuestuff.d Valuestuff.o : asn1/asn1p.tab.hh |
| 192 | Constraint.d Constraint.o : asn1/asn1p.tab.hh |