ASN_MODULE_SOURCES=	\
	MegacoMessage.c	\
	AuthenticationHeader.c	\
	SecurityParmIndex.c	\
	SequenceNum.c	\
	AuthData.c	\
	Message.c	\
	MId.c	\
	DomainName.c	\
	IP4Address.c	\
	IP6Address.c	\
	PathName.c	\
	Transaction.c	\
	TransactionId.c	\
	TransactionRequest.c	\
	TransactionPending.c	\
	TransactionReply.c	\
	TransactionResponseAck.c	\
	TransactionAck.c	\
	ErrorDescriptor.c	\
	ErrorCode.c	\
	ErrorText.c	\
	ContextID.c	\
	ActionRequest.c	\
	ActionReply.c	\
	ContextRequest.c	\
	ContextAttrAuditRequest.c	\
	CommandRequest.c	\
	Command.c	\
	CommandReply.c	\
	TopologyRequest.c	\
	AmmRequest.c	\
	AmmDescriptor.c	\
	AmmsReply.c	\
	SubtractRequest.c	\
	AuditRequest.c	\
	AuditReply.c	\
	AuditResult.c	\
	TerminationAudit.c	\
	AuditReturnParameter.c	\
	AuditDescriptor.c	\
	NotifyRequest.c	\
	NotifyReply.c	\
	ObservedEventsDescriptor.c	\
	ObservedEvent.c	\
	EventName.c	\
	EventParameter.c	\
	ServiceChangeRequest.c	\
	ServiceChangeReply.c	\
	ServiceChangeResult.c	\
	WildcardField.c	\
	TerminationID.c	\
	TerminationIDList.c	\
	MediaDescriptor.c	\
	StreamDescriptor.c	\
	StreamParms.c	\
	LocalControlDescriptor.c	\
	StreamMode.c	\
	PropertyParm.c	\
	Name.c	\
	PkgdName.c	\
	Relation.c	\
	LocalRemoteDescriptor.c	\
	PropertyGroup.c	\
	TerminationStateDescriptor.c	\
	EventBufferControl.c	\
	ServiceState.c	\
	MuxDescriptor.c	\
	MuxType.c	\
	StreamID.c	\
	EventsDescriptor.c	\
	RequestedEvent.c	\
	RequestedActions.c	\
	EventDM.c	\
	SecondEventsDescriptor.c	\
	SecondRequestedEvent.c	\
	SecondRequestedActions.c	\
	EventBufferDescriptor.c	\
	EventSpec.c	\
	SignalsDescriptor.c	\
	SignalRequest.c	\
	SeqSigList.c	\
	Signal.c	\
	SignalType.c	\
	SignalName.c	\
	NotifyCompletion.c	\
	SigParameter.c	\
	RequestID.c	\
	ModemDescriptor.c	\
	ModemType.c	\
	DigitMapDescriptor.c	\
	DigitMapName.c	\
	DigitMapValue.c	\
	ServiceChangeParm.c	\
	ServiceChangeAddress.c	\
	ServiceChangeResParm.c	\
	ServiceChangeMethod.c	\
	ServiceChangeProfile.c	\
	PackagesDescriptor.c	\
	PackagesItem.c	\
	StatisticsDescriptor.c	\
	StatisticsParameter.c	\
	NonStandardData.c	\
	NonStandardIdentifier.c	\
	H221NonStandard.c	\
	TimeNotation.c	\
	Value.c

