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