Commit 3fb647be authored by Yann Garcia's avatar Yann Garcia
Browse files

Added build files

parent 1666639e
Loading
Loading
Loading
Loading

Makefile

0 → 100644
+167 −0
Original line number Diff line number Diff line
-include config.mk

ifeq (,$(ATS))
 $(error ATS shall be defined)
endif

ifeq (,$(TOPDIR))
 TOPDIR := .
endif

ifeq (,$(TTCN3_DIR))
 $(error TTCN3_DIR shall be defined in config.mk)
endif

ifeq (,$(ASN1C))
 ifneq (,$(ASN1C_PATH))
  ASN1C := $(ASN1C_PATH)/asn1c/.libs/asn1c -S $(ASN1C_PATH)/skeletons
 else
  ASN1C := asn1c
 endif
endif

export ASN1C_PATH

first: all

define IncludeModule
undefine sources
undefine modules
undefine includes
include $(1)/module.mk
$$(foreach S, $$(sources),  $$(eval all_sources +=  $$(if $$(filter /%, $$(S)), $$(TOPDIR)$$(S), $(1)/$$(S))))
$$(foreach I, $$(includes), $$(eval all_includes += $$(if $$(filter /%, $$(I)), $$(TOPDIR)$$(I), $(1)/$$(I))))
$$(foreach M, $$(modules),  $$(eval $$(call IncludeModule, $$(if $$(filter /%, $$(M)), $$(TOPDIR)$$(M), $(1)/$$(M)))))
endef

all_includes := $(TTCN3_DIR)/include $(TTCN3_DIR)/src /usr/include/jsoncpp /usr/include/libxml2
defines  += TITAN_RUNTIME_2 _NO_SOFTLINKS_ $(ATS)  AS_USE_SSL _GNU_SOURCE
libs     += $(TTCN3_DIR)/lib/libttcn3-rt2-parallel.a -lstdc++fs

ifeq (Windows_NT,$(OS))
# Silence linker warnings.
LDFLAGS += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc
defines += WIN32
libs += $(patsubst %, -L%/lib, $(OPENSSL_DIR))
all_includes += $(addsuffix /include, $(OPENSSL_DIR))
libs += $(WPCAP_DLL_PATH)
else
defines += LINUX
libs += -lpcap -lrt -lpthread
endif

libs += -lssl -lcrypto -lxml2 -ljsoncpp -L$(OSIP_LIB) -losipparser2 -lsctp

$(eval $(call IncludeModule, $(TOPDIR)/ttcn/$(ATS)))

outdir := $(TOPDIR)/build/$(ATS)
bindir := $(TOPDIR)/bin

sources     := $(all_sources)
includes    := $(outdir) $(outdir)/.. $(outdir)/asn1 $(all_includes) $(NPCAP_INCLUDE) $(OSIP_INCLUDE) 

ifeq (Windows_NT,$(OS))
  EXE=.exe
endif

ttcn_sources  := $(filter %.ttcn , $(sources))
ttcn3_sources := $(filter %.ttcn3, $(sources))
asn_sources   := $(filter %.asn,   $(sources))
asn1_sources  := $(filter %.asn1,  $(sources))

tt_sources    := $(ttcn_sources) $(ttcn3_sources) $(asn_sources) $(asn1_sources)
cc_sources    := $(filter %.cc,    $(sources))

gen_ttcn_sources  := $(addprefix $(outdir)/, $(notdir $(patsubst %.ttcn,  %.cc, $(ttcn_sources))))
gen_ttcn_headers  := $(addprefix $(outdir)/, $(notdir $(patsubst %.ttcn,  %.hh, $(ttcn_sources))))
gen_ttcn3_sources := $(addprefix $(outdir)/, $(notdir $(patsubst %.ttcn3, %.cc, $(ttcn3_sources))))
gen_ttcn3_headers := $(addprefix $(outdir)/, $(notdir $(patsubst %.ttcn3, %.hh, $(ttcn3_sources))))
gen_asn_sources   := $(addprefix $(outdir)/, $(notdir $(patsubst %.asn,   %.cc, $(asn_sources))))
gen_asn_headers   := $(addprefix $(outdir)/, $(notdir $(patsubst %.asn,   %.hh, $(asn_sources))))
gen_asn1_sources  := $(addprefix $(outdir)/, $(notdir $(patsubst %.asn1,  %.cc, $(asn1_sources))))
gen_asn1_headers  := $(addprefix $(outdir)/, $(notdir $(patsubst %.asn1,  %.hh, $(asn1_sources))))

