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