ASN_MODULE_SOURCES=	\
	ULP-PDU.c	\
	UlpMessage.c	\
	SUPLINIT.c	\
	Notification.c	\
	NotificationType.c	\
	EncodingType.c	\
	FormatIndicator.c	\
	SLPMode.c	\
	MAC.c	\
	KeyIdentity.c	\
	SUPLSTART.c	\
	SETCapabilities.c	\
	PosTechnology.c	\
	PrefMethod.c	\
	PosProtocol.c	\
	SUPLRESPONSE.c	\
	SETAuthKey.c	\
	KeyIdentity4.c	\
	SUPLPOSINIT.c	\
	RequestedAssistData.c	\
	NavigationModel.c	\
	SatelliteInfo.c	\
	SatelliteInfoElement.c	\
	SUPLPOS.c	\
	PosPayLoad.c	\
	SUPLEND.c	\
	SUPLAUTHREQ.c	\
	SETNonce.c	\
	KeyIdentity2.c	\
	SUPLAUTHRESP.c	\
	SPCAuthKey.c	\
	KeyIdentity3.c	\
	Version.c	\
	SessionID.c	\
	SetSessionID.c	\
	SETId.c	\
	SlpSessionID.c	\
	IPAddress.c	\
	SLPAddress.c	\
	FQDN.c	\
	Ver.c	\
	LocationId.c	\
	Status.c	\
	CellInfo.c	\
	Position.c	\
	PositionEstimate.c	\
	AltitudeInfo.c	\
	CdmaCellInformation.c	\
	GsmCellInformation.c	\
	WcdmaCellInformation.c	\
	FrequencyInfo.c	\
	FrequencyInfoFDD.c	\
	FrequencyInfoTDD.c	\
	UARFCN.c	\
	NMR.c	\
	NMRelement.c	\
	MeasuredResultsList.c	\
	MeasuredResults.c	\
	CellMeasuredResultsList.c	\
	UTRA-CarrierRSSI.c	\
	CellMeasuredResults.c	\
	CellParametersID.c	\
	TGSN.c	\
	PrimaryCCPCH-RSCP.c	\
	TimeslotISCP.c	\
	TimeslotISCP-List.c	\
	PrimaryCPICH-Info.c	\
	CPICH-Ec-N0.c	\
	CPICH-RSCP.c	\
	Pathloss.c	\
	StatusCode.c	\
	QoP.c	\
	Velocity.c	\
	Horvel.c	\
	Horandvervel.c	\
	Horveluncert.c	\
	Horandveruncert.c	\
	PosMethod.c

ASN_MODULE_HEADERS=	\
	ULP-PDU.h	\
	UlpMessage.h	\
	SUPLINIT.h	\
	Notification.h	\
	NotificationType.h	\
	EncodingType.h	\
	FormatIndicator.h	\
	SLPMode.h	\
	MAC.h	\
	KeyIdentity.h	\
	SUPLSTART.h	\
	SETCapabilities.h	\
	PosTechnology.h	\
	PrefMethod.h	\
	PosProtocol.h	\
	SUPLRESPONSE.h	\
	SETAuthKey.h	\
	KeyIdentity4.h	\
	SUPLPOSINIT.h	\
	RequestedAssistData.h	\
	NavigationModel.h	\
	SatelliteInfo.h	\
	SatelliteInfoElement.h	\
	SUPLPOS.h	\
	PosPayLoad.h	\
	SUPLEND.h	\
	SUPLAUTHREQ.h	\
	SETNonce.h	\
	KeyIdentity2.h	\
	SUPLAUTHRESP.h	\
	SPCAuthKey.h	\
	KeyIdentity3.h	\
	Version.h	\
	SessionID.h	\
	SetSessionID.h	\
	SETId.h	\
	SlpSessionID.h	\
	IPAddress.h	\
	SLPAddress.h	\
	FQDN.h	\
	Ver.h	\
	LocationId.h	\
	Status.h	\
	CellInfo.h	\
	Position.h	\
	PositionEstimate.h	\
	AltitudeInfo.h	\
	CdmaCellInformation.h	\
	GsmCellInformation.h	\
	WcdmaCellInformation.h	\
	FrequencyInfo.h	\
	FrequencyInfoFDD.h	\
	FrequencyInfoTDD.h	\
	UARFCN.h	\
	NMR.h	\
	NMRelement.h	\
	MeasuredResultsList.h	\
	MeasuredResults.h	\
	CellMeasuredResultsList.h	\
	UTRA-CarrierRSSI.h	\
	CellMeasuredResults.h	\
	CellParametersID.h	\
	TGSN.h	\
	PrimaryCCPCH-RSCP.h	\
	TimeslotISCP.h	\
	TimeslotISCP-List.h	\
	PrimaryCPICH-Info.h	\
	CPICH-Ec-N0.h	\
	CPICH-RSCP.h	\
	Pathloss.h	\
	StatusCode.h	\
	QoP.h	\
	Velocity.h	\
	Horvel.h	\
	Horandvervel.h	\
	Horveluncert.h	\
	Horandveruncert.h	\
	PosMethod.h

