##############################################################################
# Copyright (c) 2000-2025 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
#   Baranyi, Botond
#
##############################################################################
TOPDIR := ..
include $(TOPDIR)/Makefile.regression

.SUFFIXES: .ttcn .asn .hh
.PHONY: all clean dep run

ASN1_LIB = asn1enc$(DYNAMIC_SUFFIX)

ASN1_MODULES = A.asn B.asn 

USER_SOURCES = test.cc
USER_HEADERS = 

GENERATED_SOURCES = $(ASN1_MODULES:.asn=.cc)

GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh)

OBJECTS = $(GENERATED_SOURCES:.cc=.o)

TARGET = asn1enc$(EXESUFFIX)

CPPFLAGS += -DTITAN_ASN1ENC

all: $(TARGET)

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

$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile

compile: $(ASN1_MODULES)
	$(ASN1_COMPILER) --asn1enc $^

clean distclean:
	$(RM) $(TARGET) $(GENERATED_HEADERS) $(GENERATED_SOURCES) $(OBJECTS) compile

dep: $(GENERATED_SOURCES)
	makedepend $(CPPFLAGS) $(GENERATED_SOURCES)

run: $(TARGET)
	./$(TARGET) 
