##############################################################################
# Copyright (c) 2000-2017 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#   Balasko, Jeno
#   Delic, Adam
#   Gecse, Roland
#   Raduly, Csaba
#   Szabo, Bence Janos
#
##############################################################################
TOPDIR := ../../
include   ../../Makefile.regression

# Flags for the C++ preprocessor (and makedepend as well):
#CPPFLAGS += -D$(PLATFORM) -I$(TTCN3_DIR)/include

# Flags for the C++ compiler:
#CXXFLAGS += -Wall

# Flags for the linker:
#LDFLAGS +=

# Flags for the TTCN-3 and ASN.1 compiler:
#COMPILER_FLAGS += -L

# Execution mode: (either ttcn3 or ttcn3-parallel)
TTCN3_LIB = ttcn3$(RT2_SUFFIX)-parallel$(DYNAMIC_SUFFIX)


#
# You may change these variables. Add your files if necessary...
#

# The TTCN-3 modules needed for this project:
TTCN3_MODULES = comptest.ttcn

# The ASN.1 modules needed for this project:
ASN1_MODULES =

# C++ source & header files generated by TTCN-3 & ASN.1 compilers:
GENERATED_SOURCES = comptest.cc
GENERATED_HEADERS = comptest.hh
ifdef CODE_SPLIT
GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc  _seqof.cc _setof.cc _union.cc))
else ifdef SPLIT_TO_SLICES
POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_))
POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc))
GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES)))
GENERATED_SOURCES += $(GENERATED_SOURCES2)
endif

# Source & header files of Test Ports and your other modules:
USER_SOURCES =
USER_HEADERS =

# All object files needed for the executable test suite:
OBJECTS = comptest.o

# The name of the executable test suite:
TARGET = comptest

#
# Do not modify these unless you know what you are doing...
#
#SOLARIS_LIBS = -lxnet
#LINUX_LIBS =
#FREEBSD_LIBS =
#WIN32_LIBS =

#
# Rules for building the executable...
#
all: $(TARGET) ;

$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \
	-L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS)

$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile
	@if [ ! -f $@ ]; then $(RM) compile; $(MAKE) compile; fi

compile: $(TTCN3_MODULES) $(ASN1_MODULES)
	$(TTCN3_DIR)/bin/compiler $(COMPILER_FLAGS) $(TTCN3_MODULES) \
	$(ASN1_MODULES) - $?
	touch $@

clean distclean:
	-$(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \
	$(GENERATED_SOURCES) compile *.log


#
# Add your rules here if necessary...
#

