# This Makefile written by Brian Callahan <bcallah@openbsd.org>
# and released into the Public Domain.

CC ?=		cc
CFLAGS ?=	-O2 -pipe

PREFIX ?=	/usr/local

MAJOR =	0
MINOR =	0

LIBNAME = libaio_compat

LIBSH =	${LIBNAME}.so.${MAJOR}.${MINOR}
LIBST =	${LIBNAME}.a

OBJS =	aio.o

MAN =	aio_cancel.3 aio_error.3 aio_read.3 aio_return.3 \
	aio_suspend.3 aio_write.3

all: shared static

shared: ${OBJS}
	${CC} -shared -Wl,-soname,${LIBSH} -fpic \
		-o ${LIBSH} ${OBJS} -pthread

static: ${OBJS}
	${AR} cru ${LIBST} ${OBJS}
	${RANLIB} ${LIBST}

install:
	install -d -m 755 ${PREFIX}/include
	install -d -m 755 ${PREFIX}/lib
	install -d -m 755 ${PREFIX}/man/man3
	install -c -S -m 644 aio_compat.h ${PREFIX}/include
	install -c -S -s -m 755 ${LIBSH} ${PREFIX}/lib
	install -c -S -m 755 ${LIBST} ${PREFIX}/lib
	install -c -S -m 755 ${MAN} ${PREFIX}/man/man3

clean:
	rm -f ${LIBSH} ${LIBST} ${OBJS}
