1
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2024-11-03 04:27:17 -05:00

refactor: New hierarchy and refactored Makefile

This commit is contained in:
Emil Engler 2020-01-11 20:41:11 +01:00
parent af170fcb5c
commit 8949d78794
No known key found for this signature in database
GPG Key ID: 2F6D4145C55FC7C7
16 changed files with 39 additions and 64 deletions

101
Makefile
View File

@ -1,31 +1,24 @@
## NAME = gophernicus
## Gophernicus server Makefile PACKAGE = $(NAME)
## BINARY = $(NAME)
VERSION = 3.1
#
# Variables and default configuration
#
NAME = gophernicus
PACKAGE = $(NAME)
BINARY = $(NAME)
VERSION = 3.1
CODENAME = Dungeon Edition CODENAME = Dungeon Edition
SOURCES = $(NAME).c file.c menu.c string.c platform.c session.c options.c SOURCES = src/$(NAME).c src/file.c src/menu.c src/string.c src/platform.c src/session.c src/options.c
HEADERS = functions.h files.h HEADERS = src/functions.h src/files.h
OBJECTS = $(SOURCES:.c=.o) OBJECTS = $(SOURCES:.c=.o)
README = README.md README = README.md
DOCS = LICENSE README.md INSTALL.md changelog README.Gophermap gophertag DOCS = LICENSE README.md INSTALL.md changelog README.Gophermap gophertag
INSTALL = PATH=$$PATH:/usr/sbin ./install-sh -o 0 -g 0
DESTDIR = /usr DESTDIR = /usr
OSXDEST = /usr/local OSXDIR = /usr/local
SBINDIR = $(DESTDIR)/sbin SBINDIR = $(DESTDIR)/sbin
DOCDIR = $(DESTDIR)/share/doc/$(PACKAGE) DOCDIR = $(DESTDIR)/share/doc/$(PACKAGE)
MANPAGE = gophernicus.1.man MANPAGE = gophernicus.1.man
MANDEST = $(DESTDIR)/share/man/man1/gophernicus.1 MANDEST = $(DESTDIR)/share/man/man1/gophernicus.1
ROOT = /var/gopher INSTALL = PATH=$$PATH:/usr/sbin ./install-sh -o 0 -g 0
ROOT = /var/gopher
OSXROOT = /Library/GopherServer OSXROOT = /Library/GopherServer
WRTROOT = /gopher WRTROOT = /gopher
MAP = gophermap MAP = gophermap
@ -48,42 +41,30 @@ LDFLAGS =
IPCRM = /usr/bin/ipcrm IPCRM = /usr/bin/ipcrm
#
# Platform support, compatible with both BSD and GNU make
#
all: all:
@case `uname` in \ @case `uname` in \
Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDEST)" $(BINARY); ;; \ Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDEST)" src/$(BINARY); ;; \
Haiku) $(MAKE) EXTRA_LIBS="-lnetwork" $(BINARY); ;; \ Haiku) $(MAKE) EXTRA_LIBS="-lnetwork" src/$(BINARY); ;; \
*) if [ -f "/usr/include/tcpd.h" ]; then $(MAKE) withwrap; else $(MAKE) $(BINARY); fi; ;; \ *) if [ -f "/usr/include/tcpd.h" ]; then $(MAKE) withwrap; else $(MAKE) src/$(BINARY); fi; ;; \
esac esac
withwrap: withwrap:
$(MAKE) EXTRA_CFLAGS="-DHAVE_LIBWRAP" EXTRA_LIBS="-lwrap" $(BINARY) $(MAKE) EXTRA_CFLAGS="-DHAVE_LIBWRAP" EXTRA_LIBS="-lwrap" src/$(BINARY)
#
# Special targets
#
deb: deb:
dpkg-buildpackage -rfakeroot -uc -us dpkg-buildpackage -rfakeroot -uc -us
#
# Building
#
headers: $(HEADERS) headers: $(HEADERS)
$(NAME).c: headers $(NAME).h src/$(NAME).c: headers src/$(NAME).h
$(BINARY): $(OBJECTS) src/$(BINARY): $(OBJECTS)
$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJECTS) $(EXTRA_LIBS) -o $@ $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJECTS) $(EXTRA_LIBS) -o $@
.c.o: .c.o:
$(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DVERSION="\"$(VERSION)\"" -DCODENAME="\"$(CODENAME)\"" -DDEFAULT_ROOT="\"$(ROOT)\"" $< -o $@ $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -DVERSION="\"$(VERSION)\"" -DCODENAME="\"$(CODENAME)\"" -DDEFAULT_ROOT="\"$(ROOT)\"" $< -o $@
src/functions.h:
functions.h:
echo "/* Automatically generated function definitions */" > $@ echo "/* Automatically generated function definitions */" > $@
echo >> $@ echo >> $@
grep -h "^[a-z]" $(SOURCES) | \ grep -h "^[a-z]" $(SOURCES) | \
@ -93,39 +74,34 @@ functions.h:
sed -e "s/ =.*$$//" -e "s/ *$$/;/" >> $@ sed -e "s/ =.*$$//" -e "s/ *$$/;/" >> $@
@echo @echo
bin2c: bin2c.c src/bin2c: src/bin2c.c
$(CC) bin2c.c -o $@ $(CC) src/bin2c.c -o $@
@echo
README: $(README) README: $(README)
cat $(README) > $@ cat $(README) > $@
files.h: bin2c README src/files.h: src/bin2c README
sed -e '/^(end of option list)/,$$d' README > README.options sed -e '/^(end of option list)/,$$d' README > README.options
./bin2c -0 -n README README.options > $@ ./src/bin2c -0 -n README README.options > $@
./bin2c -0 LICENSE >> $@ ./src/bin2c -0 LICENSE >> $@
./bin2c -n ERROR_GIF error.gif >> $@ ./src/bin2c -n ERROR_GIF error.gif >> $@
@echo @echo
# Clean cases
#
# Clean targets
#
clean: clean-build clean-deb clean: clean-build clean-deb
clean-build: clean-build:
rm -f $(BINARY) $(OBJECTS) $(HEADERS) README.options README bin2c rm -rf src/$(BINARY) $(OBJECTS) $(HEADERS) README.options README src/bin2c
clean-deb: clean-deb:
if [ -d debian/$(PACKAGE) ]; then fakeroot debian/rules clean; fi if [ -d debian/$(PACKAGE) ]; then fakeroot debian/rules clean; fi
clean-shm: clean-shm:
if [ -x $(IPCRM) ]; then $(IPCRM) -M `awk '/SHM_KEY/ { print $$3 }' $(NAME).h` || true; fi if [ -x $(IPCRM) ]; then $(IPCRM) -M `awk '/SHM_KEY/ { print $$3 }' src/$(NAME).h` || true; fi
# Install cases
#
# Install targets
#
install: clean-shm install: clean-shm
@case `uname` in \ @case `uname` in \
Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDEST)" install-files install-docs install-root install-osx install-done; ;; \ Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDEST)" install-files install-docs install-root install-osx install-done; ;; \
@ -160,9 +136,9 @@ install-done:
@echo "======================================================================" @echo "======================================================================"
@echo @echo
install-files: $(BINARY) install-files: src/$(BINARY)
mkdir -p $(SBINDIR) mkdir -p $(SBINDIR)
$(INSTALL) -s -m 755 $(BINARY) $(SBINDIR) $(INSTALL) -s -m 755 src/$(BINARY) $(SBINDIR)
@echo @echo
install-docs: install-docs:
@ -201,7 +177,7 @@ install-xinetd: install-files install-docs install-root
install-osx: install-osx:
if [ -d "$(LAUNCHD)" -a ! -f "$(LAUNCHD)/$(PLIST)" ]; then \ if [ -d "$(LAUNCHD)" -a ! -f "$(LAUNCHD)/$(PLIST)" ]; then \
sed -e "s/@HOSTNAME@/`hostname`/g" $(PLIST) > $(LAUNCHD)/$(PLIST); \ sed -e "s/@HOSTNAME@/`hostname`/g" src/$(PLIST) > $(LAUNCHD)/$(PLIST); \
launchctl load $(LAUNCHD)/$(PLIST); \ launchctl load $(LAUNCHD)/$(PLIST); \
fi fi
@echo @echo
@ -229,14 +205,14 @@ install-haiku:
install-systemd: install-files install-docs install-root install-systemd: install-files install-docs install-root
if [ -d "$(HAS_STD)" ]; then \ if [ -d "$(HAS_STD)" ]; then \
if [ -d "$(SYSCONF)" -a ! -f "$(SYSCONF)/$(NAME)" ]; then \ if [ -d "$(SYSCONF)" -a ! -f "$(SYSCONF)/$(NAME)" ]; then \
$(INSTALL) -m 644 $(NAME).env $(SYSCONF)/$(NAME); \ $(INSTALL) -m 644 init/$(NAME).env $(SYSCONF)/$(NAME); \
fi; \ fi; \
if [ ! -d "$(SYSCONF)" -a -d "$(DEFAULT)" -a ! -f $(DEFAULT)/$(NAME) ]; then \ if [ ! -d "$(SYSCONF)" -a -d "$(DEFAULT)" -a ! -f $(DEFAULT)/$(NAME) ]; then \
$(INSTALL) -m 644 $(NAME).env $(DEFAULT)/$(NAME); \ $(INSTALL) -m 644 init/$(NAME).env $(DEFAULT)/$(NAME); \
fi; \ fi; \
for DIR in $(SYSTEMD); do \ for DIR in $(SYSTEMD); do \
if [ -d "$$DIR" ]; then \ if [ -d "$$DIR" ]; then \
$(INSTALL) -m 644 $(NAME).socket $(NAME)\@.service $$DIR; \ $(INSTALL) -m 644 init/$(NAME).socket init/$(NAME)\@.service $$DIR; \
break; \ break; \
fi; \ fi; \
done; \ done; \
@ -248,13 +224,12 @@ install-systemd: install-files install-docs install-root
fi fi
@echo @echo
# # Uninstall cases
# Uninstall targets
#
uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd uninstall-inetd uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd uninstall-inetd
rm -f $(SBINDIR)/$(BINARY) rm -f $(SBINDIR)/$(BINARY)
for DOC in $(DOCS); do rm -f $(DOCDIR)/$$DOC; done for DOC in $(DOCS); do rm -f $(DOCDIR)/$$DOC; done
rmdir -p $(SBINDIR) $(DOCDIR) 2>/dev/null || true rmdir -p $(SBINDIR) $(DOCDIR) 2>/dev/null || true
rm -rf $(MANDEST)
@echo @echo
uninstall-inetd: uninstall-inetd:

2
debian/rules vendored
View File

@ -44,7 +44,7 @@ install: build
ln -s /usr/share/doc/gophernicus/ $(DEST)/var/gopher/docs ln -s /usr/share/doc/gophernicus/ $(DEST)/var/gopher/docs
ln -s /usr/bin/php5 $(DEST)/usr/lib/gophernicus/filters/php ln -s /usr/bin/php5 $(DEST)/usr/lib/gophernicus/filters/php
cp $(CURDIR)/gophermap.sample $(DEST)/usr/lib/gophernicus/gophermap cp $(CURDIR)/gophermap.sample $(DEST)/usr/lib/gophernicus/gophermap
cp $(CURDIR)/gophernicus.socket $(CURDIR)/gophernicus@.service $(DEST)/lib/systemd/system/ cp $(CURDIR)/init/gophernicus.socket $(CURDIR)/init/gophernicus@.service $(DEST)/lib/systemd/system/
# Build architecture-independent files here. # Build architecture-independent files here.
binary-indep: build install binary-indep: build install

View File

View File