gen_sources := $(gen_ttcn_sources) $(gen_ttcn3_sources) $(gen_asn_sources) $(gen_asn1_sources)
gen_headers := $(gen_ttcn_headers) $(gen_ttcn3_headers) $(gen_asn_headers) $(gen_asn1_headers)

gen_objects := $(patsubst %.cc, %.o, $(gen_sources))
cc_objects  := $(patsubst  %.cc, $(outdir)/%.o, $(cc_sources))

.PHONY: all FORCE echo

all: $(bindir) $(outdir) $(bindir)/$(ATS)$(EXE)

echo_sources:
	@echo -e "$(addsuffix \n,$(all_sources))"

echo: echo_sources
	@echo -e "sources:\n $(addsuffix \n, $(sources))"
	@echo -e "gen_sources:\n $(addsuffix \n, $(gen_sources))"
	@echo -e "gen_objects:\n $(addsuffix \n, $(gen_objects))"
	@echo -e "cc_objects:\n $(addsuffix \n, $(cc_objects))"
	@echo -e "includes:\n $(addsuffix \n, $(includes))"
	@echo -e "defines: $(addsuffix \n, $(defines))"

clean:
	rm -f $(outdir)/$(ATS)$(EXE) $(gen_objects) $(gen_sources) $(gen_headers) $(cc_objects) $(outdir)/.generate $(outdir)/../libAsn.so
#	rm -f $(outdir)/asn1/*.so $(outdir)/asn1/*.o $(outdir)/asn1/*.c $(outdir)/asn1/*.h $(outdir)/asn1/Makefile.am.libasncodec

regen: force_regen $(outdir)/.generate
force_regen:
	rm -f $(outdir)/.generate

t3q: all
	@echo -e "Code checking in progress..."
	@java -Xmx3g -Xss512m -jar $(T3Q_PATH)/t3q.jar --config $(T3Q_PATH)/$(T3Q_CONFIG) $(tt_sources) > $(outdir)/t3q.out 2>&1 ; cd -
	@echo -e "Code checking in done..."
	@echo -e "Output file is located here: $(outdir)/t3q.out"

t3d: all
	@echo -e "TTCN-3 doc generation in progress..."
	@java -Xmx3g -Xss512m -jar $(T3D_PATH)/t3d.jar --config $(T3D_PATH)/$(T3D_CONFIG) $(tt_sources) > $(outdir)/t3d.out 2>&1 ; cd -
	@echo -e "TTCN-3 doc generation done..."
	@echo -e "Output file is located here: $(outdir)/t3d.out"

$(outdir) $(outdir)/asn1 $(bindir):
	mkdir -p $@

$(bindir)/$(ATS)$(EXE): $(outdir)/asn1/libAsn.a $(gen_objects) $(cc_objects) 
	g++ -g -O0 -std=c++17 -o $@ $(LDFLAGS) $(gen_objects) $(cc_objects) $(outdir)/asn1/libAsn.a $(libs)

$(gen_objects) :%.o :%.cc
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<

$(cc_objects) : $(outdir)/%.o : %.cc
	mkdir -p $(dir $@)
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<

#$(gen_sources):
#	$(TTCN3_DIR)/bin/compiler -n -e -L -R -U none -o $(outdir) $(tt_sources)

$(gen_sources): $(outdir)/.generate

$(outdir)/.generate: Makefile $(tt_sources)
	$(TTCN3_DIR)/bin/compiler $(TTCN3_COMPILER_OPTIONS) -o  $(outdir) $(tt_sources)
	touch $@

$(bindir)/libAsn.so: $(outdir)/asn1/libAsn.so
	cp -f $< $@

$(outdir)/asn1/libAsn.a: $(asn_sources) $(asn1_sources) libasn1.mk Makefile
	mkdir -p $(outdir)/asn1
	echo TOP_DIR   := ../../..                                               >$(outdir)/asn1/Makefile
	echo ASN_PDU   := $(pdu)                                                >>$(outdir)/asn1/Makefile
	echo ASN_FILES := \\                                                    >>$(outdir)/asn1/Makefile
	for n in $(asn_sources) $(asn1_sources); do echo "        $$n \\"; done >>$(outdir)/asn1/Makefile
	echo                                                                    >>$(outdir)/asn1/Makefile
	cat libasn1.mk                                                          >>$(outdir)/asn1/Makefile
	$(MAKE) -C $(outdir)/asn1
	touch $@