ASN_MODULE_HEADERS+=BOOLEAN.h
ASN_MODULE_SOURCES+=BOOLEAN.c
ASN_MODULE_HEADERS+=ENUMERATED.h
ASN_MODULE_SOURCES+=ENUMERATED.c
ASN_MODULE_HEADERS+=INTEGER.h
ASN_MODULE_HEADERS+=NativeEnumerated.h
ASN_MODULE_HEADERS+=GeneralizedTime.h
ASN_MODULE_SOURCES+=GeneralizedTime.c
ASN_MODULE_HEADERS+=IA5String.h
ASN_MODULE_SOURCES+=IA5String.c
ASN_MODULE_SOURCES+=INTEGER.c
ASN_MODULE_SOURCES+=NativeEnumerated.c
ASN_MODULE_HEADERS+=NativeInteger.h
ASN_MODULE_SOURCES+=NativeInteger.c
ASN_MODULE_HEADERS+=UTCTime.h
ASN_MODULE_SOURCES+=UTCTime.c
ASN_MODULE_HEADERS+=VisibleString.h
ASN_MODULE_SOURCES+=VisibleString.c
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
ASN_MODULE_HEADERS+=asn_SET_OF.h
ASN_MODULE_SOURCES+=asn_SET_OF.c
ASN_MODULE_HEADERS+=constr_CHOICE.h
ASN_MODULE_SOURCES+=constr_CHOICE.c
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
ASN_MODULE_HEADERS+=constr_SET_OF.h
ASN_MODULE_SOURCES+=constr_SET_OF.c
ASN_MODULE_HEADERS+=asn_application.h
ASN_MODULE_HEADERS+=asn_system.h
ASN_MODULE_HEADERS+=asn_codecs.h
ASN_MODULE_HEADERS+=asn_internal.h
ASN_MODULE_HEADERS+=OCTET_STRING.h
ASN_MODULE_SOURCES+=OCTET_STRING.c
ASN_MODULE_HEADERS+=BIT_STRING.h
ASN_MODULE_SOURCES+=BIT_STRING.c
ASN_MODULE_SOURCES+=asn_codecs_prim.c
ASN_MODULE_HEADERS+=asn_codecs_prim.h
ASN_MODULE_HEADERS+=ber_tlv_length.h
ASN_MODULE_SOURCES+=ber_tlv_length.c
ASN_MODULE_HEADERS+=ber_tlv_tag.h
ASN_MODULE_SOURCES+=ber_tlv_tag.c
ASN_MODULE_HEADERS+=ber_decoder.h
ASN_MODULE_SOURCES+=ber_decoder.c
ASN_MODULE_HEADERS+=der_encoder.h
ASN_MODULE_SOURCES+=der_encoder.c
ASN_MODULE_HEADERS+=constr_TYPE.h
ASN_MODULE_SOURCES+=constr_TYPE.c
ASN_MODULE_HEADERS+=constraints.h
ASN_MODULE_SOURCES+=constraints.c
ASN_MODULE_HEADERS+=xer_support.h
ASN_MODULE_SOURCES+=xer_support.c
ASN_MODULE_HEADERS+=xer_decoder.h
ASN_MODULE_SOURCES+=xer_decoder.c
ASN_MODULE_HEADERS+=xer_encoder.h
ASN_MODULE_SOURCES+=xer_encoder.c
ASN_MODULE_HEADERS+=per_support.h
ASN_MODULE_SOURCES+=per_support.c
ASN_MODULE_HEADERS+=per_decoder.h
ASN_MODULE_SOURCES+=per_decoder.c
ASN_MODULE_HEADERS+=per_encoder.h
ASN_MODULE_SOURCES+=per_encoder.c
ASN_MODULE_HEADERS+=per_opentype.h
ASN_MODULE_SOURCES+=per_opentype.c
ASN_CONVERTER_SOURCES+=converter-sample.c
ASN_CONVERTER_SOURCES+=pdu_collection.c


