Subject: handling generated config files (or substitutions within)
To: None <tech-toolchain@netbsd.org>
From: john heasley <heas@shrubbery.net>
List: tech-toolchain
Date: 05/19/2004 15:20:53
Postfix comes with a main.cf template which has some required variables
without a valkue.  These are normally filled at post-install time by
a script that comes with Postfix.  However, that script uses postconf
(a binary built w/ Postfix) to get the system-dependent default and I
gather that wouldn't work well for cross builds.

I'd like to just use sed to make the substitutions.  I have that working,
but I'm not sure that my technique is the proper way or necessarily the
most elegant.  Or is altering Postfix's template file the preferred
solution?

comments on the following?

gnu/usr.sbin/postfix/postfix-etc/Makefile:
	...
SRCS=           ${DIST}/main.cf
CONFIGFILES=    main.cf master.cf postfix-files README

CONFIGFILES+=                   postfix-script post-install
FILESMODE_postfix-script=       ${BINMODE}
FILESMODE_post-install=         ${BINMODE}

.include "${.CURDIR}/../Makefile.inc"

CLEANFILES+= main.cf

all: main.cf

main.cf: ${SRCS} Makefile
        sed -e "/^setgid_group =/s/$$/ maildrop/" \
                -e "\|^html_directory =|s|$$| ${PFIX_HTMLDIR}|" \
                -e "\|^mailq_path =|s|$$| /usr/bin/mailq|" \
                -e "\|^manpage_directory =|s|$$| /usr/share/man|" \
                -e "\|^newaliases_path =|s|$$| /usr/bin/newaliases|" \
                -e "\|^readme_directory =|s|$$| ${PFIX_EXAMPLEDIR}|" \
                -e "\|^sample_directory =|s|$$| ${PFIX_EXAMPLEDIR}|" \
                -e "\|^sendmail_path =|s|$$| /usr/sbin/sendmail|" \
                ${DIST}/main.cf > main.cf

.include <bsd.prog.mk>