mirror of
https://github.com/gophernicus/gophernicus.git
synced 2024-11-03 04:27:17 -05:00
Introduce new build system
This build system is very different to the old build system, and is much more inuitive. It leverages a hand made configure script to generate the Makefile. The listener is no longer auto-detected, unless specifically specified, and no longer activated by default. That is not the place for a build system. Along with the focus of moving to distribution repositiories, this 'feature' is clearly unwanted by distributions. Multiple listeners are now also supported, primarily for distributions. Lastly, parallelism now works as well.
This commit is contained in:
parent
5aade41f00
commit
1720740bdd
21
.gitignore
vendored
21
.gitignore
vendored
@ -6,26 +6,7 @@ src/files.h
|
|||||||
src/filetypes.h
|
src/filetypes.h
|
||||||
src/bin2c
|
src/bin2c
|
||||||
src/gophernicus
|
src/gophernicus
|
||||||
|
Makefile
|
||||||
|
|
||||||
README
|
README
|
||||||
README.options
|
README.options
|
||||||
|
|
||||||
#
|
|
||||||
# Test leftovers
|
|
||||||
#
|
|
||||||
test.output
|
|
||||||
|
|
||||||
#
|
|
||||||
# Release files
|
|
||||||
#
|
|
||||||
*.gz
|
|
||||||
|
|
||||||
#
|
|
||||||
# Debian packaging leftovers
|
|
||||||
#
|
|
||||||
build-stamp
|
|
||||||
debian/files
|
|
||||||
debian/gophernicus.debhelper.log
|
|
||||||
debian/gophernicus.postrm.debhelper
|
|
||||||
debian/gophernicus.substvars
|
|
||||||
debian/gophernicus/
|
|
||||||
|
269
Makefile
269
Makefile
@ -1,269 +0,0 @@
|
|||||||
NAME = gophernicus
|
|
||||||
PACKAGE = $(NAME)
|
|
||||||
BINARY = $(NAME)
|
|
||||||
VERSION = 3.1
|
|
||||||
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
|
|
||||||
|
|
||||||
DESTDIR = /usr
|
|
||||||
OSXDIR = /usr/local
|
|
||||||
SBINDIR = $(DESTDIR)/sbin
|
|
||||||
DOCDIR = $(DESTDIR)/share/doc/$(PACKAGE)
|
|
||||||
MANPAGE = gophernicus.1
|
|
||||||
MANDEST = $(DESTDIR)/share/man/man1/gophernicus.1
|
|
||||||
|
|
||||||
INSTALL = PATH=$$PATH:/usr/sbin ./install-sh -o 0 -g 0
|
|
||||||
ROOT = /var/gopher
|
|
||||||
OSXROOT = /Library/GopherServer
|
|
||||||
WRTROOT = /gopher
|
|
||||||
MAP = gophermap
|
|
||||||
|
|
||||||
INETD = /etc/inetd.conf
|
|
||||||
XINETD = /etc/xinetd.d
|
|
||||||
# get OPTIONS line from gophernicus.env and use that also for inetd
|
|
||||||
INETOPT = $$(grep '^OPTIONS=' $(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//')
|
|
||||||
INETLIN = "gopher stream tcp nowait nobody $(SBINDIR)/$(BINARY) $(BINARY) $(INETOPT)"
|
|
||||||
INETPID = /var/run/inetd.pid
|
|
||||||
LAUNCHD = /Library/LaunchDaemons
|
|
||||||
PLIST = org.$(NAME).server.plist
|
|
||||||
NET_SRV = /boot/common/settings/network/services
|
|
||||||
SYSTEMD = /lib/systemd/system /usr/lib/systemd/system
|
|
||||||
HAS_STD = /run/systemd/system
|
|
||||||
SYSCONF = /etc/sysconfig
|
|
||||||
DEFAULT = /etc/default
|
|
||||||
|
|
||||||
CC ?= cc
|
|
||||||
CFLAGS := -O2 -Wall $(CFLAGS)
|
|
||||||
LDFLAGS := $(LDFLAGS)
|
|
||||||
|
|
||||||
IPCRM = /usr/bin/ipcrm
|
|
||||||
|
|
||||||
all:
|
|
||||||
@case $$(uname) in \
|
|
||||||
Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDIr)" src/$(BINARY); ;; \
|
|
||||||
Haiku) $(MAKE) LDFLAGS="$(LDFLAGS) -lnetwork" src/$(BINARY); ;; \
|
|
||||||
*) if [ -f "/usr/include/tcpd.h" ]; then $(MAKE) withwrap; else $(MAKE) src/$(BINARY); fi; ;; \
|
|
||||||
esac
|
|
||||||
|
|
||||||
withwrap:
|
|
||||||
$(MAKE) CFLAGS="$(CFLAGS) -DHAVE_LIBWRAP" LDFLAGS="$(LDFLAGS) -lwrap" src/$(BINARY)
|
|
||||||
|
|
||||||
deb:
|
|
||||||
dpkg-buildpackage -rfakeroot -uc -us
|
|
||||||
|
|
||||||
headers: $(HEADERS)
|
|
||||||
|
|
||||||
src/$(NAME).c: headers 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
|
|
||||||
$(CC) src/bin2c.c -o $@
|
|
||||||
|
|
||||||
README: $(README)
|
|
||||||
cat $(README) > $@
|
|
||||||
|
|
||||||
src/files.h: src/bin2c README
|
|
||||||
sed -e '/^(end of option list)/,$$d' README > README.options
|
|
||||||
./src/bin2c -0 -n README README.options > $@
|
|
||||||
./src/bin2c -0 LICENSE >> $@
|
|
||||||
./src/bin2c -n ERROR_GIF error.gif >> $@
|
|
||||||
@echo
|
|
||||||
|
|
||||||
# Clean cases
|
|
||||||
|
|
||||||
clean: clean-build clean-deb
|
|
||||||
|
|
||||||
clean-build:
|
|
||||||
rm -rf src/$(BINARY) $(OBJECTS) $(HEADERS) README.options README src/bin2c
|
|
||||||
|
|
||||||
clean-deb:
|
|
||||||
if [ -d debian/$(PACKAGE) ]; then fakeroot debian/rules clean; fi
|
|
||||||
|
|
||||||
clean-shm:
|
|
||||||
if [ -x $(IPCRM) ]; then $(IPCRM) -M $$(awk '/SHM_KEY/ { print $$3 }' src/$(NAME).h) || true; fi
|
|
||||||
|
|
||||||
# Install cases
|
|
||||||
|
|
||||||
install: clean-shm
|
|
||||||
@case $$(uname) in \
|
|
||||||
Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDIR)" install-files install-docs install-root install-osx install-done; ;; \
|
|
||||||
Haiku) $(MAKE) SBINDIR=/boot/common/bin DOCDIR=/boot/common/share/doc/$(PACKAGE) \
|
|
||||||
install-files install-docs install-root install-haiku install-done; ;; \
|
|
||||||
*) $(MAKE) install-files install-docs install-root; ;; \
|
|
||||||
esac
|
|
||||||
@if [ -d "$(HAS_STD)" ]; then $(MAKE) install-systemd install-done; \
|
|
||||||
elif [ -d "$(XINETD)" ]; then $(MAKE) install-xinetd install-done; \
|
|
||||||
elif [ -f "$(INETD)" ]; then $(MAKE) install-inetd install-done; fi
|
|
||||||
|
|
||||||
.PHONY: install
|
|
||||||
|
|
||||||
install-done:
|
|
||||||
@echo
|
|
||||||
@echo "======================================================================"
|
|
||||||
@echo
|
|
||||||
@echo "If there were no errors shown above,"
|
|
||||||
@echo "Gophernicus has now been succesfully installed. To try it out, launch"
|
|
||||||
@echo "your favorite gopher browser and navigate to your gopher root."
|
|
||||||
@echo
|
|
||||||
@echo "Gopher URL...: gopher://$$(hostname)/"
|
|
||||||
@for CONFFILE in /etc/sysconfig/gophernicus \
|
|
||||||
/etc/default/gophernicus \
|
|
||||||
/Library/LaunchDaemons/org.gophernicus.server.plist \
|
|
||||||
/boot/common/settings/network/services \
|
|
||||||
/lib/systemd/system/gophernicus\@.service \
|
|
||||||
/etc/xinetd.d/gophernicus \
|
|
||||||
/etc/inetd.conf; do \
|
|
||||||
if [ -f $$CONFFILE ]; then echo "Configuration: $$CONFFILE"; break; fi; done;
|
|
||||||
@echo
|
|
||||||
@echo "======================================================================"
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-files: src/$(BINARY)
|
|
||||||
mkdir -p $(SBINDIR)
|
|
||||||
$(INSTALL) -s -m 755 src/$(BINARY) $(SBINDIR)
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-docs:
|
|
||||||
mkdir -p $(DOCDIR)
|
|
||||||
$(INSTALL) -m 644 $(MANPAGE) $(MANDEST)
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-root:
|
|
||||||
if [ ! -d "$(ROOT)" -o ! -f "$(ROOT)/$(MAP)" ]; then \
|
|
||||||
mkdir -p $(ROOT); \
|
|
||||||
$(INSTALL) -m 644 $(MAP).sample $(ROOT); \
|
|
||||||
ln -fs $(DOCDIR) $(ROOT)/docs; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-inetd: install-files install-docs install-root
|
|
||||||
@if update-inetd --add $(INETLIN); then \
|
|
||||||
echo update-inetd install worked ; \
|
|
||||||
else if grep '^gopher' $(INETD) >/dev/null 2>&1 ; then \
|
|
||||||
echo "::::: Gopher entry in $(INETD) already present -- please check! :::::"; \
|
|
||||||
else echo "Trying to add gopher entry to $(INETD)" ; \
|
|
||||||
echo "$(INETLIN)" >> $(INETD) ; \
|
|
||||||
if [ -r $(INETPID) ] ; then kill -HUP $$(cat $(INETPID)) ; \
|
|
||||||
else echo "::::: No PID for inetd found, not restarted -- please check! :::::" ; fi ; \
|
|
||||||
fi ; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-xinetd: install-files install-docs install-root
|
|
||||||
if [ -d "$(XINETD)" -a ! -f "$(XINETD)/$(NAME)" ]; then \
|
|
||||||
sed -e "s/@HOSTNAME@/$$(hostname)/g" $(NAME).xinetd > $(XINETD)/$(NAME); \
|
|
||||||
[ -x /sbin/service ] && /sbin/service xinetd reload; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-osx:
|
|
||||||
if [ -d "$(LAUNCHD)" -a ! -f "$(LAUNCHD)/$(PLIST)" ]; then \
|
|
||||||
sed -e "s/@HOSTNAME@/$$(hostname)/g" src/$(PLIST) > $(LAUNCHD)/$(PLIST); \
|
|
||||||
launchctl load $(LAUNCHD)/$(PLIST); \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
chown -h root:admin $(ROOT) $(ROOT)/*
|
|
||||||
chmod -h 0775 $(ROOT) $(ROOT)/docs
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-haiku:
|
|
||||||
if [ -f "$(NET_SRV)" -a ! "$$(grep -m1 gopher $(NET_SRV))" ]; then \
|
|
||||||
(echo ""; \
|
|
||||||
echo "service gopher {"; \
|
|
||||||
echo " family inet"; \
|
|
||||||
echo " protocol tcp"; \
|
|
||||||
echo " port 70"; \
|
|
||||||
echo " launch $(BINARY) -h $$(hostname)"; \
|
|
||||||
echo "}") >> $(NET_SRV); \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
chown user:root $(DOCDIR)/* $(SBINDIR)/$(BINARY) $(ROOT)/$(MAP)
|
|
||||||
@echo
|
|
||||||
ps | grep net_server | grep -v grep | awk '{ print $$2 }' | xargs kill
|
|
||||||
nohup /boot/system/servers/net_server >/dev/null 2>/dev/null &
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install-systemd: install-files install-docs install-root
|
|
||||||
if [ -d "$(HAS_STD)" ]; then \
|
|
||||||
if [ -d "$(SYSCONF)" -a ! -f "$(SYSCONF)/$(NAME)" ]; then \
|
|
||||||
$(INSTALL) -m 644 init/$(NAME).env $(SYSCONF)/$(NAME); \
|
|
||||||
fi; \
|
|
||||||
if [ ! -d "$(SYSCONF)" -a -d "$(DEFAULT)" -a ! -f $(DEFAULT)/$(NAME) ]; then \
|
|
||||||
$(INSTALL) -m 644 init/$(NAME).env $(DEFAULT)/$(NAME); \
|
|
||||||
fi; \
|
|
||||||
for DIR in $(SYSTEMD); do \
|
|
||||||
if [ -d "$$DIR" ]; then \
|
|
||||||
$(INSTALL) -m 644 init/$(NAME).socket init/$(NAME)\@.service $$DIR; \
|
|
||||||
break; \
|
|
||||||
fi; \
|
|
||||||
done; \
|
|
||||||
if pidof systemd ; then \
|
|
||||||
systemctl daemon-reload; \
|
|
||||||
systemctl enable $(NAME).socket; \
|
|
||||||
systemctl start $(NAME).socket; \
|
|
||||||
fi; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
# Uninstall cases
|
|
||||||
uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd uninstall-inetd
|
|
||||||
rm -f $(SBINDIR)/$(BINARY)
|
|
||||||
for DOC in $(DOCS); do rm -f $(DOCDIR)/$$DOC; done
|
|
||||||
rmdir -p $(SBINDIR) $(DOCDIR) 2>/dev/null || true
|
|
||||||
rm -rf $(MANDEST)
|
|
||||||
@echo
|
|
||||||
|
|
||||||
uninstall-inetd:
|
|
||||||
@if [ -f "$(INETD)" ] && update-inetd --remove "^gopher.*gophernicus" ; then \
|
|
||||||
echo update-inetd remove worked ; \
|
|
||||||
else if grep '^gopher' $(INETD) >/dev/null 2>&1 && \
|
|
||||||
sed -i .bak -e 's/^gopher/#gopher/' $(INETD) ; then \
|
|
||||||
echo "commented out gopher entry in $(INETD), reloading inetd" ; \
|
|
||||||
[ -r $(INETPID) ] && kill -HUP $$(cat $(INETPID)) ; \
|
|
||||||
else echo "::::: could not find gopher entry in $(INETD) :::::" ; \
|
|
||||||
fi ; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
uninstall-xinetd:
|
|
||||||
if grep -q $(BINARY) "$(XINETD)/gopher" 2>/dev/null; then \
|
|
||||||
rm -f $(XINETD)/gopher; \
|
|
||||||
[ -x /sbin/service ] && service xinetd reload; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
uninstall-launchd:
|
|
||||||
if [ -f $(LAUNCHD)/$(PLIST) ]; then \
|
|
||||||
launchctl unload $(LAUNCHD)/$(PLIST); \
|
|
||||||
rm -f $(LAUNCHD)/$(PLIST); \
|
|
||||||
fi
|
|
||||||
if [ -L $(ROOT) ]; then \
|
|
||||||
rm -f $(ROOT); \
|
|
||||||
fi
|
|
||||||
@echo
|
|
||||||
|
|
||||||
uninstall-systemd:
|
|
||||||
if [ -d "$(HAS_STD)" ]; then \
|
|
||||||
for DIR in $(SYSTEMD); do \
|
|
||||||
if [ -f "$$DIR/$(NAME).socket" ]; then \
|
|
||||||
systemctl stop $(NAME).socket; \
|
|
||||||
systemctl disable $(NAME).socket; \
|
|
||||||
rm -f $$DIR/$(NAME).socket $$DIR/$(NAME)\@.service $(SYSCONF)/$(NAME) $(DEFAULT)/$(NAME); \
|
|
||||||
systemctl daemon-reload; \
|
|
||||||
break; \
|
|
||||||
fi; \
|
|
||||||
done; \
|
|
||||||
fi
|
|
||||||
@echo
|
|
149
Makefile.in
Normal file
149
Makefile.in
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
NAME = gophernicus
|
||||||
|
PACKAGE = $(NAME)
|
||||||
|
BINARY = $(NAME)
|
||||||
|
VERSION = 3.1
|
||||||
|
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
|
||||||
|
MANPAGE = $(DESTDIR)gophernicus.1
|
||||||
|
|
||||||
|
DESTDIR ?= /
|
||||||
|
PREFIX = @PREFIX@
|
||||||
|
BINDIR = @BINDIR@
|
||||||
|
SBINDIR = @SBINDIR@
|
||||||
|
MANDIR = @MANDIR@
|
||||||
|
MAN1DIR = @MAN1DIR@
|
||||||
|
|
||||||
|
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
|
||||||
|
INETOPT = $$(grep '^OPTIONS=' $(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//')
|
||||||
|
LAUNCHD = @LAUNCHD@
|
||||||
|
PLIST = org.$(NAME).server.plist
|
||||||
|
HAIKU_SRV = @HAIKUSRV@
|
||||||
|
DEFAULT = @DEFAULT@
|
||||||
|
SYSCONF = @SYSCONF@
|
||||||
|
HOSTNAME = @HOSTNAME@
|
||||||
|
|
||||||
|
CC ?= @CC@
|
||||||
|
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
|
||||||
|
$(CC) src/bin2c.c -o $@
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@ install-done
|
||||||
|
$(INSTALL) -s -m 755 src/$(BINARY) $(DESTDIR)$(SBINDIR)
|
||||||
|
.PHONY: install
|
||||||
|
|
||||||
|
install-done:
|
||||||
|
@echo
|
||||||
|
@echo "======================================================================"
|
||||||
|
@echo
|
||||||
|
@echo "If there were no errors shown above,"
|
||||||
|
@echo "Gophernicus has now been succesfully installed. To try it out, launch"
|
||||||
|
@echo "your favorite gopher browser and navigate to your gopher root."
|
||||||
|
@echo
|
||||||
|
@echo "Gopher URL...: gopher://$$(hostname)/"
|
||||||
|
@echo
|
||||||
|
@echo "======================================================================"
|
||||||
|
@echo
|
||||||
|
|
||||||
|
install-man:
|
||||||
|
$(INSTALL) -m 644 $(MANPAGE) $(DESTDIR)$(MANDEST)
|
||||||
|
|
||||||
|
install-root:
|
||||||
|
$(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT)
|
||||||
|
|
||||||
|
install-inetd-update: install-root
|
||||||
|
update-inetd --add $$(sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in)
|
||||||
|
|
||||||
|
install-inetd-manual: install-root
|
||||||
|
sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in > $(DESTDIR)$(INETD)
|
||||||
|
|
||||||
|
install-xinetd: install-root
|
||||||
|
sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(NAME).xinetd.in > $(DESTDIR)$(XINETD)/$(NAME)
|
||||||
|
|
||||||
|
install-osx: install-root
|
||||||
|
sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(PLIST).in > $(DESTDIR)$(LAUNCHD)/$(PLIST)
|
||||||
|
chown -h root:admin $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/*
|
||||||
|
chmod -h 0775 $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/docs
|
||||||
|
|
||||||
|
install-haiku: install-root
|
||||||
|
sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV)
|
||||||
|
chown user:root $(DESTDIR)$(DOCDIR)/* $(DESTDIR)$(SBINDIR)/$(BINARY) $(DESTDIR)$(ROOT)/$(MAP)
|
||||||
|
|
||||||
|
install-systemd: install-root
|
||||||
|
$(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(SYSCONF)/$(NAME)
|
||||||
|
$(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(DEFAULT)/$(NAME)
|
||||||
|
|
||||||
|
uninstall: @UNINSTALL_INETD_UPDATE@ @UNINSTALL_INETD_MANUAL@ @UNINSTALL_XINETD@ @UNINSTALL_OSX@ @UNINSTALL_SYSTEMD@
|
||||||
|
rm -f $(DESTDIR)$(SBINDIR)/$(BINARY)
|
||||||
|
rm -f $(DESTDIR)$(MANDEST)/$(MANPAGE)
|
||||||
|
|
||||||
|
uninstall-inetd-update:
|
||||||
|
update-inetd --remove "^gopher.*gophernicus"
|
||||||
|
|
||||||
|
uninstall-inetd-manual:
|
||||||
|
sed -i '/^gopher/d' $(DESTDIR)$(INETD)
|
||||||
|
|
||||||
|
uninstall-xinetd:
|
||||||
|
rm -f $(DESTDIR)$(XINETD)/gopher
|
||||||
|
|
||||||
|
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)$(SYSCONF)/$(NAME)/$(NAME).socket
|
||||||
|
rm -f $(DESTDIR)$(SYSCONF)/$(NAME)/$(NAME)\@.service
|
||||||
|
rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME).env
|
||||||
|
rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME).socket
|
||||||
|
rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME)\@.service
|
310
configure
vendored
Executable file
310
configure
vendored
Executable file
@ -0,0 +1,310 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Is similar to an autoconf configure script, but is written by hand
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "Usage: %s [options]\\n\\n" "$0"
|
||||||
|
printf " --prefix=/usr/local Prefix for all files\\n"
|
||||||
|
printf " --bindir=PREFIX/bin Prefix for binaries\\n"
|
||||||
|
printf " --sbindir=PREFIX/sbin Prefix for system binaries\\n"
|
||||||
|
printf " --mandir=PREFIX/share/man Prefix for manpages\\n"
|
||||||
|
printf " --man1dir=MANDIR/man1 Prefix for section 1 manpages\\n"
|
||||||
|
printf " --gopherroot=/var/gopher Path to gopher root\\n"
|
||||||
|
printf " --sysconfig=/etc/sysconfig Path to sysconfig directory\\n\\n"
|
||||||
|
printf " --default=/etc/default Path to 'default' configuration directory\\n\\n"
|
||||||
|
printf " --launchd=/Library/LaunchDaemons Path to launchd for MacOS\\n"
|
||||||
|
printf " --haikusrv=/boot/common/settings/network/services Path to services directory in Haiku\\n\\n"
|
||||||
|
printf " --os=autodetected Your target OS, one of linux, mac, haiku, netbsd, openbsd or freebsd\\n"
|
||||||
|
printf " --listener=autodetected Program to recieve and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n"
|
||||||
|
printf " --hostname=autodetected Desired hostname for gophernicus to identify as\\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set values for each option
|
||||||
|
while [ "$#" -gt 0 ] ; do
|
||||||
|
opt="${1%%=*}"
|
||||||
|
opt="${opt##--}"
|
||||||
|
value="${1##*=}"
|
||||||
|
case "${opt}" in
|
||||||
|
prefix) PREFIX="${value}"; shift ;;
|
||||||
|
bindir) BINDIR="${value}"; shift ;;
|
||||||
|
sbindir) SBINDIR="${value}"; shift ;;
|
||||||
|
docdir) DOCDIR="${value}"; shift ;;
|
||||||
|
mandir) MANDIR="${value}"; shift ;;
|
||||||
|
man1dir) MAN1DIR="${value}"; shift ;;
|
||||||
|
gopherroot) GOPHERROOT="${value}"; shift ;;
|
||||||
|
sysconfig) SYSCONFIG="${value}"; shift ;;
|
||||||
|
default) DEFAULTCONF="${value}"; shift ;;
|
||||||
|
os) OS="${value}"; shift ;;
|
||||||
|
launchd) LAUNCHD="${value}"; shift ;;
|
||||||
|
haikusrv) HAIKUSRV="${value}"; shift ;;
|
||||||
|
listener) LISTENER="${value}"; shift ;;
|
||||||
|
hostname) HOSTNAME="${value}"; shift ;;
|
||||||
|
help) usage; exit 0 ;;
|
||||||
|
*) usage; exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Set default values
|
||||||
|
: ${PREFIX:=/usr/local}
|
||||||
|
: ${BINDIR:=${PREFIX}/bin}
|
||||||
|
: ${SBINDIR:=${PREFIX}/sbin}
|
||||||
|
: ${DOCDIR:=${PREFIX}/share/doc}
|
||||||
|
: ${MANDIR:=${PREFIX}/share/man}
|
||||||
|
: ${MAN1DIR:=${MANDIR}/man1}
|
||||||
|
: ${GOPHERROOT:=/var/gopher}
|
||||||
|
: ${SYSCONFIG:=/etc/sysconfig}
|
||||||
|
: ${DEFAULTCONF:=/etc/default}
|
||||||
|
: ${LAUNCHD:=/Library/LaunchDaemons}
|
||||||
|
: ${HAIKUSRV:=/boot/common/settings/network/services}
|
||||||
|
: ${CC:=cc}
|
||||||
|
: ${CFLAGS:=-O2}
|
||||||
|
: ${HOSTNAME:=autodetect}
|
||||||
|
|
||||||
|
# Check for a compiler that actually works
|
||||||
|
printf "checking for working compiler... "
|
||||||
|
cat > conftest.c <<EOF
|
||||||
|
#include <stdlib.h>
|
||||||
|
int main() { return 0; }
|
||||||
|
EOF
|
||||||
|
if ! ${CC} -o conftest conftest.c; then
|
||||||
|
printf "no\\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "${CC}\\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Autodetect the OS
|
||||||
|
if ! [ "${OS:=1}" ]; then
|
||||||
|
# If it can't find uname, it needs to be manually specified
|
||||||
|
printf "checking for uname... "
|
||||||
|
if ! UNAME="$(command -v uname)"; then
|
||||||
|
printf "please provide OS in options\\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "%s\\n" "${UNAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it can, it presses on
|
||||||
|
printf "checking for OS... "
|
||||||
|
case "$(${UNAME})" in
|
||||||
|
Linux) OS=linux ;;
|
||||||
|
Haiku) OS=haiku
|
||||||
|
INSTALL_HAIKU="install-haiku" ;;
|
||||||
|
Darwin) OS=mac
|
||||||
|
INSTALL_OSX="install-osx" ;;
|
||||||
|
NetBSD) OS=netbsd ;;
|
||||||
|
OpenBSD) OS=openbsd ;;
|
||||||
|
FreeBSD) OS=freebsd ;;
|
||||||
|
*) printf "unknown, pressing on anyway\\n" ;;
|
||||||
|
esac
|
||||||
|
printf "%s\\n" "${OS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checks for an install command and falls back to install-sh
|
||||||
|
printf "checking for install... "
|
||||||
|
if ! INSTALL="$(command -v install)"; then
|
||||||
|
printf "install-sh"
|
||||||
|
INSTALL=build-aux/install-sh
|
||||||
|
else
|
||||||
|
printf "%s" "${INSTALL}"
|
||||||
|
fi
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
# Check for listener validity and autodetect if required
|
||||||
|
# Checks that take place:
|
||||||
|
# mac OS = mac listener (both ways)
|
||||||
|
# haiku OS = haiku listener (both ways)
|
||||||
|
# systemd listener = linux OS
|
||||||
|
printf "checking for listener... "
|
||||||
|
if [ -z "${LISTENER}" ]; then
|
||||||
|
printf "not given\\n"
|
||||||
|
exit 1
|
||||||
|
elif [ "${LISTENER}" = "mac" ] && [ "${OS}" != "mac" ]; then
|
||||||
|
printf "mac listener only valid with macos\\n"
|
||||||
|
exit 1
|
||||||
|
elif [ "${LISTENER}" = "haiku" ] && [ "${OS}" != "haiku" ]; then
|
||||||
|
printf "haiku listener only valid with haiku\\n"
|
||||||
|
exit 1
|
||||||
|
elif [ "${LISTENER}" = "systemd" ] && [ "${OS}" != "linux" ]; then
|
||||||
|
printf "systemd listener only valid with linux\\n"
|
||||||
|
exit 1
|
||||||
|
elif [ "${LISTENER}" = "autodetect" ]; then
|
||||||
|
# OS-specific listeners
|
||||||
|
case "${OS}" in
|
||||||
|
mac)
|
||||||
|
LISTENER=mac
|
||||||
|
printf "mac\\n"
|
||||||
|
break ;;
|
||||||
|
haiku)
|
||||||
|
LISTENER=haiku
|
||||||
|
printf "haiku\\n"
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -d "/lib/systemd/system" ] ; then
|
||||||
|
LISTENER=systemd
|
||||||
|
printf "systemd\\n"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "checking for inetd... "
|
||||||
|
if command -v update-inetd; then
|
||||||
|
LISTENER=inetd
|
||||||
|
printf "inetd\\n"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "checking for xinetd... "
|
||||||
|
if XINETD="$(command -v xinetd)"; then
|
||||||
|
LISTENER=xinetd
|
||||||
|
printf "xinetd\\n"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure we detected something
|
||||||
|
if [ "${LISTENER}" = "autodetect" ]; then
|
||||||
|
printf "unable to autodetect, please manually specify\\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [ "${OS}" = "haiku" ] && [ "${LISTENER}" != "haiku" ]; then
|
||||||
|
printf "only haiku listener supported on haiku\\n"
|
||||||
|
exit 1
|
||||||
|
elif [ "${OS}" = "mac" ] && [ "${LISTENER}" != "mac" ]; then
|
||||||
|
printf "only mac listener supported on mac\\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "%s\\n" "${LISTENER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Act accordingly based on whichever listener we are given
|
||||||
|
case "${LISTENER}" in
|
||||||
|
systemd)
|
||||||
|
INSTALL_SYSTEMD="install-systemd"
|
||||||
|
UNINSTALL_SYSTEMD="uninstall-systemd" ;;
|
||||||
|
xinetd)
|
||||||
|
INSTALL_XINETD="install-xinetd"
|
||||||
|
UNINSTALL_XINETD="uninstall-xinetd"
|
||||||
|
XINETD_CONF="/etc/xinetd.d/gophernicus" ;;
|
||||||
|
inetd)
|
||||||
|
INSTALL_INETD="install-inetd"
|
||||||
|
INETD_CONF="/etc/inetd.conf"
|
||||||
|
printf "checking for update-inetd... "
|
||||||
|
if ! UPDATE_INETD="$(command -v update-inetd)"; then
|
||||||
|
printf "not found\\n"
|
||||||
|
INSTALL_INETD_MANUAL="install-inetd-manual"
|
||||||
|
UNINSTALL_INETD_UPDATE="uninstall-inetd-update"
|
||||||
|
else
|
||||||
|
printf "%s\\n" "${UPDATE_INETD}"
|
||||||
|
INSTALL_INETD_UPDATE="install-inetd-update"
|
||||||
|
UNINSTALL_INETD_UPDATE="uninstall-inetd-update"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
mac) INSTALL_OSX="install-osx" UNINSTALL_OSX="uninstall-osx" ;;
|
||||||
|
haiku) INSTALL_HAIKU="install-haiku" UNINSTALL_HAIKU="uninstall-haiku" ;;
|
||||||
|
*) printf "The listener %s is not offically supported; continuing anyway.\\n" "${LISTENER}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Try to detect hostname
|
||||||
|
printf "getting hostname... "
|
||||||
|
if [ "${HOSTNAME}" = "autodetect" ]; then
|
||||||
|
HOSTNAME="$(hostname)"
|
||||||
|
# If no hostname then we couldn't autodetect
|
||||||
|
if [ $? != 0 ] || [ -z "${HOSTNAME}" ]; then
|
||||||
|
printf "unable to detect hostname\\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
printf "%s\\n" "${HOSTNAME}"
|
||||||
|
|
||||||
|
# Use libwrap when it is avaliable
|
||||||
|
printf "checking for libwrap... "
|
||||||
|
cat > conftest.c <<EOF
|
||||||
|
#include <tcpd.h>
|
||||||
|
int main() {}
|
||||||
|
EOF
|
||||||
|
if ${CC} -o conftest -lwrap conftest.c 2>/dev/null; then
|
||||||
|
LIBWRAP="-DHAVE_LIBWRAP"
|
||||||
|
printf "yes"
|
||||||
|
else
|
||||||
|
LIBWRAP=
|
||||||
|
printf "no, but program will still work"
|
||||||
|
fi
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
# Check and use SHM if avaliable
|
||||||
|
printf "checking for ipcrm (SHM management)... "
|
||||||
|
if ! IPCRM="$(command -v ipcrm)"; then
|
||||||
|
printf "not found"
|
||||||
|
else
|
||||||
|
printf "%s" "${IPCRM}"
|
||||||
|
CLEAN_SHM="clean-shm"
|
||||||
|
fi
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
# Trying to autodetect make
|
||||||
|
printf "checking for make... "
|
||||||
|
if ! MAKE="$(command -v make)"; then
|
||||||
|
printf "not found, please pass MAKE=/path/to/make to make invocation"
|
||||||
|
MAKE="make"
|
||||||
|
else
|
||||||
|
printf "%s" "${MAKE}"
|
||||||
|
fi
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
# Don't replace an existing root
|
||||||
|
printf "checking for existing gopher root... "
|
||||||
|
if [ -d "${GOPHERROOT}" ] || [ -f "${GOPHERROOT}/gophermap" ]; then
|
||||||
|
INSTALL_ROOT="install-root"
|
||||||
|
printf "yes"
|
||||||
|
else
|
||||||
|
printf "no"
|
||||||
|
fi
|
||||||
|
printf "\\n"
|
||||||
|
|
||||||
|
# Sub in values
|
||||||
|
cp Makefile.in Makefile
|
||||||
|
|
||||||
|
printf "creating Makefile... "
|
||||||
|
sed -i "s:@CC@:${CC}:" Makefile
|
||||||
|
sed -i "s:@LIBWRAP@:${LIBWRAP}:" Makefile
|
||||||
|
sed -i "s:@INSTALL@:${INSTALL}:" Makefile
|
||||||
|
sed -i "s:@MAKE@:${MAKE}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@PREFIX@:${PREFIX}:" Makefile
|
||||||
|
sed -i "s:@BINDIR@:${BINDIR}:" Makefile
|
||||||
|
sed -i "s:@SBINDIR@:${SBINDIR}:" Makefile
|
||||||
|
sed -i "s:@DOCDIR@:${DOCDIR}:" Makefile
|
||||||
|
sed -i "s:@MANDIR@:${MANDIR}:" Makefile
|
||||||
|
sed -i "s:@MAN1DIR@:${MAN1DIR}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@IPCRM@:${IPCRM}:" Makefile
|
||||||
|
sed -i "s:@CLEAN_SHM@:${CLEAN_SHM}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@SYSCONF@:${SYSCONFIG}:" Makefile
|
||||||
|
sed -i "s:@DEFAULT@:${DEFAULTCONF}:" Makefile
|
||||||
|
sed -i "s:@HOSTNAME@:${HOSTNAME}:" Makefile
|
||||||
|
sed -i "s:@ROOT@:${GOPHERROOT}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@HAIKUSRV@:${HAIKUSRV}:" Makefile
|
||||||
|
sed -i "s:@LAUNCHD@:${LAUNCHD}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_ROOT@:${INSTALL_ROOT}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@INSTALL_OSX@:${INSTALL_OSX}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_INETD_MANUAL@:${INSTALL_INETD_MANUAL}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_INETD_UPDATE@:${INSTALL_INETD_UPDATE}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_XINETD@:${INSTALL_XINETD}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_SYSTEMD@:${INSTALL_SYSTEMD}:" Makefile
|
||||||
|
sed -i "s:@INSTALL_HAIKU@:${INSTALL_HAIKU}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_OSX@:${UNINSTALL_OSX}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_INETD_MANUAL@:${UNINSTALL_INETD_MANUAL}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_INETD_UPDATE@:${UNINSTALL_INETD_UPDATE}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_XINETD@:${UNINSTALL_XINETD}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_SYSTEMD@:${UNINSTALL_SYSTEMD}:" Makefile
|
||||||
|
sed -i "s:@UNINSTALL_HAIKU@:${UNINSTALL_HAIKU}:" Makefile
|
||||||
|
|
||||||
|
sed -i "s:@INETD_CONF@:${INETD_CONF}:" Makefile
|
||||||
|
sed -i "s:@XINETD_CONF@:${XINETD_CONF}:" Makefile
|
||||||
|
printf "done\\n"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -f conftest conftest.c
|
4
init/.gitignore
vendored
Normal file
4
init/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
haiku_snippet
|
||||||
|
org.gophernicus.server.plist
|
||||||
|
gophernicus.xinetd
|
||||||
|
inetlin
|
7
init/haiku_snippet.in
Normal file
7
init/haiku_snippet.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
service gopher {
|
||||||
|
family inet
|
||||||
|
protocol tcp
|
||||||
|
port 70
|
||||||
|
launch @BINARY@ -h @HOSTNAME@
|
||||||
|
}
|
1
init/inetlin.in
Normal file
1
init/inetlin.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
gopher stream tcp nowait @BINARY_PATH@ @BINARY_NAME@ @OPTIONS@
|
Loading…
Reference in New Issue
Block a user