humungus - reop

i am gravely disappointed

just walk away and there will be an end to the horror

overview - files - changes

viewing file: reop/ configure

view - history - annotated - download

#!/bin/sh

has() {
	header=/usr/include/$1
	[ -f $header ] && grep -q $2 $header
}

doconfigure() {
	cflags=$(pkg-config --cflags libsodium)
	libs=$(pkg-config --libs libsodium)
	[ -n "$cflags" ] || cflags='-I/usr/local/include'
	[ -n "$libs" ] || libs='-L/usr/local/lib -lsodium'

	printf 'CPPFLAGS=-Iother\n'
	printf 'CFLAGS=-std=c99 -Wall -O2 %s\n' "$cflags"
	printf 'LDFLAGS=%s\n' "$libs"
	printf 'OBJS=reop.o\n'
	# always include base64.c. testing for correct versions is too hard
	printf 'OBJS+=other/base64.o\n'
	if has features.h _GNU_SOURCE ; then
		printf 'CPPFLAGS+=-D_GNU_SOURCE\n'
	fi
	if has features.h _FILE_OFFSET_BITS ; then
		printf 'CPPFLAGS+=-D_FILE_OFFSET_BITS=64\n'
	fi
	if [ `uname` = "Darwin" ] ; then
		: # always has strlcpy; sometimes hard to find
	elif ! has string.h strlcpy ; then
		printf 'CPPFLAGS+=-DNEED_STRLCPY\n'
		printf 'OBJS+=other/strlcpy.o\n'
		printf 'OBJS+=other/strlcat.o\n'
	fi
	if ! has readpassphrase.h readpassphrase ; then
		printf 'OBJS+=other/readpassphrase.o\n'
	fi
		
	if has util.h bcrypt_pbkdf ; then
		printf 'LDFLAGS+=-lutil\n'
	else
		printf 'OBJS+=other/bcrypt_pbkdf.o\n'
		if ! has blf.h Blowfish_initstate ; then
			printf 'OBJS+=other/blowfish.o\n'
		fi
	fi

	printf 'SOBJS:=${OBJS:o=so}\n'
	printf 'LIBREOP=libreop.so.%s\n' `cat shlib_version`
	printf '\n'
	printf 'all: reop ${LIBREOP}\n'
	printf '\n'
	printf '.SUFFIXES: .c .o .so\n'
	printf '\n'
	printf '.c.o:\n'
	printf '\t${CC} ${CFLAGS} ${CPPFLAGS} -o $@ -c $<\n'
	printf 'reop.o: reop.c\n'
	printf '\t${CC} -DREOPMAIN ${CFLAGS} ${CPPFLAGS} -o $@ -c $<\n'
	printf '\n'
	printf '.c.so:\n'
	printf '\t${CC} -fPIC ${CFLAGS} ${CPPFLAGS} -o $@ -c $<\n'
	printf '\n'
	printf 'reop: ${OBJS}\n'
	printf '\t${CC} ${OBJS} -o reop ${LDFLAGS}\n'
	printf '\n'
	printf '${LIBREOP}: ${SOBJS}\n'
	printf '\t${CC} -shared ${SOBJS} -o $@ ${LDFLAGS}\n'
	printf '\n'
	printf 'clean:\n'
	printf '\trm -f ${OBJS} reop\n'
	printf '\trm -f ${SOBJS} ${LIBREOP}\n'
}

doconfigure > Makefile