xref: /freebsd/share/mk/bsd.nls.mk (revision df21a004be237a1dccd03c7b47254625eea62fa9)
1#
2# Handle building and installing Native Language Support (NLS) catalogs.
3# This is implemented using a <bsd.files.mk> files group called "NLS",
4# so any per-group options that bsd.files.mk supports can be used here
5# with the prefix "NLS".
6#
7# +++ variables +++
8#
9# GENCAT	A program for converting .msg files into compiled NLS
10#		.cat files. [gencat]
11#
12# NLS		Source or intermediate .msg files. [set in Makefile]
13#
14# NLSDIR	Base path for National Language Support files
15#		installation. [${SHAREDIR}/nls]
16#
17# NLSGRP	National Language Support files group. [${SHAREGRP}]
18#
19# NLSMODE	National Language Support files mode. [${NOBINMODE}]
20#
21# NLSOWN	National Language Support files owner. [${SHAREOWN}]
22#
23# NLSPACKAGE	Package to install the NLS files in.
24#		[${PACKAGE}, or "utilities" if not set]
25
26.if !target(__<bsd.init.mk>__)
27.error bsd.nls.mk cannot be included directly.
28.endif
29
30GENCAT?=	gencat
31
32.SUFFIXES: .cat .msg
33
34.msg.cat:
35	${GENCAT} ${.TARGET} ${.IMPSRC}
36
37.if defined(NLS) && !empty(NLS) && ${MK_NLS} != "no"
38
39#
40# .msg file pre-build rules
41#
42NLSSRCDIR?=	${.CURDIR}
43.for file in ${NLS}
44.if defined(NLSSRCFILES)
45NLSSRCFILES_${file}?= ${NLSSRCFILES}
46.endif
47.if defined(NLSSRCFILES_${file})
48NLSSRCDIR_${file}?= ${NLSSRCDIR}
49${file}.msg: ${NLSSRCFILES_${file}:S/^/${NLSSRCDIR_${file}}\//}
50	@rm -f ${.TARGET}
51	cat ${.ALLSRC} > ${.TARGET}
52CLEANFILES+= ${file}.msg
53.endif
54.endfor
55
56#
57# .cat file build rules
58#
59NLS:=		${NLS:=.cat}
60CLEANFILES+=	${NLS}
61FILESGROUPS?=	FILES
62FILESGROUPS+=	NLS
63NLSDIR?=	${SHAREDIR}/nls
64
65#
66# installation rules
67#
68.if ${MK_STAGING_PROG} == "yes"
69.if !defined(_SKIP_BUILD)
70STAGE_TARGETS+= stage_symlinks
71.endif
72STAGE_SYMLINKS.NLS= ${NLSSYMLINKS}
73STAGE_SYMLINKS_DIR.NLS= ${STAGE_OBJTOP}
74.else
75SYMLINKS+= ${NLSSYMLINKS}
76.endif
77.for file in ${NLS}
78NLSDIR_${file:T}=	${NLSDIR}/${file:T:R}
79NLSNAME_${file:T}=	${NLSNAME}.cat
80.if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
81.if !empty(NLSLINKS_${file:R}:M${file:R})
82.error NLSLINKS_${file:R} contains itself: ${file:R}
83.endif
84.endif
85.for dst in ${NLSLINKS_${file:R}}
86NLSSYMLINKS+= ../${file:R}/${NLSNAME}.cat ${NLSDIR}/${dst}/${NLSNAME}.cat
87.endfor
88.endfor
89
90.endif # defined(NLS) && !empty(NLS) && ${MK_NLS} != "no"
91