ASN_MODULE_HEADERS=	\
	MegacoMessage.h	\
	AuthenticationHeader.h	\
	SecurityParmIndex.h	\
	SequenceNum.h	\
	AuthData.h	\
	Message.h	\
	MId.h	\
	DomainName.h	\
	IP4Address.h	\
	IP6Address.h	\
	PathName.h	\
	Transaction.h	\
	TransactionId.h	\
	TransactionRequest.h	\
	TransactionPending.h	\
	TransactionReply.h	\
	TransactionResponseAck.h	\
	TransactionAck.h	\
	ErrorDescriptor.h	\
	ErrorCode.h	\
	ErrorText.h	\
	ContextID.h	\
	ActionRequest.h	\
	ActionReply.h	\
	ContextRequest.h	\
	ContextAttrAuditRequest.h	\
	CommandRequest.h	\
	Command.h	\
	CommandReply.h	\
	TopologyRequest.h	\
	AmmRequest.h	\
	AmmDescriptor.h	\
	AmmsReply.h	\
	SubtractRequest.h	\
	AuditRequest.h	\
	AuditReply.h	\
	AuditResult.h	\
	TerminationAudit.h	\
	AuditReturnParameter.h	\
	AuditDescriptor.h	\
	NotifyRequest.h	\
	NotifyReply.h	\
	ObservedEventsDescriptor.h	\
	ObservedEvent.h	\
	EventName.h	\
	EventParameter.h	\
	ServiceChangeRequest.h	\
	ServiceChangeReply.h	\
	ServiceChangeResult.h	\
	WildcardField.h	\
	TerminationID.h	\
	TerminationIDList.h	\
	MediaDescriptor.h	\
	StreamDescriptor.h	\
	StreamParms.h	\
	LocalControlDescriptor.h	\
	StreamMode.h	\
	PropertyParm.h	\
	Name.h	\
	PkgdName.h	\
	Relation.h	\
	LocalRemoteDescriptor.h	\
	PropertyGroup.h	\
	TerminationStateDescriptor.h	\
	EventBufferControl.h	\
	ServiceState.h	\
	MuxDescriptor.h	\
	MuxType.h	\
	StreamID.h	\
	EventsDescriptor.h	\
	RequestedEvent.h	\
	RequestedActions.h	\
	EventDM.h	\
	SecondEventsDescriptor.h	\
	SecondRequestedEvent.h	\
	SecondRequestedActions.h	\
	EventBufferDescriptor.h	\
	EventSpec.h	\
	SignalsDescriptor.h	\
	SignalRequest.h	\
	SeqSigList.h	\
	Signal.h	\
	SignalType.h	\
	SignalName.h	\
	NotifyCompletion.h	\
	SigParameter.h	\
	RequestID.h	\
	ModemDescriptor.h	\
	ModemType.h	\
	DigitMapDescriptor.h	\
	DigitMapName.h	\
	DigitMapValue.h	\
	ServiceChangeParm.h	\
	ServiceChangeAddress.h	\
	ServiceChangeResParm.h	\
	ServiceChangeMethod.h	\
	ServiceChangeProfile.h	\
	PackagesDescriptor.h	\
	PackagesItem.h	\
	StatisticsDescriptor.h	\
	StatisticsParameter.h	\
	NonStandardData.h	\
	NonStandardIdentifier.h	\
	H221NonStandard.h	\
	TimeNotation.h	\
	Value.h

ASN_MODULE_HEADERS+=BOOLEAN.h
ASN_MODULE_SOURCES+=BOOLEAN.c
ASN_MODULE_HEADERS+=INTEGER.h
ASN_MODULE_HEADERS+=NativeEnumerated.h
ASN_MODULE_HEADERS+=IA5String.h
ASN_MODULE_SOURCES+=IA5String.c
ASN_MODULE_SOURCES+=INTEGER.c
ASN_MODULE_HEADERS+=NULL.h
ASN_MODULE_SOURCES+=NULL.c
ASN_MODULE_SOURCES+=NativeEnumerated.c
ASN_MODULE_HEADERS+=NativeInteger.h
ASN_MODULE_SOURCES+=NativeInteger.c
ASN_MODULE_HEADERS+=OBJECT_IDENTIFIER.h
ASN_MODULE_SOURCES+=OBJECT_IDENTIFIER.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+=oer_decoder.h
ASN_MODULE_SOURCES+=oer_decoder.c
ASN_MODULE_HEADERS+=oer_encoder.h
ASN_MODULE_SOURCES+=oer_encoder.c
ASN_MODULE_HEADERS+=oer_support.h
ASN_MODULE_SOURCES+=oer_support.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


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 = megaco-dump
CPPFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE  -DASN_DISABLE_OER_SUPPORT -DASN_DISABLE_PER_SUPPORT -DPDU=MegacoMessage -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}

all: MegacoMessage.c $(TARGET)

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

.SUFFIXES:
.SUFFIXES: .c .o

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

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

regen: regenerate-from-asn1-source

regenerate-from-asn1-source:
	../../asn1c/asn1c -S ../../skeletons -pdu=MegacoMessage -fcompound-names ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1


MegacoMessage.c: ../sample.makefile.regen ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
	make regen-makefile
	@touch MegacoMessage.c
	make

regen-makefile:
	ASN1CMDOPTS="-fcompound-names" \
	ASN1MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \
	ASN1PDU=MegacoMessage \
	PROGNAME=megaco-dump \
	CPPFLAGS="" \
	../sample.makefile.regen

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

check-ber:
	@if test -f sample-MegacoMessage-1.[db]er ; then \
	for f in sample-MegacoMessage-*.[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-MegacoMessage-1.xer ; then \
	for f in sample-MegacoMessage-*.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-MegacoMessage-1-nopad.per ; then \
	for f in sample-MegacoMessage-[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-MegacoMessage-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
