bouquins-bchs/Makefile

158 lines
4.0 KiB
Makefile
Raw Normal View History

2016-12-18 15:50:32 +00:00
.SUFFIXES: .html .js .min.js
# The default installation is for a default-install OpenBSD box that's
# running HTTPS (only).
# File-system location (directory) of static media.
# See HTURI for the web-visible component.
2016-12-31 09:31:48 +00:00
HTDOCS = /usr/local/www/bouquins/
2016-12-18 15:50:32 +00:00
# URL location (path) of static media.
# See HTDOCS.
HTURI =
# File-system location (directory) of CGI script.
# See CGIURI.
2016-12-31 09:31:48 +00:00
CGIBIN = /usr/local/www/bouquins/cgi-bin
2016-12-18 15:50:32 +00:00
# File-system location of database.
# See RDDIR.
2016-12-31 09:31:48 +00:00
DATADIR = /usr/local/www/data
2016-12-18 15:50:32 +00:00
# Web-server relative location of system log file.
# This will have all logging messages by the system.
LOGFILE = /logs/system.log
# Compilation and link options.
# If on a static architecture, STATIC is -static; otherwise empty.
# I use /usr/local for kcgi and ksql, hence using them here.
STATIC = -static
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib
# Web-server relative location of DATADIR.
# See DATADIR.
RDDIR = /data
# Name of installed CGI script, since some servers like to have ".cgi"
# appended to everything.
# See TARGET.
CGINAME = bouquins
# URL location (filename) of CGI script.
# See CGIBIN and CGINAME.
CGIURI = /cgi-bin/$(CGINAME)
# This is the name of the binary we're going to build.
# It differs from CGINAME in that it's the install source.
# See CGINAME.
TARGET = bouquins
# If on an HTTPS-only installation, should be "-DSECURE".
SECURE = -DSECURE
# File-system location (directory) of Swagger API.
APIDOCS = /var/www/htdocs/api-docs
# Override these with an optional local file.
sinclude GNUmakefile.local
DATABASE = metadata.db
2017-01-08 15:30:06 +00:00
OBJS = db.o db_author.o db_book.o db_series.o json.o main.o
2016-12-31 09:31:48 +00:00
2017-04-03 19:06:29 +00:00
EXT = externals
BOOTSTRAP_VERSION = 3.3.7
BOOTSTRAP_DIST = bootstrap-$(BOOTSTRAP_VERSION)-dist
BOOTSTRAP_URL = https://github.com/twbs/bootstrap/releases/download/v$(BOOTSTRAP_VERSION)/$(BOOTSTRAP_DIST).zip
BOOTSTRAP_TMP_ZIP = $(EXT)/bootstrap.zip
VUE_URL = https://vuejs.org/js/vue.min.js
VUEJS = $(EXT)/vue.min.js
2017-01-14 16:38:40 +00:00
HTMLS = index.html book.html author.html series.html search.html
2017-04-03 19:06:29 +00:00
JSMINS = index.min.js book.min.js author.min.js series.min.js search.min.js $(VUEJS)
CSS = $(EXT)/$(BOOTSTRAP_DIST)/css/bootstrap.min.css
FONTS = $(EXT)/$(BOOTSTRAP_DIST)/fonts/*
2016-12-31 09:31:48 +00:00
2016-12-18 15:50:32 +00:00
CFLAGS += -g -W -Wall -O2 $(SECURE)
CFLAGS += -DLOGFILE=\"$(LOGFILE)\"
CFLAGS += -DDATADIR=\"$(RDDIR)\"
CFLAGS += -DDATABASE=\"$(DATABASE)\"
VERSION = 0.0.0
2017-01-15 10:43:07 +00:00
.if defined(DEBUG)
CFLAGS += -DDEBUG
.endif
2016-12-18 15:50:32 +00:00
all: $(TARGET) $(HTMLS) $(JSMINS)
api: swagger.json
2017-04-03 19:06:29 +00:00
$(BOOTSTRAP_TMP_ZIP):
fetch -o $(BOOTSTRAP_TMP_ZIP) $(BOOTSTRAP_URL)
$(EXT)/$(BOOTSTRAP_DIST): $(BOOTSTRAP_TMP_ZIP)
unzip -d $(EXT) $(BOOTSTRAP_TMP_ZIP)
$(VUEJS):
fetch -o $(VUEJS) $(VUE_URL)
$(EXT): $(EXT)/$(BOOTSTRAP_DIST) $(VUEJS)
packwww: $(EXT) $(HTMLS) $(JSMINS)
mkdir -p build build/css build/fonts build/js
cp $(HTMLS) build
cp $(JSMINS) $(VUEJS) build/js
cp $(CSS) build/css
cp $(FONTS) build/fonts
packcgi: $(TARGET)
mkdir -p build/cgi-bin
cp $(TARGET) build/cgi-bin
cp $(OBJS) build/cgi-bin
package: packcgi packwww
tar czf bouquins.tar.gz -C build cgi-bin $(HTMLS) css js fonts
rm -rf build/*
2016-12-18 15:50:32 +00:00
installwww: all
2016-12-31 09:31:48 +00:00
mkdir -p $(HTDOCS) $(HTDOCS)/css $(HTDOCS)/fonts $(HTDOCS)/js
install -m 0444 $(HTMLS) $(HTDOCS)
2017-04-03 19:06:29 +00:00
install -m 0444 $(JSMINS) $(HTDOCS)/js
2016-12-31 09:31:48 +00:00
install -m 0444 $(CSS) $(HTDOCS)/css
install -m 0444 $(FONTS) $(HTDOCS)/fonts
2016-12-18 15:50:32 +00:00
installapi: api
mkdir -p $(APIDOCS)
install -m 0444 swagger.json $(APIDOCS)
updatecgi: all
mkdir -p $(CGIBIN)
install -m 0555 $(TARGET) $(CGIBIN)/$(CGINAME)
2016-12-31 09:31:48 +00:00
install -m 0555 $(OBJS) $(CGIBIN)/
2016-12-18 15:50:32 +00:00
installcgi: updatecgi
mkdir -p $(DATADIR)
chmod 0777 $(DATADIR)
clean:
2016-12-18 17:29:39 +00:00
rm -f $(TARGET) $(JSMINS) $(OBJS)
2016-12-18 15:50:32 +00:00
rm -f swagger.json
.js.min.js:
sed -e "s!@HTURI@!$(HTURI)!g" \
-e "s!@VERSION@!$(VERSION)!g" \
-e "s!@CGIURI@!$(CGIURI)!g" $< >$@
$(TARGET): $(OBJS)
2017-04-02 18:35:55 +00:00
$(CC) $(STATIC) -o $@ $(OBJS) $(LDFLAGS) -lksql -lkcgi -lkcgijson -lz -lsqlite3 -pthread
2016-12-18 15:50:32 +00:00
$(OBJS): extern.h
swagger.json: swagger.in.json
@rm -f $@
sed -e "s!@VERSION@!$(VERSION)!g" -e "s!@TARGET@!$(TARGET)!g" swagger.in.json >$@
@chmod 400 $@