lib_LTLIBRARIES=libsomething.la
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)

# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = ulp-dump
CFLAGS += -DASN_CONVERTER_TITLE="OMA UserPlane Location Protocol decoder" -DHAVE_CONFIG_H -DJUNKTEST -DPDU=ULP_PDU -DASN_PDU_COLLECTION -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}

all: ULP-PDU.c $(TARGET)

$(TARGET): ${OBJS}
	$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)

.SUFFIXES:
.SUFFIXES: .c .o

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

clean:
	rm -f $(TARGET)
	rm -f $(OBJS)

regen: regenerate-from-asn1-source

regenerate-from-asn1-source:
	../../asn1c/asn1c -S ../../skeletons -pdu=ULP-PDU -pdu=SUPLINIT -fcompound-names -gen-PER ../ulp.asn1


ULP-PDU.c: ../sample.makefile.regen ../ulp.asn1
	make regen-makefile
	@touch ULP-PDU.c
	make

regen-makefile:
	TITLE="OMA UserPlane Location Protocol decoder" \
	ASN1CMDOPTS="-pdu=SUPLINIT -fcompound-names -gen-PER" \
	ASN1MODULES="../ulp.asn1" \
	ASN1PDU=ULP-PDU \
	PROGNAME=ulp-dump \
	../sample.makefile.regen

check: ${TARGET} check-ber check-xer check-per
	@echo ================
	@echo All tests passed
	@echo ================

check-ber:
	@if test -f sample-ULP-PDU-1.[db]er ; then \
	for f in sample-ULP-PDU-*.[db]er; do \
	for b in 1 17 33 980 8192; do \
	echo "Recoding $$f into XER and back ($$b)..."; \
	./${TARGET} -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
	diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
	rm -f ./.tmp.[12].$$$$; \
	echo "Test junking $$f (please wait)..."; \
	./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 5; \
	./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 6; \
	done; done; fi

check-xer:
	@if test -f sample-ULP-PDU-1.xer ; then \
	for f in sample-ULP-PDU-*.xer; do \
	for b in 1 17 33 980 8192; do \
	echo "Recoding $$f into DER and back ($$b)..."; \
	./${TARGET} -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
	diff $$f ./.tmp.2.$$$$ || exit 4; \
	rm -f ./.tmp.[12].$$$$; \
	echo "Test junking $$f (please wait)..."; \
	./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 5; \
	./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 6; \
	done; done; fi

check-per:
	@if test -f sample-ULP-PDU-1-nopad.per ; then \
	for f in sample-ULP-PDU-[1-9]-nopad.per; do \
	for b in 1 17 33 980 8192; do \
	echo "Recoding non-padded $$f into DER into XER and back ($$b)..."; \
	./${TARGET} -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
	./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
	diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
	rm -f ./.tmp.[123].$$$$; \
	echo "Test junking $$f (please wait)..."; \
	./${TARGET} -J0.0001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 6; \
	./${TARGET} -J0.001 -n 1000 -b $$b -per-nopad -iper -onull $$f || exit 7; \
	done; done; fi
	@if test -f sample-ULP-PDU-1.per ; then \
	for f in sample-*-[1-9].per; do \
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z-]+)-[0-9].*/\1/"`; \
	for b in 1 17 33 980 8192; do \
	echo "Recoding $$f into DER into XER and back ($$b)..."; \
	./${TARGET} -b $$b -p $$pdu -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
	./${TARGET} -b $$b -p $$pdu -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
	./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
	diff $$f ./.tmp.1.$$$$ || exit 6; \
	rm -f ./.tmp.[12].$$$$; \
	echo "Test junking $$f (please wait)..."; \
	./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 7; \
	./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 8; \
	done; done; fi

distclean: clean
	rm -f $(ASN_MODULE_SOURCES)
	rm -f $(ASN_MODULE_HEADERS)
	rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
	rm -f Makefile.am.sample
