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