Blob


1 # Copyright (c) 2022 Omar Polo <op@omarpolo.com>
2 # Copyright (c) 2011, 2013-2022 Ingo Schwarze <schwarze@openbsd.org>
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 # tests to run as a port of the regression suite. Leave empty to run
18 # all.
19 TESTS=
21 # host to bind to during regress
22 REGRESS_HOST = localhost
24 # -- build-related variables --
26 COBJS = ${COMPATS:.c=.o}
28 GMID_SRCS = gmid.c config.c crypto.c dirs.c fcgi.c iri.c log.c \
29 logger.c mime.c proc.c proxy.c puny.c sandbox.c \
30 server.c utf8.c utils.c y.tab.c proxy-proto.c
32 GMID_OBJS = ${GMID_SRCS:.c=.o} ${COBJS}
34 GEMEXP_SRCS = ge.c config.c crypto.c dirs.c fcgi.c iri.c log.c mime.c \
35 proc.c proxy.c puny.c sandbox.c server.c utf8.c utils.c proxy-proto.c
37 GEMEXP_OBJS = ${GEMEXP_SRCS:.c=.o} ${COBJS}
39 GG_SRCS = gg.c iri.c log.c utf8.c
41 GG_OBJS = ${GG_SRCS:.c=.o} ${COBJS}
43 TITAN_SRCS = titan.c iri.c log.c utf8.c
44 TITAN_OBJS = ${TITAN_SRCS:.c=.o} ${COBJS}
46 SRCS = gmid.h iri.h log.h parse.y proc.h \
47 ${GMID_SRCS} ${GEMEXP_SRCS} ${GG_SRCS} ${TITAN_SRCS}
49 DISTNAME = gmid-${VERSION}
51 # -- public targets --
53 all: config.mk gmid gemexp gg titan
54 .PHONY: all tags clean cleanall test regress install
56 config.mk config.h: configure
57 @echo "$@ is out of date; please run ./configure"
58 @exit 1
60 include config.mk
62 clean:
63 rm -f gmid gemexp gg
64 rm -f *.[do] compat/*.[do] compat/libtls/*.[do]
65 rm -f y.tab.c y.tab.h y.output
66 rm -f compile_flags.txt
67 ${MAKE} -C regress clean
69 distclean: clean
70 rm -f config.h config.h.old config.log config.log.old config.mk
72 test: regress
73 regress: all
74 ${MAKE} 'TESTS=${TESTS}' -C regress all
76 install: gmid gg gemexp
77 mkdir -p ${DESTDIR}${BINDIR}
78 mkdir -p ${DESTDIR}${MANDIR}/man1
79 mkdir -p ${DESTDIR}${MANDIR}/man5
80 mkdir -p ${DESTDIR}${MANDIR}/man8
81 ${INSTALL_PROGRAM} gemexp ${DESTDIR}${BINDIR}
82 ${INSTALL_PROGRAM} gg ${DESTDIR}${BINDIR}
83 ${INSTALL_PROGRAM} gmid ${DESTDIR}${BINDIR}
84 ${INSTALL_PROGRAM} titan ${DESTDIR}${BINDIR}
85 ${INSTALL_MAN} gemexp.1 ${DESTDIR}${MANDIR}/man1
86 ${INSTALL_MAN} gg.1 ${DESTDIR}${MANDIR}/man1
87 ${INSTALL_MAN} titan.1 ${DESTDIR}${MANDIR}/man1
88 ${INSTALL_MAN} gmid.conf.5 ${DESTDIR}${MANDIR}/man5
89 ${INSTALL_MAN} gmid.8 ${DESTDIR}${MANDIR}/man8
91 uninstall:
92 rm ${DESTDIR}${BINDIR}/gemexp
93 rm ${DESTDIR}${BINDIR}/gg
94 rm ${DESTDIR}${BINDIR}/gmid
95 rm ${DESTDIR}${BINDIR}/titan
96 rm ${DESTDIR}${MANDIR}/man1/gemexp.1
97 rm ${DESTDIR}${MANDIR}/man1/gg.1
98 rm ${DESTDIR}${MANDIR}/man1/titan.1
99 rm ${DESTDIR}${MANDIR}/man5/gmid.conf.5
100 rm ${DESTDIR}${MANDIR}/man8/gmid.8
102 tags:
103 ctags ${SRCS}
105 # --internal build targets --
107 gmid: ${GMID_OBJS}
108 ${CC} ${GMID_OBJS} -o $@ ${LDFLAGS} ${LIBS}
110 gemexp: ${GEMEXP_OBJS}
111 ${CC} ${GEMEXP_OBJS} -o $@ ${LDFLAGS} ${LIBS}
113 gg: ${GG_OBJS}
114 ${CC} ${GG_OBJS} -o $@ ${LDFLAGS} ${LIBS}
116 titan: ${TITAN_OBJS}
117 ${CC} ${TITAN_OBJS} -o $@ ${LDFLAGS} ${LIBS}
119 y.tab.c: parse.y
120 ${YACC} -b y parse.y
122 # make sure we pass -o to ${CC}. OpenBSD default suffix rule doesn't
123 .SUFFIXES: .c .o
124 .c.o:
125 ${CC} ${CFLAGS} -c $< -o $@
127 # -- maintainer targets --
129 .PHONY: lint release dist
131 lint:
132 man -Tlint -Wstyle -l gmid.8 gmid.conf.5 gemexp.1 gg.1 titan.1
134 PUBKEY = keys/gmid-2.0.pub
135 PRIVKEY = set-PRIVKEY
136 DISTFILES = .cirrus.yml .dockerignore .gitignore ChangeLog LICENSE \
137 Makefile README.md config.c configure crypto.c dirs.c fcgi.c \
138 ge.c gemexp.1 gg.1 gg.c gmid.8 gmid.c gmid.conf.5 gmid.h \
139 iri.c iri.h log.c log.h logger.c mime.c parse.y proc.c \
140 proc.h proxy.c proxy-proto.c puny.c sandbox.c server.c \
141 titan.1 titan.c utf8.c utils.c y.tab.c
143 release:
144 sed -i -e '/^RELEASE=/s/no/yes/' configure
145 ${MAKE} dist
146 sed -i -e '/^RELEASE=/s/yes/no/' configure
147 signify -S -e -m ${DISTNAME}.sha256 -s ${PRIVKEY}
149 verify-release:
150 signify -C -p ${PUBKEY} -x ${DISTNAME}.sha256.sig
152 dist: ${DISTNAME}.sha256
154 ${DISTNAME}.sha256: ${DISTNAME}.tar.gz
155 sha256 ${DISTNAME}.tar.gz > $@
157 ${DISTNAME}.tar.gz: ${DISTFILES}
158 mkdir -p .dist/${DISTNAME}/
159 ${INSTALL} -m 0644 ${DISTFILES} .dist/${DISTNAME}/
160 cd .dist/${DISTNAME} && chmod 755 configure
161 ${MAKE} -C compat DESTDIR=${PWD}/.dist/${DISTNAME}/compat dist
162 ${MAKE} -C contrib DESTDIR=${PWD}/.dist/${DISTNAME}/contrib dist
163 ${MAKE} -C have DESTDIR=${PWD}/.dist/${DISTNAME}/have dist
164 ${MAKE} -C keys DESTDIR=${PWD}/.dist/${DISTNAME}/keys dist
165 ${MAKE} -C regress DESTDIR=${PWD}/.dist/${DISTNAME}/regress dist
166 cd .dist/ && tar zcf ../$@ ${DISTNAME}
167 rm -rf .dist/
169 # -- dependencies --
171 -include config.d
172 -include crypto.d
173 -include dirs.d
174 -include fcgi.d
175 -include ge.d
176 -include gg.d
177 -include gmid.d
178 -include iri.d
179 -include log.d
180 -include logger.d
181 -include mime.d
182 -include proc.d
183 -include proxy.d
184 -include proxy-proto.d
185 -include puny.d
186 -include sandbox.d
187 -include server.d
188 -include titan.d
189 -include utf8.d
190 -include utils.d
191 -include y.tab.d