blob: 18aec49e30ef15f09b9cb1cffe4df0e9128c5f34 [file] [log] [blame]
Lev Walkinad775912017-09-26 22:55:22 -07001-include Makefile.am.libasncodec
Lev Walkin60a14032004-09-23 22:02:52 +00002
Lev Walkin60a14032004-09-23 22:02:52 +00003TARGET = x509dump
Lev Walkinad775912017-09-26 22:55:22 -07004ASN_LIBRARY=libasncodec.a
5LIBS += -lm
6CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -D_DEFAULT_SOURCE $(ASN_MODULE_CFLAGS) -DPDU=Certificate -I.
7ASN_CONVERTER_SOURCES := \
8 converter-example.c
Lev Walkin60a14032004-09-23 22:02:52 +00009
Lev Walkin0c050a82017-08-27 12:39:47 -070010all: maybe-wip-pause Certificate.c $(TARGET)
Lev Walkin60a14032004-09-23 22:02:52 +000011
Lev Walkinad775912017-09-26 22:55:22 -070012$(TARGET): $(ASN_LIBRARY) $(ASN_CONVERTER_SOURCES:.c=.o)
13 $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(ASN_CONVERTER_SOURCES:.c=.o) $(LDFLAGS) $(ASN_LIBRARY) $(LIBS)
14
15$(ASN_LIBRARY): $(ASN_MODULE_SOURCES:.c=.o)
16 $(AR) rcs $@ $^
Lev Walkin60a14032004-09-23 22:02:52 +000017
18.SUFFIXES:
19.SUFFIXES: .c .o
20
21.c.o:
Lev Walkinad775912017-09-26 22:55:22 -070022 $(CC) $(CFLAGS) -o $@ -c $<
Lev Walkin60a14032004-09-23 22:02:52 +000023
24clean:
Lev Walkinad775912017-09-26 22:55:22 -070025 rm -f $(TARGET) $(ASN_LIBRARY)
26 rm -f $(ASN_MODULE_SOURCES:.c=.o) $(ASN_CONVERTER_SOURCES:.c=.o)
Lev Walkin60a14032004-09-23 22:02:52 +000027
Lev Walkin4b24d482005-03-06 09:28:03 +000028regen: regenerate-from-asn1-source
29
30regenerate-from-asn1-source:
Lev Walkinad775912017-09-26 22:55:22 -070031 ../../asn1c/asn1c -S ../../skeletons -pdu=Certificate -fcompound-names -fwide-types ../rfc3280-PKIX1Explicit88.asn1 ../rfc3280-PKIX1Implicit88.asn1
Lev Walkin4b24d482005-03-06 09:28:03 +000032
Lev Walkin60a14032004-09-23 22:02:52 +000033
Lev Walkinc33a59e2006-09-18 20:04:14 +000034Certificate.c: ../sample.makefile.regen ../rfc3280-*.asn1
Lev Walkincc7c94e2006-09-17 04:01:29 +000035 make regen-makefile
36 @touch Certificate.c
37 make
38
39regen-makefile:
Lev Walkinad775912017-09-26 22:55:22 -070040 ASN1CMDOPTS="-fcompound-names -fwide-types" \
Lev Walkinf5b49392006-09-12 06:19:15 +000041 ASN1MODULES="../rfc3280-*.asn1" \
42 ASN1PDU=Certificate \
43 PROGNAME=x509dump \
Lev Walkin2fd86de2006-09-13 02:10:23 +000044 ../sample.makefile.regen
Lev Walkin60a14032004-09-23 22:02:52 +000045
Lev Walkinad775912017-09-26 22:55:22 -070046check: ${TARGET} check-ber check-xer check-oer check-per
Lev Walkin1f12da42006-09-24 19:47:07 +000047 @echo ================
48 @echo All tests passed
49 @echo ================
50
51check-ber:
Lev Walkin13afe532006-09-18 21:30:04 +000052 @if test -f sample-Certificate-1.[db]er ; then \
Lev Walkina926fce2017-08-27 12:54:25 -070053 for f in sample-*-*.[db]er; do \
Lev Walkinad775912017-09-26 22:55:22 -070054 pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin13afe532006-09-18 21:30:04 +000055 for b in 1 17 33 980 8192; do \
Lev Walkina926fce2017-08-27 12:54:25 -070056 echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
57 ./${TARGET} -p $$pdu -b $$b -iber -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
58 ./${TARGET} -p $$pdu -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
Lev Walkin3cd82c32007-06-26 08:37:20 +000059 diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 4; \
Lev Walkinc33a59e2006-09-18 20:04:14 +000060 rm -f ./.tmp.[12].$$$$; \
Lev Walkin1f12da42006-09-24 19:47:07 +000061 echo "Test junking $$f (please wait)..."; \
Lev Walkina926fce2017-08-27 12:54:25 -070062 ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 5; \
63 ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iber -onull $$f || exit 6; \
Lev Walkin13afe532006-09-18 21:30:04 +000064 done; done; fi
Lev Walkin1f12da42006-09-24 19:47:07 +000065
66check-xer:
Lev Walkin13afe532006-09-18 21:30:04 +000067 @if test -f sample-Certificate-1.xer ; then \
Lev Walkina926fce2017-08-27 12:54:25 -070068 for f in sample-*-*.xer; do \
Lev Walkinad775912017-09-26 22:55:22 -070069 pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin13afe532006-09-18 21:30:04 +000070 for b in 1 17 33 980 8192; do \
Lev Walkina926fce2017-08-27 12:54:25 -070071 echo "Recoding $$f ($$pdu) into DER and back ($$b)..."; \
72 ./${TARGET} -p $$pdu -b $$b -ixer -oder $$f > ./.tmp.1.$$$$ || exit 2; \
73 ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
Lev Walkin3cd82c32007-06-26 08:37:20 +000074 diff $$f ./.tmp.2.$$$$ || exit 4; \
Lev Walkinc33a59e2006-09-18 20:04:14 +000075 rm -f ./.tmp.[12].$$$$; \
Lev Walkin1f12da42006-09-24 19:47:07 +000076 echo "Test junking $$f (please wait)..."; \
Lev Walkina926fce2017-08-27 12:54:25 -070077 ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 5; \
78 ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ixer -onull $$f || exit 6; \
Lev Walkin13afe532006-09-18 21:30:04 +000079 done; done; fi
Lev Walkin1f12da42006-09-24 19:47:07 +000080
Lev Walkinad775912017-09-26 22:55:22 -070081check-oer:
82 @if test -f sample-Certificate-1.*oer ; then \
83 for f in sample-*-*.*oer; do \
84 pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
85 for b in 1 17 33 980 8192; do \
86 echo "Recoding $$f ($$pdu) into XER and back ($$b)..."; \
87 ./${TARGET} -p $$pdu -b $$b -ioer -oxer $$f > ./.tmp.1.$$$$ || exit 2; \
88 ./${TARGET} -p $$pdu -b $$b -ixer -ooer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
89 diff $$f ./.tmp.2.$$$$ || exit 4; \
90 rm -f ./.tmp.[12].$$$$; \
91 echo "Test junking $$f (please wait) ($$b) ..."; \
92 ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 5; \
93 ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -ioer -onull $$f || exit 6; \
94 done; done; fi
95
Lev Walkin1f12da42006-09-24 19:47:07 +000096check-per:
Lev Walkin3cd82c32007-06-26 08:37:20 +000097 @if test -f sample-Certificate-1-nopad.per ; then \
Lev Walkina926fce2017-08-27 12:54:25 -070098 for f in sample-*-[1-9]-nopad.per; do \
Lev Walkinad775912017-09-26 22:55:22 -070099 pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin13afe532006-09-18 21:30:04 +0000100 for b in 1 17 33 980 8192; do \
Lev Walkina926fce2017-08-27 12:54:25 -0700101 echo "Recoding non-padded $$f ($$pdu) into DER into XER and back ($$b)..."; \
102 ./${TARGET} -p $$pdu -b $$b -per-nopad -iper -oder $$f > ./.tmp.1.$$$$ || exit 2; \
103 ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 3; \
104 ./${TARGET} -p $$pdu -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 4; \
Lev Walkin3cd82c32007-06-26 08:37:20 +0000105 diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 5; \
Lev Walkin13afe532006-09-18 21:30:04 +0000106 rm -f ./.tmp.[123].$$$$; \
Lev Walkin1f12da42006-09-24 19:47:07 +0000107 echo "Test junking $$f (please wait)..."; \
Lev Walkina926fce2017-08-27 12:54:25 -0700108 ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 6; \
109 ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -per-nopad -iper -onull $$f || exit 7; \
Lev Walkin13afe532006-09-18 21:30:04 +0000110 done; done; fi
Lev Walkin3cd82c32007-06-26 08:37:20 +0000111 @if test -f sample-Certificate-1.per ; then \
112 for f in sample-*-[1-9].per; do \
Lev Walkinad775912017-09-26 22:55:22 -0700113 pdu=`echo $$f | sed -E -e "s/sample-([A-Za-z0-9-]+)-[0-9].*/\1/"`; \
Lev Walkin13afe532006-09-18 21:30:04 +0000114 for b in 1 17 33 980 8192; do \
Lev Walkina926fce2017-08-27 12:54:25 -0700115 echo "Recoding $$f ($$pdu) into DER into XER and back ($$b)..."; \
116 ./${TARGET} -p $$pdu -b $$b -iper -oder $$f > ./.tmp.1.$$$$ || exit 3; \
117 ./${TARGET} -p $$pdu -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 4; \
118 ./${TARGET} -p $$pdu -b $$b -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 5; \
Lev Walkin3cd82c32007-06-26 08:37:20 +0000119 diff $$f ./.tmp.1.$$$$ || exit 6; \
Lev Walkin13afe532006-09-18 21:30:04 +0000120 rm -f ./.tmp.[12].$$$$; \
Lev Walkin1f12da42006-09-24 19:47:07 +0000121 echo "Test junking $$f (please wait)..."; \
Lev Walkina926fce2017-08-27 12:54:25 -0700122 ./${TARGET} -J0.0001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 7; \
123 ./${TARGET} -J0.001 -n 1000 -p $$pdu -b $$b -iper -onull $$f || exit 8; \
Lev Walkin13afe532006-09-18 21:30:04 +0000124 done; done; fi
Lev Walkinc744a022006-09-15 18:33:25 +0000125
Lev Walkin0c050a82017-08-27 12:39:47 -0700126maybe-wip-pause:
127 @if [ -f WIP ]; then cat WIP; sleep 2; fi
128
Lev Walkin60a14032004-09-23 22:02:52 +0000129distclean: clean
Lev Walkinbcda5ff2006-09-17 03:29:51 +0000130 rm -f $(ASN_MODULE_SOURCES)
131 rm -f $(ASN_MODULE_HEADERS)
Lev Walkinf5b49392006-09-12 06:19:15 +0000132 rm -f $(ASN_CONVERTER_SOURCES) $(ASN_CONVERTER_HEADERS)
Lev Walkinad775912017-09-26 22:55:22 -0700133 rm -f Makefile.am.example