$(foreach S, $(ttcn_sources),  $(eval $(outdir)/$(notdir $(patsubst %.ttcn, %.cc,  $(S))): $(S)))
$(foreach S, $(ttcn3_sources), $(eval $(outdir)/$(notdir $(patsubst %.ttcn3, %.cc, $(S))): $(S)))
$(foreach S, $(asn_sources),   $(eval $(outdir)/$(notdir $(patsubst %.asn, %.cc,   $(S))): $(S)))
$(foreach S, $(asn1_sources),  $(eval $(outdir)/$(notdir $(patsubst %.asn1, %.cc,  $(S))): $(S)))

$(asn_sources) $(asn1_sources):
+11 −0
Original line number Diff line number Diff line
{
	"folders": [
		{
			"path": "."
		},
		{
			"path": "../../../tmp/osmo-ttcn3-hacks"
		}
	],
	"settings": {}
}
 No newline at end of file

config.mk

0 → 100644
+15 −0
Original line number Diff line number Diff line
#TTCN3_COMPILER_OPTIONS := -d -e -f -g -j -H -l -L -R -U none -x -X
TTCN3_COMPILER_OPTIONS := -d -e -f -g -j -l -L -R -U none -x -X
#TTCN3_DIR      := $(HOME)/frameworks/titan/titan.core/Install
TTCN3_DIR      :=  $(HOME)/tmp/ttcn3-9.0.0
#ASN1C_PATH     := $(HOME)/frameworks/asn1c.denis
#ASN1C_PATH     := /home/ubuntu/bin/asn1c.denis/
#WPCAP_DLL_PATH := /cygdrive/c/windows/system32/npcap/wpcap.dll
#NPCAP_INCLUDE  := /cygdrive/c/PROGRA~1/Npcap/sdk/include
#T3Q_PATH=./tools/t3q-v2.0.0b30
#T3Q_CONFIG=t3q.cfg
#T3D_PATH=./tools/t3d-v2.0.0b30
#T3D_CONFIG=t3d.cfg
#ITS_CONTAINER=../../../AtsDENM/lib/asn1/cdd/ITS_Container.asn
#OSIP_INCLUDE= /home/ubuntu/bin/osip/include/
#OSIP_LIB= /home/ubuntu/bin/osip/src/osipparser2/.libs/

libNr5gcAsn1.mk

0 → 100644
+126 −0
Original line number Diff line number Diff line
##########################################################
#  This Makefile is to build the ASN1 library to be used
#  for external codec in Titan
#  This Makefile is expected that asn1c compiler is 
#  installed in the PATHs
##########################################################

# The name of the library
ASN_LIBRARY = libItsAsn.a

ifeq (,$(sort $(ASN_FILES)))
 $(error ASN_FILES should be specified )
endif

#Override ASN1C instalation path
ifneq (, $(ASN1C_PATH))
  ASN1C:=$(ASN1C_PATH)/asn1c/asn1c -S $(ASN1C_PATH)/skeletons
else
  ASN1C:=asn1c
  ASN1C:=asn1_compiler
endif

LIB_MAKEFILE=Makefile.am.libasncodec
include $(LIB_MAKEFILE)
OBJS = ${ASN_MODULE_SRCS:.c=.o}
CONVERTER=converter
ASN_CONVERTER_SOURCES := \
	converter-example.c\
	pdu_collection.c
CONVERTER_OBJS=${ASN_CONVERTER_SOURCES:.c=.o}
ifneq ($(strip $(ASN_PDU)),$(firstword $(ASN_PDU)))
  HAS_PDU_COLLECTION := -DASN_PDU_COLLECTION
endif

CFLAGS += $(ASN_MODULE_CFLAGS) -DPDU=$(firstword $(ASN_PDU)) $(HAS_PDU_COLLECTION) -fPIC -I.
CC = gcc -std=c99

ifeq ('asn1c', $(ASN1C))
    ASN1C_OPTIONS += -no-gen-example -fcompound-names -no-gen-XER -no-gen-JER -no-gen-APER -no-gen-print -no-gen-random-fill
else
    ASN1C_OPTIONS += -b -O
endif

