env/utils/httpd/Makefile

59 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2020-12-29 00:24:06 +01:00
# httpd-utils
# Written in 2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty. You should have received a copy of the CC0 Public Domain
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
.POSIX:
.SUFFIXES:
.SUFFIXES: .c
P = httpd-utils
V = 1
DOMAIN = example.net
DOMAIN_V4 = 4.${DOMAIN}
DOMAIN_V6 = 6.${DOMAIN}
IPV4 = 192.0.2.1
IPV6 = 2001:db8::2
PREFIX = /var/www/htdocs/${DOMAIN}
CGI = ip
SRC = ip.c gen-config.sh gen-index.sh
TXT = codes.txt
.c:
${CC} ${CFLAGS} ${LDFLAGS} -static -o $@ $<
all: ${DOMAIN}.httpd.conf index.html ${CGI}
${DOMAIN}.httpd.conf: gen-config.sh codes.txt
sh gen-config.sh ${DOMAIN} ${DOMAIN_V4} ${IPV4} ${DOMAIN_V6} ${IPV6} >$@
index.html: gen-index.sh codes.txt
sh gen-index.sh ${DOMAIN} ${DOMAIN_V4} ${DOMAIN_V6} >$@
clean:
rm -f ${DOMAIN}.httpd.conf index.html ${CGI} ${P}-${V}.tgz
dist: clean
pax -ws ',^,${P}-${V}/,' Makefile ${SRC} ${TXT} | gzip >${P}-${V}.tgz
install: all
cp -f ${DOMAIN}.httpd.conf /etc
mkdir -p ${PREFIX}
cp -f ${CGI} ${PREFIX}
cd ${PREFIX} && chmod 555 ${CGI}
cd ${PREFIX} && chown www:www ${CGI}
cp -f index.html ${PREFIX}
cd ${PREFIX} && chmod 444 index.html
cd ${PREFIX} && chown www:www index.html
uninstall:
rm -f /etc/${DOMAIN}.httpd.conf
cd ${PREFIX} && rm -f ${CGI} index.html