1#	$NetBSD: Makefile,v 1.3 2018/05/01 19:59:43 christos Exp $
2#
3#	@(#)Makefile	8.29 (Berkeley) 10/19/96
4
5.include <bsd.hostinit.mk>
6
7.PATH:	${DIST}/catalog
8
9CATALOG=	dutch english french german ru_RU.KOI8-R spanish swedish
10
11VI_FILES=	${DIST}/cl/*.c ${DIST}/common/*.c \
12		${DIST}/ex/*.c ${DIST}/vi/*.c
13FILES=		${CATALOG}
14FILESDIR=	/usr/share/nvi/catalog
15
16HOSTPROG=	dump
17SRCS=		dump.c
18
19CLEANFILES+=	${CATALOG} english.base *.check __ck1 __ck2
20
21realall: ${CATALOG}
22
23${CATALOG}: ${CATALOG:S/$/.base/}
24	@echo "... $@";							\
25	rm -f $@;							\
26	if test -f $@.base; then					\
27		f=$@.base;						\
28	else								\
29		f=${DIST}/catalog/$@.base;				\
30	fi;								\
31	sort -u $$f |							\
32	${TOOL_AWK} '{							\
33		if ($$1 == 1) {						\
34			print "\nMESSAGE NUMBER 1 IS NOT LEGAL";	\
35			exit 1;						\
36		}							\
37		if (++nline > $$1) {					\
38			print "DUPLICATE MESSAGE NUMBER " $$1;		\
39			exit 1;						\
40		}							\
41		for (; nline < $$1; ++nline)				\
42			print "";					\
43		print $0;						\
44	}' |								\
45	${TOOL_SED} -e '1s/^/VI_MESSAGE_CATALOG/'			\
46	    -e '/"/s/^[^"]*"//'						\
47	    -e '1!s/"$$/X/' > $@;					\
48	if grep DUPLICATE $@ > /dev/null; then				\
49		grep DUPLICATE $@;					\
50	fi;								\
51	if grep 'NOT LEGAL' $@ > /dev/null; then			\
52		grep 'NOT LEGAL' $@;					\
53	fi
54
55CHK=	dutch.check english.check french.check german.check \
56	ru_RU.KOI8-R.check spanish.check swedish.check
57check: ${CHK}
58${CHK}: ${CATALOG}
59	@echo "... $@";							\
60	f=${DIST}/catalog/`basename $@ .check`;				\
61	(echo "Unused message id's (this is okay):";			\
62	${TOOL_AWK} '{							\
63		while (++nline < $$1)					\
64			printf "%03d\n", nline;				\
65	}' < ${DIST}/catalog/$$f.base;					\
66	echo =========================;					\
67	echo "MISSING ERROR MESSAGES (Please add!):";			\
68	${TOOL_AWK} '{print $$1}' < $$f.base | sort -u > __ck1;		\
69	${TOOL_AWK} '{print $$1}' < english.base | sort -u > __ck2;	\
70	comm -13 __ck1 __ck2;						\
71	echo =========================;					\
72	echo "Extra error messages (just delete them):";		\
73	comm -23 __ck1 __ck2;						\
74	echo =========================;					\
75	echo "MESSAGES WITH THE SAME MESSAGE ID's (FIX!):";		\
76	for j in							\
77	    `${TOOL_SED} '/^$$/d' < $$f.base | sort -u |		\
78	    ${TOOL_AWK} '{print $$1}' | uniq -d`; do			\
79		egrep $$j $$f.base;					\
80	done;								\
81	echo =========================;					\
82	echo "Duplicate messages, both id and message (this is okay):";	\
83	${TOOL_SED} '/^$$/d' < $$f.base | sort | uniq -c |		\
84	${TOOL_AWK} '$$1 != 1 { print $$0 }' | sort -n;			\
85	echo =========================;					\
86	echo "Duplicate messages, just message (this is okay):";	\
87	${TOOL_SED} '/^$$/d' < $$f | sort | uniq -c |			\
88	${TOOL_AWK} '$$1 != 1 { print $$0 }' | sort -n;			\
89	echo =========================) > $@
90
91english.base: dump ${VI_FILES} #Makefile
92	${_MKTARGET_CREATE}
93	./dump ${VI_FILES} |\
94	${TOOL_SED} -e '/|/!d' \
95	    -e 's/|/ "/' \
96	    -e 's/^"//' \
97	    -e 's/\\"/"/g' |\
98	sort -n > $@
99
100.include <bsd.hostprog.mk>
101