ifeq (yes,$(DEBUG))
  CFLAGS += -g -O0 -DASN_EMIT_DEBUG=1
endif
ASN_SRC_FILES := $(addprefix $(TOP_DIR)/, $(ASN_FILES))

all: $(ASN_LIBRARY)

$(LIB_MAKEFILE): $(ASN_SRC_FILES) Makefile
	$(ASN1C) $(ASN1C_OPTIONS) $(addprefix -pdu=,$(pdu)) $(ASN_SRC_FILES)
#	-for n in $(PATCHES); do git apply "$(SCRIPT_DIR)/$$n"; done

$(CONVERTER): $(ASN_LIBRARY) $(CONVERTER_OBJS) 
	$(CC) $(CFLAGS) -o $@ $(CONVERTER_OBJS) $(ASN_LIBRARY) $(LIBS)

$(ASN_LIBRARY): ${ASN_MODULE_SRCS:.c=.o}
	ar rcs $@ $^
#	$(CC) $(CFLAGS) -o $@ $^ -shared $(LDFLAGS) $(LIBS)

.SUFFIXES:
.SUFFIXES: .c .o

.c.o:
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	rm -f $(CONVERTER) $(ASN_LIBRARY)
	rm -f $(OBJS) $(CONVERTER_OBJS)

regen: clear-asn1c $(LIB_MAKEFILE)
clear-asn1c:
	rm -f $(LIB_MAKEFILE)

##########################################################

#$(TOP_DIR)/./build/asn1/ISO_TS_14816/AVIAEINumberingAndDataStructures.asn:
#	mkdir -p "$(dir $@)"
#	curl 'https://standards.iso.org/iso/14816/ISO14816%20ASN.1%20repository/ISO14816_AVIAEINumberingAndDataStructures.asn' | \
#	sed -e 's/IssuerIdentifier/AVIAEIIssuerIdentifier/g' > "$@"

#$(TOP_DIR)/./build/asn1/ISO_TS_14906/EfcDsrcApplication.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/14906/ed-3/en/ISO14906(2018)EfcDsrcApplicationv6.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_14906/EfcDsrcGeneric.asn:
#	mkdir -p "$(dir $@)
#	curl -o "$@" 'https://standards.iso.org/iso/14906/ed-3/en/ISO14906(2018)EfcDsrcGenericv7.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSapplMgmtIDs.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/ts/17419/TS%2017419%20ASN.1%20repository/TS17419_2014_CITSapplMgmtIDs.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_19091/ISO-TS-19091-addgrp-C-2018-patched.asn:
#	mkdir -p "$(dir $@)"
#	curl 'https://standards.iso.org/iso/ts/19091/ed-2/en/ISO-TS-19091-addgrp-C-2018.asn' | \
#	sed -e 's/\bHeadingConfidence\b/HeadingConfidenceDSRC/g' \
#        -e 's/\bSpeedConfidence\b/SpeedConfidenceDSRC/g' \
#        -e 's/\bHeading\b/HeadingDSRC/g' > "$@"

#$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary1.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/17419/ed-1/en/17419.1.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary2.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/17419/ed-1/en/17419.2.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_19091/AddGrpC.asn:
#$(TOP_DIR)/./build/asn1/ISO_TS_19091/AddGrpC_noCircular.asn:
#$(TOP_DIR)/./build/asn1/ISO_TS_19091/DSRC.asn:
#$(TOP_DIR)/./build/asn1/ISO_TS_19091/DSRC_REGION_noCircular.asn
#$(TOP_DIR)/./build/asn1/ISO_TS_19091/REGION.asn

#$(TOP_DIR)/./build/asn1/ISO_TS_19321/IVI.asn:
#	mkdir -p "$(dir $@)"
#	curl 'https://standards.iso.org/iso/ts/19321/ed-2/en/ISO19321IVIv2.asn' | \
#	sed -e 's/\bCITSdataDictionary1\b/CITSapplMgmtIDs/g' \
#	    -e 's/,\s*\.\.\.\s*,\s*[0-9]\+/,.../g' \
#	> "$@"

#$(TOP_DIR)/build/asn1/ISO_TS_24534-3/ElectronicRegistrationIdentificationVehicleDataModule.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/24534/-3/ISO%2024534-3%20ASN.1%20repository/ISO24534-3_ElectronicRegistrationIdentificationVehicleDataModule_ForBallot.asn'