Makefile 4.22 KB
Newer Older
filatov's avatar
filatov committed
##########################################################
#  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.so 
# ASN.1 files to be included in the library
ASN_FILES = CAM/CAM.asn \
            DENM/DENM.asn \
            IS/ETSI_TS_103301/IVIM_PDU_Descriptions.asn \
            IS/ETSI_TS_103301/MAPEM_PDU_Descriptions.asn \
Yann Garcia's avatar
Yann Garcia committed
            IS/ETSI_TS_103301/RTCM_PDU_Descriptions.asn \
            IS/ETSI_TS_103301/SPATEM_PDU_Descriptions.asn \
            IS/ETSI_TS_103301/SREM_PDU_Descriptions.asn \
            IS/ETSI_TS_103301/SSEM_PDU_Descriptions.asn \
            IS/ISO_TS_14816/AVIAEINumberingAndDataStructures.asn \
            IS/ISO_TS_14906/EfcDsrcApplication.asn \
            IS/ISO_TS_14906/EfcDsrcGeneric.asn \
            IS/ISO_TS_17419/CITSapplMgmtIDs.asn \
            IS/ISO_TS_19091/original/AddGrpC.asn \
            IS/ISO_TS_19091/original/DSRC.asn \
            IS/ISO_TS_19091/original/REGION.asn \
            IS/ISO_TS_19321/IVI.asn \
            IS/ISO_TS_24534-3/ElectronicRegistrationIdentificationVehicleDataModule.asn \
            ITS-Container/ITS_Container.asn \
            Security/1609Dot2/IEEE1609dot2.asn \
            Security/1609Dot2/IEEE1609dot2BaseTypes.asn \
            Security/TS102921/EtsiTs102941BaseTypes.asn \
            Security/TS102921/EtsiTs102941MessagesCA.asn \
            Security/TS102921/EtsiTs102941TrustLists.asn \
            Security/TS102921/EtsiTs102941TypesAuthorization.asn \
            Security/TS102921/EtsiTs102941TypesAuthorizationValidation.asn \
            Security/TS102921/EtsiTs102941TypesCaManagement.asn \
            Security/TS102921/EtsiTs102941TypesEnrolment.asn \
            Security/EtsiTs103097Module.asn \


filatov's avatar
filatov committed
# PDUs
Yann Garcia's avatar
Yann Garcia committed
PDU = CAM DENM MAPEM SPATEM SREM SSEM IVIM RTCMEM EtsiTs103097Data EtsiTs103097Certificate EtsiTs102941Data
filatov's avatar
filatov committed

#patches
PATCHES = PsidGroupPermissions.c.diff

filatov's avatar
filatov committed
ASN1C:=asn1c
#Override ASN1C instalation path
#ASN1C_PATH = 

ifneq (, $(ASN1C_PATH))
OS=$(shell uname)
ifneq ("CYGWIN_NT-6.1", $(OS))
ASN1C:=$(ASN1C_PATH)/asn1c/asn1c -S $(ASN1C_PATH)/skeletons
else
ASN1C:=$(ASN1C_PATH)/asn1c/asn1c.exe -S $(ASN1C_PATH)/skeletons
endif
endif

Denis Filatov's avatar
Denis Filatov committed
ifeq (,$(ASN_DIR))
##########################################################
# Build path for the library
BIN_DIR := .
SCRIPT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
ASN_DIR := $(dir $(SCRIPT_DIR))../ttcn/LibIts/asn1

.PHONY: FORCE

all: $(BIN_DIR)/$(ASN_LIBRARY)
clean:
	rm -rf $(BIN_DIR)

$(BIN_DIR)/$(ASN_LIBRARY): $(BIN_DIR)/Makefile
	make -C $(BIN_DIR) all

$(BIN_DIR):
	mkdir -p $@

$(BIN_DIR)/Makefile: $(BIN_DIR) $(SCRIPT_DIR)/Makefile
	echo SCRIPT_DIR=$(SCRIPT_DIR) > $@
	echo ASN_DIR=$(ASN_DIR)       >>$@
	cat $(SCRIPT_DIR)/Makefile    >>$@

##########################################################
else
##########################################################
# This part is executed within the BIN_DIR directory to
# override variables from the Makefile.am.libasncodec 
# generated by asn1c
filatov's avatar
filatov committed
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}
garciay's avatar
garciay committed
CFLAGS += $(ASN_MODULE_CFLAGS) -DPDU=CAM -DASN_PDU_COLLECTION -fPIC -I.
filatov's avatar
filatov committed

Denis Filatov's avatar
Denis Filatov committed
all: Makefile $(CONVERTER)
filatov's avatar
filatov committed

$(LIB_MAKEFILE): $(addprefix $(ASN_DIR)/, $(ASN_FILES))
	$(ASN1C) -gen-PER -gen-OER $(addprefix -pdu=,$(PDU)) -fcompound-names $^
garciay's avatar
garciay committed
	-for n in $(PATCHES); do git apply "$(SCRIPT_DIR)/$$n"; done
filatov's avatar
filatov committed

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

$(ASN_LIBRARY): ${ASN_MODULE_SRCS:.c=.o}
	$(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)

Denis Filatov's avatar
Denis Filatov committed
Makefile: $(SCRIPT_DIR)/Makefile
	echo SCRIPT_DIR=$(SCRIPT_DIR) > $@
	echo ASN_DIR=$(ASN_DIR) >>$@
	cat $<                  >>$@
filatov's avatar
filatov committed
##########################################################
Denis Filatov's avatar
Denis Filatov committed
endif