Shell Minimalistic configure without autoconf

I'm developing a script that I use for fetching various CIDR tables such as http://www.spamhaus.org/drop/drop.txt that is the SpamHaus's famous drop list and the script loads the downloaded lists to tables that are in PF ruleset. I'd like to turn the script into a port and I'd like it to be installable with a customizable $PREFIX. The Makefile and the script itself are now hard-coded to use /usr/local as PREFIX. I know how to create a configure script using devel/autoconf having used it for years in my work. However, I feel that using devel/autoconf is a major overkill for the job of just doing a few macro substitutions. Is there anything out there that could automate this type of simple task? I could write the configure script by hand but that feels like re-inventing the wheel...
 
Would something like below in the port's makefile work for you?
Code:
do-install:
    @cd ${WRKSRC} && \
   "${INSTALL_SCRIPT} ${WRKSRC}/my_script ${STAGEDIR}/${PREFIX}/bin"
The user could then set a custom ${PREFIX} (haven't tested this part).

There are similar variables in ${PORTSDIR}/Mk/bsd.port.mk like INSTALL_LIB, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_MAN, COPYTREE_BIN, and COPYTREE_SHARE that might be useful.
 
I see in the porter's handbook the user could set ${PREFIX} with something like make package PREFIX=/custom/location/.
 
Hmm yes, I seem to have assumed that the $PREFIX is only set on configure stage and it's then saved somewhere which is what GNU autoconf does as I recall. That would work for creating a FreeBSD port I guess.
 
I was overthinking the whole problem. All I need to do is set PREFIX in my Makefile so that it can be overridden by environment. Then I need to build my script from a source file substituting @@PREFIX@@ literals with the value of $PREFIX. Something like:

Code:
.SUFFIXES: .sh .sh.in

.sh.in.sh:
    sed -e "s|@@PREFIX@@|${PREFIX}|g" < ${.ALLSRC} > ${.TARGET}

PREFIX?=/usr/local

pf-tables.sh: pf-tables.sh.in

...
 
Back
Top