From 771d8f281baa6f15913d705365e00c3128feac8b Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Sun, 17 Jan 2021 12:12:37 +0000 Subject: [PATCH] build docs + install and static targets --- INSTALL.gmi | 43 ------------------------------------------- Makefile | 17 ++++++++++++++++- README.md | 19 ++++++++++--------- 3 files changed, 26 insertions(+), 53 deletions(-) delete mode 100644 INSTALL.gmi diff --git a/INSTALL.gmi b/INSTALL.gmi deleted file mode 100644 index c822e3e..0000000 --- a/INSTALL.gmi +++ /dev/null @@ -1,43 +0,0 @@ -# Installing gmid - -## Dependencies - -gmid depends on libtls and a C compiler. It's reported to compile with gcc 4.2, so it should work pretty everywhere now. - -The compilation is as easy as - -``` -make -``` - -Note that there isn't an install target yet. - -If you're a packager, don't forget to install also the manpage gmid.1 - -### etags - -during the build process, etags(1) is invoked to generate a TAGS file. This is done to aid the development. Anyway, etags(1) is NOT NEEDED as dependency. So, if you get something like - -``` -$ make -... -etags gmid.c -make: exec(etags) failed (No such file or directory) -*** Error code 1 (ignored) -``` - -you don't need to worry, it is OK. - -## Notes for specific OSes - -### OpenBSD - -Everything you need is in base, just run make. - -### FreeBSD - -You need to install security/libressl and then - -``` -make CFLAGS=-I/usr/local/include LDFLAGS='-L/usr/local/lib -ltls' -``` diff --git a/Makefile b/Makefile index cf06def..4d6ae12 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,12 @@ LDFLAGS = -ltls LEX = lex YACC = yacc -.PHONY: all clean test +PREFIX = /usr/local + +# /usr/local/lib on FreeBSD +LIBDIR = /usr/lib/ + +.PHONY: all static clean test install all: gmid TAGS README.md @@ -18,6 +23,12 @@ OBJS = gmid.o iri.o utf8.o lex.yy.o y.tab.o ex.o cgi.o sandbox.o gmid: ${OBJS} ${CC} ${OBJS} -o gmid ${LDFLAGS} +static: ${OBJS} + ${CC} -static ${OBJS} \ + ${LIBDIR}/libcrypto.a ${LIBDIR}/libtls.a ${LIBDIR}/libssl.a \ + -o gmid + strip gmid + TAGS: gmid.c iri.c utf8.c ex.c cgi.c sandbox.c -etags gmid.c iri.c utf8.c ex.c cgi.c sandbox.c || true @@ -35,3 +46,7 @@ test: gmid iri_test @echo "server tests" @echo "==============================" cd test && ./test.sh + +install: gmid + install -o root -g wheel -m 0755 gmid ${PREFIX}/bin/ + install -o root -g wheel -m 0644 gmid.1 ${PREFIX}/man/man1 diff --git a/README.md b/README.md index 7bbc2ed..0bcaa14 100644 --- a/README.md +++ b/README.md @@ -32,23 +32,24 @@ mind: on Linux, FreeBSD and OpenBSD is sandboxed via `seccomp(2)`, ## Building -gmid depends a POSIX libc and libtls. It can probably be linked -against libretls, but I've never tried. +gmid depends on a POSIX libc and libtls (part of LibreSSL). It can +probably be linked against libretls, but I've never tried. At build +time, flex and yacc (or GNU bison) are also needed. -See [INSTALL.gmi](INSTALL.gmi) for more info, but the build is as -simple as +The build is as simple as make -The Makefile isn't able to produce a statically linked executable -(yet), so for that you have to execute by hand +or - make - cc -static *.o /usr/lib/lib{crypto,tls,ssl}.a -o gmid - strip gmid + make static to enjoy your ~2.3M statically-linked gmid. +To install execute: + + make install + ## Architecture/Security considerations