EXES=@exes@

all: ${EXES}

SCRIPTS=bon_csv2html bon_csv2txt

prefix=@prefix@
WFLAGS=-Wall -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Weffc++ -pedantic -ffor-scope
CFLAGS=-O2 -g -DNDEBUG ${WFLAGS}
CXX=@CXX@ ${CFLAGS}

INSTALL=@INSTALL@

BONSRC=bon_io.cpp bon_file.cpp bon_time.cpp semaphore.cpp forkit.cpp \
 bon_suid.cpp
BONOBJS=${BONSRC:.cpp=.o}

MAN1=bon_csv2html.1 bon_csv2txt.1
MAN8=@man8@

ZCAVSRC=bon_suid.cpp
ZCAVOBJS=${ZCAVSRC:.cpp=.o}

ALLOBJS=${BONOBJS} ${ZCAVOBJS}

bonnie++: bonnie++.cpp ${BONOBJS}
	${CXX} bonnie++.cpp -o bonnie++ ${BONOBJS} ${LFLAGS}

zcav: zcav.cpp ${ZCAVOBJS}
	${CXX} zcav.cpp -o zcav ${ZCAVOBJS} ${LFLAGS}

install-bin: ${EXES}
	mkdir -p ${prefix}/bin ${prefix}/sbin
	@INSTALL_PROGRAM@ @stripping@ ${EXES} ${prefix}/sbin
	@INSTALL_PROGRAM@ ${SCRIPTS} ${prefix}/bin

install: install-bin
	mkdir -p @mandir@/man1 @mandir@/man8
	@INSTALL_DATA@ ${MAN1} @mandir@/man1
	@INSTALL_DATA@ ${MAN8} @mandir@/man8

%.o: %.cpp %.h bonnie.h port.h
	${CXX} -c $<

bon_suid.o: bon_suid.cpp bonnie.h port.h
	${CXX} -c $<

clean:
	rm -f ${EXES} ${ALLOBJS} build-stamp install-stamp
	rm -rf debian/tmp core debian/*.debhelper
	rm -f debian/{substvars,files} config.log

realclean: clean
	rm -f config.* Makefile bonnie.h port.h bonnie++.spec bon_csv2html bon_csv2txt sun/pkginfo
