2020-12-04 18:20:10 -05:00
|
|
|
NAME = gophernicus
|
|
|
|
PACKAGE = $(NAME)
|
|
|
|
BINARY = $(NAME)
|
2021-01-02 20:39:23 -05:00
|
|
|
VERSION = 3.1.1
|
2020-12-04 18:20:10 -05:00
|
|
|
CODENAME = Dungeon Edition
|
|
|
|
|
|
|
|
SOURCES = src/$(NAME).c src/file.c src/menu.c src/string.c src/platform.c src/session.c src/options.c src/log.c
|
|
|
|
HEADERS = src/files.h src/filetypes.h
|
|
|
|
OBJECTS = $(SOURCES:.c=.o)
|
|
|
|
README = README.md
|
2020-12-09 10:15:15 -05:00
|
|
|
MANPAGE = gophernicus.8
|
|
|
|
MAP = gophermap
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
DESTDIR ?= /
|
|
|
|
PREFIX = @PREFIX@
|
|
|
|
BINDIR = @BINDIR@
|
|
|
|
SBINDIR = @SBINDIR@
|
|
|
|
MANDIR = @MANDIR@
|
2020-12-09 10:15:15 -05:00
|
|
|
MAN8DIR = @MAN8DIR@
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
INSTALL = @INSTALL@
|
|
|
|
INSTALL_ARGS = -o 0 -g 0
|
|
|
|
ROOT = @ROOT@
|
|
|
|
OSXROOT = /Library/GopherServer
|
|
|
|
|
|
|
|
INETD = @INETD_CONF@
|
|
|
|
XINETD = @XINETD_CONF@
|
|
|
|
# get OPTIONS line from gophernicus.env and use that also for inetd
|
2020-12-22 19:48:42 -05:00
|
|
|
INETOPT = $$(grep '^OPTIONS=' init/$(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//')
|
2020-12-04 18:20:10 -05:00
|
|
|
LAUNCHD = @LAUNCHD@
|
|
|
|
PLIST = org.$(NAME).server.plist
|
|
|
|
HAIKU_SRV = @HAIKUSRV@
|
|
|
|
DEFAULT = @DEFAULT@
|
|
|
|
SYSCONF = @SYSCONF@
|
2021-01-02 20:09:34 -05:00
|
|
|
SYSTEMD = @SYSTEMD@
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
CC ?= @CC@
|
2020-12-22 19:48:42 -05:00
|
|
|
HOSTCC ?= @HOSTCC@
|
2020-12-04 18:20:10 -05:00
|
|
|
CFLAGS := -O2 -Wall @LIBWRAP@ $(CFLAGS)
|
|
|
|
LDFLAGS := $(LDFLAGS)
|
|
|
|
|
|
|
|
IPCRM ?= @IPCRM@
|
|
|
|
MAKE ?= @MAKE@
|
|
|
|
|
|
|
|
all:
|
|
|
|
$(MAKE) headers
|
|
|
|
$(MAKE) src/$(BINARY)
|
|
|
|
|
|
|
|
headers: $(HEADERS)
|
|
|
|
|
|
|
|
src/$(NAME).c: src/$(NAME).h
|
|
|
|
|
|
|
|
src/$(BINARY): $(OBJECTS)
|
|
|
|
$(CC) $(OBJECTS) $(CFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
|
|
|
|
.c.o:
|
|
|
|
$(CC) -c $(CFLAGS) -DVERSION="\"$(VERSION)\"" -DCODENAME="\"$(CODENAME)\"" -DDEFAULT_ROOT="\"$(ROOT)\"" $< -o $@
|
|
|
|
|
|
|
|
src/filetypes.h: src/filetypes.conf
|
|
|
|
sh src/filetypes.sh < src/filetypes.conf > $@
|
|
|
|
|
|
|
|
src/bin2c: src/bin2c.c
|
2020-12-22 19:48:42 -05:00
|
|
|
$(HOSTCC) src/bin2c.c -o $@
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
src/files.h: src/bin2c
|
|
|
|
sed -e '/^(end of option list)/,$$d' README.md > README.options
|
|
|
|
./src/bin2c -0 -n README README.options > $@
|
|
|
|
./src/bin2c -0 LICENSE >> $@
|
|
|
|
./src/bin2c -n ERROR_GIF error.gif >> $@
|
|
|
|
|
|
|
|
# Clean cases
|
|
|
|
|
|
|
|
clean: @CLEAN_SHM@
|
|
|
|
rm -rf src/$(BINARY) $(OBJECTS) $(HEADERS) README.options README src/bin2c
|
|
|
|
|
|
|
|
clean-shm:
|
|
|
|
$(IPCRM) -M $$(awk '/SHM_KEY/ { print $$3 }' src/$(NAME).h) || true
|
|
|
|
|
|
|
|
# Install cases
|
|
|
|
|
2020-12-09 10:15:15 -05:00
|
|
|
install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(SBINDIR)
|
|
|
|
$(INSTALL) -s -m 755 -t $(DESTDIR)$(SBINDIR) src/$(BINARY)
|
2021-01-02 20:39:14 -05:00
|
|
|
@$(MAKE) -s install-msg
|
|
|
|
|
|
|
|
install-msg:
|
|
|
|
echo
|
|
|
|
echo "======================================================================"
|
|
|
|
echo
|
|
|
|
echo "If there were no errors shown above,"
|
|
|
|
echo "Gophernicus has now been succesfully installed."
|
|
|
|
echo
|
|
|
|
@INSTALL_MSG_INETD@
|
|
|
|
@INSTALL_MSG_XINETD@
|
|
|
|
@INSTALL_MSG_SYSTEMD@
|
|
|
|
@INSTALL_MSG_OSX@
|
|
|
|
@INSTALL_MSG_HAIKU@
|
|
|
|
$(MAKE) install-msg-final
|
|
|
|
|
|
|
|
install-msg-inetd:
|
|
|
|
echo "Please restart the inetd daemon to allow your gopher root to be"
|
|
|
|
echo "accessed."
|
|
|
|
echo "On systemd distributions:"
|
|
|
|
echo " systemctl restart inetd"
|
|
|
|
echo
|
|
|
|
|
|
|
|
install-msg-xinetd:
|
|
|
|
echo "Please restart the xinetd daemon to allow your gopher root to be"
|
|
|
|
echo "accessed."
|
|
|
|
echo "On systemd distributions:"
|
|
|
|
echo " systemctl restart xinetd"
|
|
|
|
echo "You can configure arguments, including the hostname, in $(INETD)."
|
|
|
|
echo
|
|
|
|
|
|
|
|
install-msg-systemd:
|
|
|
|
echo "Please enable and start gophernicus.socket using the commands:"
|
|
|
|
echo " systemctl enable gophernicus.socket"
|
|
|
|
echo " systemctl start gophernicus.socket"
|
|
|
|
echo "to allow your gopher root to be accessed."
|
|
|
|
echo "You can configure arguments, including the hostname, in"
|
|
|
|
echo "$(DEFAULT)/$(NAME) or $(SYSCONF)/$(NAME)."
|
|
|
|
echo
|
|
|
|
|
|
|
|
install-msg-osx:
|
|
|
|
echo "Please reboot your computer to allow your gopher root to be accessed."
|
|
|
|
echo "You can configure arguments, including the hostname, in $(LAUNCHD)."
|
|
|
|
echo
|
|
|
|
|
|
|
|
install-msg-haiku:
|
|
|
|
echo "Please reboot your computer to allow your gopher root to be accessed."
|
|
|
|
echo "You can configure arguments, including the hostname, in $(HAIKU_SRV)"
|
|
|
|
echo "under the gophernicus section."
|
|
|
|
echo
|
|
|
|
|
|
|
|
install-msg-final:
|
|
|
|
echo "======================================================================"
|
|
|
|
echo
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-man:
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(MAN8DIR)
|
|
|
|
$(INSTALL) -m 644 -t $(DESTDIR)$(MAN8DIR) $(MANPAGE)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-root:
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(ROOT)
|
|
|
|
$(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT)/gophermap
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-inetd-update: install-root
|
2021-01-02 20:09:34 -05:00
|
|
|
update-inetd --add "$$(sed -e "s:@BINARY_PATH@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in)"
|
|
|
|
update-inetd --enable gopher
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-inetd-manual: install-root
|
2021-01-02 20:09:34 -05:00
|
|
|
sed -e "s:@BINARY_PATH@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in >> $(DESTDIR)$(INETD)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-xinetd: install-root
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)/etc/xinetd.d
|
2021-01-02 20:09:34 -05:00
|
|
|
sed -i -e "s:@BINARY@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" init/$(NAME).xinetd
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -m 644 -T init/$(NAME).xinetd $(DESTDIR)$(XINETD)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-osx: install-root
|
2020-12-22 19:48:42 -05:00
|
|
|
$(INSTALL) -m 644 init/$(PLIST) $(DESTDIR)$(LAUNCHD)
|
2020-12-04 18:20:10 -05:00
|
|
|
chown -h root:admin $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/*
|
2020-12-26 17:34:40 -05:00
|
|
|
chmod -h 0775 $(DESTDIR)$(ROOT)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
install-haiku: install-root
|
2020-12-22 19:48:42 -05:00
|
|
|
sed -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV)
|
2020-12-04 18:20:10 -05:00
|
|
|
chown user:root $(DESTDIR)$(DOCDIR)/* $(DESTDIR)$(SBINDIR)/$(BINARY) $(DESTDIR)$(ROOT)/$(MAP)
|
|
|
|
|
|
|
|
install-systemd: install-root
|
2020-12-26 17:34:40 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(SYSCONF)
|
|
|
|
$(INSTALL) -m 644 -T init/$(NAME).env $(DESTDIR)$(SYSCONF)/$(NAME)
|
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(DEFAULT)
|
|
|
|
$(INSTALL) -m 644 -T init/$(NAME).env $(DESTDIR)$(DEFAULT)/$(NAME)
|
2021-01-02 20:09:34 -05:00
|
|
|
$(INSTALL) -d -m 755 $(DESTDIR)$(SYSTEMD)
|
|
|
|
$(INSTALL) -m 644 -t $(DESTDIR)$(SYSTEMD) init/$(NAME).socket
|
|
|
|
sed -i -e "s:@BINARY@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" init/$(NAME)\@.service
|
|
|
|
$(INSTALL) -m 644 -t $(DESTDIR)$(SYSTEMD) init/$(NAME)\@.service
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
uninstall: @UNINSTALL_INETD_UPDATE@ @UNINSTALL_INETD_MANUAL@ @UNINSTALL_XINETD@ @UNINSTALL_OSX@ @UNINSTALL_SYSTEMD@
|
|
|
|
rm -f $(DESTDIR)$(SBINDIR)/$(BINARY)
|
2020-12-22 19:48:42 -05:00
|
|
|
rm -f $(DESTDIR)$(MAN8DIR)/$(MANPAGE)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
uninstall-inetd-update:
|
|
|
|
update-inetd --remove "^gopher.*gophernicus"
|
|
|
|
|
|
|
|
uninstall-inetd-manual:
|
|
|
|
sed -i '/^gopher/d' $(DESTDIR)$(INETD)
|
|
|
|
|
|
|
|
uninstall-xinetd:
|
2020-12-22 19:48:42 -05:00
|
|
|
rm -f $(DESTDIR)$(XINETD)
|
2020-12-04 18:20:10 -05:00
|
|
|
|
|
|
|
uninstall-osx:
|
|
|
|
rm -f $(DESTDIR)$(LAUNCHD)/$(PLIST)
|
|
|
|
|
|
|
|
uninstall-haiku:
|
|
|
|
rm -f $(DESTDIR)$(HAIKU_SRV)
|
|
|
|
|
|
|
|
uninstall-systemd:
|
|
|
|
rm -f $(DESTDIR)$(SYSCONF)/$(NAME)/$(NAME).env
|
|
|
|
rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME).env
|
2021-01-02 20:09:34 -05:00
|
|
|
rm -f $(DESTDIR)$(SYSTEMD)/$(NAME).socket
|
|
|
|
rm -f $(DESTDIR)$(SYSTEMD)/$(NAME)\@.service
|