Makefile 5.12 KB
Newer Older
Lev Walkin's avatar
Lev Walkin committed
1
-include Makefile.am.libasncodec
2

Lev Walkin's avatar
Lev Walkin committed
3
TARGET = megaco-dump
Lev Walkin's avatar
Lev Walkin committed
4 5 6 7 8 9 10
ASN_LIBRARY=libasncodec.a
LIBS += -lm
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=MegacoMessage -I.
ASN_CONVERTER_SOURCES := \
	converter-example.c

all: maybe-wip-pause MegacoMessage.c $(TARGET)
11

Lev Walkin's avatar
Lev Walkin committed
12 13
$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o)
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS)
14

Lev Walkin's avatar
Lev Walkin committed
15 16
$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o)
	$(AR) rcs $@ $^
17 18 19 20 21

.SUFFIXES:
.SUFFIXES: .c .o

.c.o:
Lev Walkin's avatar
Lev Walkin committed
22
	$(CC) $(CFLAGS) -o $@ -c $<
23 24

clean:
Lev Walkin's avatar
Lev Walkin committed
25 26
	rm -f $(TARGET) $(ASN_LIBRARY)
	rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o)
27 28 29 30

regen: regenerate-from-asn1-source

regenerate-from-asn1-source:
Lev Walkin's avatar
Lev Walkin committed
31
	../../asn1c/asn1c -S ../../skeletons -pdu=MegacoMessage -fcompound-names ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
32 33


Lev Walkin's avatar
Lev Walkin committed
34
MegacoMessage.c: ../sample.makefile.regen ../rfc3525-MEDIA-GATEWAY-CONTROL.asn1
Lev Walkin's avatar
Lev Walkin committed
35 36 37 38 39
	make regen-makefile
	@touch MegacoMessage.c
	make

regen-makefile:
40 41 42
	ASN1CMDOPTS="-fcompound-names" \
	ASN1MODULES="../rfc3525-MEDIA-GATEWAY-CONTROL.asn1" \
	ASN1PDU=MegacoMessage \
Lev Walkin's avatar
Lev Walkin committed
43
	PROGNAME=megaco-dump \
Lev Walkin's avatar
Lev Walkin committed
44
	../sample.makefile.regen
45

Lev Walkin's avatar
Lev Walkin committed
46
check: ${TARGET} check-ber check-xer check-oer check-per
Lev Walkin's avatar
Lev Walkin committed
47 48 49 50 51
	@echo ================
	@echo All tests passed
	@echo ================

check-ber:
Lev Walkin's avatar
Lev Walkin committed
52
	@if test -f sample-MegacoMessage-1.[db]er ; then \
Lev Walkin's avatar
Lev Walkin committed
53 54
	for f in sample-*-*.[db]er; do \
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin's avatar
Lev Walkin committed
55
	for b in 1 17 33 980 8192; do \
Lev Walkin's avatar
Lev Walkin committed
56 57 58
	echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
	./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
59
	diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
Lev Walkin's avatar
Lev Walkin committed
60
	rm -f ./.tmp.[12].$$$$; \
Lev Walkin's avatar
Lev Walkin committed
61
	echo "Test junking $$f (please wait)..."; \
Lev Walkin's avatar
Lev Walkin committed
62 63
	./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
	./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
Lev Walkin's avatar
Lev Walkin committed
64
	done; done; fi
Lev Walkin's avatar
Lev Walkin committed
65 66

check-xer:
Lev Walkin's avatar
Lev Walkin committed
67
	@if test -f sample-MegacoMessage-1.xer ; then \
Lev Walkin's avatar
Lev Walkin committed
68 69
	for f in sample-*-*.xer; do \
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin's avatar
Lev Walkin committed
70
	for b in 1 17 33 980 8192; do \
Lev Walkin's avatar
Lev Walkin committed
71 72 73
	echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
	./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
74
	diff $$f ./.tmp.2.$$$$ || exit 4; \
Lev Walkin's avatar
Lev Walkin committed
75
	rm -f ./.tmp.[12].$$$$; \
Lev Walkin's avatar
Lev Walkin committed
76
	echo "Test junking $$f (please wait)..."; \
Lev Walkin's avatar
Lev Walkin committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
	./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
	./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
	done; done; fi

check-oer:
	@if test -f sample-MegacoMessage-1.*oer ; then \
	for f in sample-*-*.*oer; do \
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
	for b in 1 17 33 980 8192; do \
	echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
	./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
	diff $$f ./.tmp.2.$$$$ || exit 4; \
	rm -f ./.tmp.[12].$$$$; \
	echo "Test junking $$f (please wait) ($$b) ..."; \
	./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
	./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
Lev Walkin's avatar
Lev Walkin committed
94
	done; done; fi
Lev Walkin's avatar
Lev Walkin committed
95 96

check-per:
97
	@if test -f sample-MegacoMessage-1-nopad.per ; then \
Lev Walkin's avatar
Lev Walkin committed
98 99
	for f in sample-*-[1-9]-nopad.per; do \
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin's avatar
Lev Walkin committed
100
	for b in 1 17 33 980 8192; do \
Lev Walkin's avatar
Lev Walkin committed
101 102 103 104
	echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
	./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
	./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
	./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
105
	diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
Lev Walkin's avatar
Lev Walkin committed
106
	rm -f ./.tmp.[123].$$$$; \
Lev Walkin's avatar
Lev Walkin committed
107
	echo "Test junking $$f (please wait)..."; \
Lev Walkin's avatar
Lev Walkin committed
108 109
	./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
	./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
Lev Walkin's avatar
Lev Walkin committed
110
	done; done; fi
111 112
	@if test -f sample-MegacoMessage-1.per ; then \
	for f in sample-*-[1-9].per; do \
Lev Walkin's avatar
Lev Walkin committed
113
	pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin's avatar
Lev Walkin committed
114
	for b in 1 17 33 980 8192; do \
Lev Walkin's avatar
Lev Walkin committed
115 116 117 118
	echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
	./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
	./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
	./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
119
	diff $$f ./.tmp.1.$$$$ || exit 6; \
Lev Walkin's avatar
Lev Walkin committed
120
	rm -f ./.tmp.[12].$$$$; \
Lev Walkin's avatar
Lev Walkin committed
121
	echo "Test junking $$f (please wait)..."; \
Lev Walkin's avatar
Lev Walkin committed
122 123
	./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
	./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
Lev Walkin's avatar
Lev Walkin committed
124
	done; done; fi
Lev Walkin's avatar
Lev Walkin committed
125

Lev Walkin's avatar
Lev Walkin committed
126 127 128
maybe-wip-pause:
	@if [ -f WIP ]; then cat WIP; sleep 2; fi

129
distclean: clean
130 131
	rm -f $(ASN_MODULE_SOURCES)
	rm -f $(ASN_MODULE_HEADERS)
132
	rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
Lev Walkin's avatar
Lev Walkin committed
133
	rm -f Makefile.am.example