xref: /freebsd/usr.bin/vi/catalog/Makefile (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1#	$Id: Makefile,v 9.0 2012/10/19 15:13:11 zy Exp $
2
3.include <bsd.own.mk>
4
5PACKAGE=vi
6V=	${.CURDIR}/../../../contrib/nvi
7
8FILESGROUPS+=VICAT
9CAT=	dutch english french german polish ru_RU.KOI8-R spanish swedish \
10	uk_UA.KOI8-U zh_CN.GB2312 tr_TR.ISO8859-9 tr_TR.UTF-8
11VICAT=		${CAT}
12VICATDIR=	${FILESDIR}
13VICATPACKAGE=	${PACKAGE}
14
15SCAN=	${V}/cl/*.c ${V}/common/*.c ${V}/ex/*.c ${V}/vi/*.c
16
17.PATH: ${V}/catalog
18
19all:		dump
20
21build-tools:	dump
22WARNS=		3
23
24# Helper since iconv is non trivial to make a build tool
25utf8convert:
26.for c in dutch french german spanish swedish
27	iconv -f ISO8859-1 -t UTF-8 $V/catalog/$c.base > $c.UTF-8.base
28.endfor
29	iconv -f ISO8859-2 -t UTF-8 $V/catalog/polish.base > polish.UTF-8.base
30	iconv -f GB2312 -t UTF-8 $V/catalog/zh_CN.GB2312.base > zh_CN.UTF-8.base
31	iconv -f KOI8-R -t UTF-8 $V/catalog/ru_RU.KOI8-R.base > ru_RU.UTF-8.base
32	iconv -f KOI8-U -t UTF-8 $V/catalog/uk_UA.KOI8-U.base > uk_UA.UTF-8.base
33
34.for c in dutch french german polish spanish swedish zh_CN ru_RU uk_UA
35CAT+=	$c.UTF-8
36.endfor
37
38.for c in ${CAT}
39${c}:	${c}.base
40	echo "... $c";							\
41	rm -f $c;							\
42	env LC_ALL=C sort -u ${.ALLSRC} |				\
43	awk '{								\
44		if ($$1 == 1) {						\
45			print "\nMESSAGE NUMBER 1 IS NOT LEGAL";	\
46			exit 1;						\
47		}							\
48		if (++nline > $$1) {					\
49			print "DUPLICATE MESSAGE NUMBER " $$1;		\
50			exit 1;						\
51		}							\
52		print $$0;						\
53	}' |								\
54	sed -e '1s/^/$$set 1~$$quote "~/; 1y/~/\n/' |			\
55	gencat $c /dev/stdin;						\
56	chmod 444 $c;							\
57	if grep DUPLICATE $c > /dev/null; then				\
58		grep DUPLICATE $@;					\
59	fi;								\
60	if grep 'NOT LEGAL' $c > /dev/null; then			\
61		grep 'NOT LEGAL' $@;					\
62	fi
63.endfor
64
65CHK=	dutch.check english.check french.check german.check \
66	polish.check ru_RU.KOI8-R.check spanish.check swedish.check \
67	uk_UA.KOI8-U.check zh_CN.GB2312.check
68check: ${CHK}
69.for c in ${CAT}
70${c}.check: ${c}.base
71	@echo "... $c";							\
72	f=${.ALLSRC:S;.base$;;};					\
73	(echo "Unused message id's (this is okay):";			\
74	awk '{								\
75		while (++nline < $$1)					\
76			printf "%03d\n", nline;				\
77	}' < $$f.base;							\
78	echo =========================;					\
79	echo "MISSING ERROR MESSAGES (Please add!):";			\
80	awk '{print $$1}' < $$f.base | sort -u > __ck1;			\
81	awk '{print $$1}' < english.base | sort -u > __ck2;		\
82	comm -13 __ck1 __ck2;						\
83	echo =========================;					\
84	echo "Extra error messages (just delete them):";		\
85	comm -23 __ck1 __ck2;						\
86	echo =========================;					\
87	echo "MESSAGES WITH THE SAME MESSAGE ID's (FIX!):";		\
88	for j in							\
89	    `sed '/^$$/d' < $$f.base | LC_ALL=C sort -u |		\
90	    awk '{print $$1}' | uniq -d`; do				\
91		egrep $$j $$f.base;					\
92	done;								\
93	echo =========================;					\
94	echo "Duplicate messages, both id and message (this is okay):";	\
95	sed '/^$$/d' < $$f.base | LC_ALL=C sort | uniq -c |		\
96	awk '$$1 != 1 { print $$0 }' | sort -n;				\
97	echo =========================) > $c
98.endfor
99
100english.base: dump ${SCAN} #Makefile
101	${BTOOLSPATH:U.}/dump ${SCAN} |\
102	sed -e '/|/!d' \
103	    -e 's/|/ "/' \
104	    -e 's/^"//' |\
105	LC_ALL=C sort -nu > $@
106
107
108DEPENDOBJS+=	dump
109dump: ${BUILD_TOOLS_META}
110
111CLEANFILES+= dump ${CAT} english.base *.check __ck1 __ck2
112
113CATALOGS= ${CAT}
114NLLINKS= nl_NL
115ENLINKS= en_AU en_CA en_GB en_NZ en_US
116FRLINKS= fr_BE fr_CA fr_CH fr_FR
117DELINKS= de_AT de_CH de_DE
118ESLINKS= es_ES
119SVLINKS= sv_SE
120PLLINKS= pl_PL
121
122FILES=	${CATALOGS}
123FILESDIR= ${SHAREDIR}/vi/catalog
124SYMLINKS=
125.for l in ${NLLINKS}
126SYMLINKS+= dutch ${FILESDIR}/$l.ISO8859-1
127SYMLINKS+= dutch ${FILESDIR}/$l.ISO8859-15
128SYMLINKS+= dutch.UTF-8 ${FILESDIR}/$l.UTF-8
129.endfor
130.for l in ${ENLINKS}
131SYMLINKS+= english ${FILESDIR}/$l.ISO8859-1
132SYMLINKS+= english ${FILESDIR}/$l.ISO8859-15
133SYMLINKS+= english ${FILESDIR}/$l.US-ASCII
134SYMLINKS+= english ${FILESDIR}/$l.UTF-8
135.endfor
136SYMLINKS+= english ${FILESDIR}/POSIX
137SYMLINKS+= english ${FILESDIR}/C
138.for l in ${FRLINKS}
139SYMLINKS+= french ${FILESDIR}/$l.ISO8859-1
140SYMLINKS+= french ${FILESDIR}/$l.ISO8859-15
141SYMLINKS+= french.UTF-8 ${FILESDIR}/$l.UTF-8
142.endfor
143.for l in ${DELINKS}
144SYMLINKS+= german ${FILESDIR}/$l.ISO8859-1
145SYMLINKS+= german ${FILESDIR}/$l.ISO8859-15
146SYMLINKS+= german.UTF-8 ${FILESDIR}/$l.UTF-8
147.endfor
148.for l in ${ESLINKS}
149SYMLINKS+= spanish ${FILESDIR}/$l.ISO8859-1
150SYMLINKS+= spanish ${FILESDIR}/$l.ISO8859-15
151SYMLINKS+= spanish.UTF-8 ${FILESDIR}/$l.UTF-8
152.endfor
153.for l in ${SVLINKS}
154SYMLINKS+= swedish ${FILESDIR}/$l.ISO8859-1
155SYMLINKS+= swedish ${FILESDIR}/$l.ISO8859-15
156SYMLINKS+= swedish.UTF-8 ${FILESDIR}/$l.UTF-8
157.endfor
158.for l in ${PLLINKS}
159SYMLINKS+= polish ${FILESDIR}/$l.ISO8859-2
160SYMLINKS+= polish.UTF-8 ${FILESDIR}/$l.UTF-8
161.endfor
162SYMLINKS+= zh_CN.GB2312 ${FILESDIR}/zh_CN.GB18030
163SYMLINKS+= zh_CN.GB2312 ${FILESDIR}/zh_CN.GBK
164SYMLINKS+= zh_CN.GB2312 ${FILESDIR}/zh_CN.eucCN
165
166.include <bsd.prog.mk>
167