-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
148 lines (106 loc) · 3.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.SUFFIXES: .html .in.xml .xml .js .min.js .db .sql
.PHONY: clean distclean regress distcheck
# https://github.com/kristapsdz/oconfigure compatibility.
# This is generated by ./configure.
include Makefile.configure
# Path to static media.
# HTDOCS is the file-system path; HTURI is the URL path.
HTDOCS = /var/www/htdocs
HTURI =
# Path to the CGI script.
# CGIBIN is the file-system path; HTURI is the URL path.
CGIBIN = /var/www/cgi-bin
CGIURI = /cgi-bin/yourprog
# Path to the database
# DATADIR is the file-system path; RDDIR is in the chroot.
# If there's no chroot, these are the same.
DATADIR = /var/www/data
RDDIR = /data
# Uncomment this to disable -static linking.
# This is set to -static by configure for supporting systems.
#LDADD_STATIC =
# If on an HTTPS-only installation, should be "-DSECURE".
SECURE = -DSECURE
# File-system path where OAS API is installed.
APIDOCS = /var/www/htdocs/api-docs
# Override these with an optional local file.
sinclude Makefile.local
OBJS = compats.o db.o json.o valids.o main.o
HTMLS = index.html
JSMINS = index.min.js
DEPS_PKG = sqlbox kcgi-json
STATIC_PKG != [ -z "$(LDADD_STATIC)" ] || echo "--static"
CFLAGS_PKG != pkg-config --cflags $(DEPS_PKG)
LDADD_PKG != pkg-config --libs $(STATIC_PKG) $(DEPS_PKG)
CFLAGS += $(CFLAGS_PKG)
LDADD += $(LDADD_PKG) $(LDADD_CRYPT)
CFLAGS += -DDATADIR=\"$(RDDIR)\"
VERSION = 0.0.5
all: yourprog yourprog.db yourprog-upgrade $(HTMLS) $(JSMINS)
api: swagger.json
yourprog-upgrade: yourprog-upgrade.in.sh
sed -e "s!@DATADIR@!$(DATADIR)!g" \
-e "s!@CGIBIN@!$(CGIBIN)!g" \
-e "s!@SHAREDIR@!$(SHAREDIR)!g" yourprog-upgrade.in.sh >$@
install: all
mkdir -p $(DESTDIR)$(SHAREDIR)/yourprog
mkdir -p $(DESTDIR)$(SBINDIR)
mkdir -p $(DESTDIR)$(CGIBIN)
mkdir -p $(DESTDIR)$(HTDOCS)
$(INSTALL_DATA) $(HTMLS) $(JSMINS) $(DESTDIR)$(HTDOCS)
$(INSTALL_DATA) yourprog.ort $(DESTDIR)$(SHAREDIR)/yourprog
$(INSTALL_PROGRAM) yourprog $(DESTDIR)$(CGIBIN)
$(INSTALL_PROGRAM) yourprog-upgrade $(DESTDIR)$(SBINDIR)
uninstall:
rm -f $(DESTDIR)$(SHAREDIR)/yourprog/yourprog.ort
rmdir $(DESTDIR)$(SHAREDIR)/yourprog
rm -f $(DESTDIR)$(CGIBIN)/yourprog
rm -f $(DESTDIR)$(SBINDIR)/yourprog-upgrade
installwww: all
mkdir -p $(HTDOCS)
$(INSTALL_DATA) $(HTMLS) $(JSMINS) $(HTDOCS)
installapi: api
mkdir -p $(APIDOCS)
$(INSTALL_DATA) swagger.json $(APIDOCS)
updatecgi: all
mkdir -p $(CGIBIN)
$(INSTALL_PROGRAM) yourprog $(CGIBIN)
installcgi: updatecgi
mkdir -p $(DATADIR)
rm -f $(DATADIR)/yourprog.db
install -m 666 yourprog.db $(DATADIR)
chmod 0777 $(DATADIR)
regress:
# Do nothing.
distcheck:
# Do nothing.
clean:
rm -f yourprog yourprog-upgrade $(HTMLS) $(JSMINS) $(OBJS) yourprog.db
rm -f swagger.json
rm -f db.c json.c valids.c extern.h yourprog.sql
distclean: clean
rm -f config.log config.h Makefile.configure
db.c: yourprog.ort
ort-c-source -Idvj -h extern.h yourprog.ort >$@
json.c: yourprog.ort
ort-c-source -Idvj -j -Nd -h extern.h yourprog.ort >$@
valids.c: yourprog.ort
ort-c-source -Idvj -v -Nd -h extern.h yourprog.ort >$@
extern.h: yourprog.ort
ort-c-header -jv yourprog.ort >$@
yourprog.sql: yourprog.ort
ort-sql yourprog.ort >$@
.sql.db:
@rm -f $@
sqlite3 $@ < $<
.js.min.js .xml.html:
sed -e "s!@HTURI@!$(HTURI)!g" \
-e "s!@VERSION@!$(VERSION)!g" \
-e "s!@CGIURI@!$(CGIURI)!g" $< >$@
yourprog: $(OBJS)
$(CC) $(LDADD_STATIC) -o $@ $(OBJS) $(LDFLAGS) $(LDADD)
$(OBJS): extern.h
swagger.json: swagger.in.json
@rm -f $@
sed -e "s!@VERSION@!$(VERSION)!g" swagger.in.json >$@
@chmod 400 $@