~strahinja/reflow

7af9e53fe7db9f12376416a026f95eb74e263645 — Страхиња Радић 1 year, 2 months ago 326c8e9
Change build scripts to make .gz optional; OpenBSD build and instructions

Signed-off-by: Страхиња Радић <contact@strahinja.org>
7 files changed, 62 insertions(+), 14 deletions(-)

M INSTALL
M all.do
M clean.do
M config.redo
M default.o.do
M install.do
M uninstall.do
M INSTALL => INSTALL +20 -1
@@ 2,7 2,12 @@ Prerequisites
=============

* C compiler - defaults in config.redo
* gzip


Optional
--------

* gzip (autodetected, for manpage compression)


Install


@@ 27,3 32,17 @@ Persistent build configuration file
The file config.redo will be sourced when building targets which also accept
configuration through environment variables.  For example, CC and PREFIX
are specified in config.redo.


OpenBSD
-------

Replace gcc in CC with cc and add -D_BSD_SOURCE, eg:

	# CC='cc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L
		-D_XOPEN_SOURCE=700 -D_BSD_SOURCE}' \
		./do install

and change MANDIR to

	MANDIR=$PREFIX/man/man1

M all.do => all.do +2 -1
@@ 1,1 1,2 @@
redo-ifchange version.h reflow reflow.1.gz
. ./config.redo
redo-ifchange reflow reflow.1"$MANSUFFIX"

M clean.do => clean.do +2 -1
@@ 1,1 1,2 @@
rm -f *~ *.o reflow reflow.1 reflow.1.gz version.h version date
. ./config.redo
rm -f *~ *.o reflow $MANPAGES *.1 version.h version date

M config.redo => config.redo +17 -0
@@ 1,4 1,21 @@
PREFIX=${PREFIX:-/usr/local}

BINDIR=$PREFIX/bin
DOCDIR=$PREFIX/share/doc/reflow
MANDIR=$PREFIX/share/man/man1

# OpenBSD
#MANDIR=$PREFIX/man/man1

PROGS="reflow"
DOCS="README LICENSE"
MANSUFFIX=${MANSUFFIX-$(command -v gzip >/dev/null && printf ".gz")}
MANPAGES="reflow.1${MANSUFFIX}"

CC=${CC:-gcc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L \
-D_XOPEN_SOURCE=700}
STRIP=${STRIP:-:}

# OpenBSD
#CC=${CC:-cc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L \
#-D_XOPEN_SOURCE=700 -D_BSD_SOURCE}

M default.o.do => default.o.do +2 -3
@@ 1,6 1,5 @@
. ./config.redo
for f in *.h; do
	echo $f
done | xargs redo-ifchange
sed -n 's/^#include "\([^"]*\)"/\1/p' ${2%.o}.c |
	xargs redo-ifchange
redo-ifchange $2.c
${CC} -c $2.c -o $3

M install.do => install.do +10 -5
@@ 1,7 1,12 @@
redo-ifchange all
. ./config.redo
BINDIR=$PREFIX/bin
MANDIR=$PREFIX/share/man/man1
install -d $BINDIR $MANDIR
install -m 0755 reflow $BINDIR
install -m 0644 reflow.1.gz $MANDIR
install -d "$DOCDIR" "$BINDIR" "$MANDIR"
for docfile in $DOCS; do
	install -Dm 0644 "${docfile}" "${DOCDIR}/${docfile}"
done
for binfile in $PROGS; do
	install -Dm 0755 "${binfile}" "${BINDIR}/${binfile}"
done
for manfile in $MANPAGES; do
	install -Dm 0644 "${manfile}" "${MANDIR}/${manfile}"
done

M uninstall.do => uninstall.do +9 -3
@@ 1,5 1,11 @@
redo-always
. ./config.redo
BINDIR=$PREFIX/bin
MANDIR=$PREFIX/share/man/man1
rm -f $BINDIR/reflow $MANDIR/reflow.1.gz
for docfile in $DOCS; do
	rm -f "${DOCDIR}/${docfile}"
done
for binfile in $PROGS; do
	rm -f "${BINDIR}/${binfile}"
done
for manfile in $MANPAGES; do
	rm -f "${MANDIR}/${manfile}"
done