summaryrefslogtreecommitdiff
path: root/mkc_imp.intexts.mk
blob: 4ccdefb8b34d63dfa2fcda59f8a2dbc9b7961396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) 2009-2010 by Aleksey Cheusov
#
# See COPYRIGHT file in the distribution.
############################################################

# Given a list of files in INFILES or INSCRIPTS mkc.intexts.mk
# generates them from appropriate *.in files replacing @prefix@,
# @sysconfdir@, @libdir@, @bindir@, @sbindir@, @datadir@ etc. with
# real ${PREFIX}, ${SYSCONFDIR} etc. See examples/ projects.

.ifndef _MKC_IMP_INTEXTS_MK
_MKC_IMP_INTEXTS_MK := 1

MESSAGE.gen ?=	@${_MESSAGE} "GEN: ${.TARGET}"

INTEXTS_SED  +=	-e 's,@sysconfdir@,${SYSCONFDIR},g'
INTEXTS_SED  +=	-e 's,@libdir@,${LIBDIR},g'
INTEXTS_SED  +=	-e 's,@libexecdir@,${LIBEXECDIR},g'
INTEXTS_SED  +=	-e 's,@prefix@,${PREFIX},g'
INTEXTS_SED  +=	-e 's,@bindir@,${BINDIR},g'
INTEXTS_SED  +=	-e 's,@sbindir@,${SBINDIR},g'
INTEXTS_SED  +=	-e 's,@datadir@,${DATADIR},g'
INTEXTS_SED  +=	-e 's,@mandir@,${MANDIR},g'
INTEXTS_SED  +=	-e 's,@incsdir@,${INCSDIR},g'

.for _pattern _repl in ${INTEXTS_REPLS}
INTEXTS_SED  +=	-e 's,@${_pattern}@,${_repl},g'
.endfor

CLEANFILES   +=	${INSCRIPTS} ${INFILES}

.for i in ${INFILES}
${i} : ${i}.in
	${MESSAGE.gen}
	${_V} sed ${INTEXTS_SED} ${.ALLSRC} > ${.TARGET} && \
	chmod 0644 ${.TARGET}
.endfor

.for i in ${INSCRIPTS}
${i} : ${i}.in
	${MESSAGE.gen}
	${_V} sed ${INTEXTS_SED} ${.ALLSRC} > ${.TARGET} && \
	chmod 0755 ${.TARGET}
.endfor

all : ${INSCRIPTS} ${INFILES}

######################################################################
.endif # _MKC_IMP_INTEXTS_MK