# Generic lib Makefile

# RCSid:
#	$Id: Makefile,v 1.38 2009/12/14 18:09:44 sjg Exp $
#
#	@(#) Copyright (c) 1994 Simon J. Gerraty
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@crufty.net
#

LIB=	${.CURDIR:T}

CFLAGS+= -Dlib${LIB}

.ifmake obj

# otherwise a .PATH in .srcs or .cfg can muck us up.
SRCS=*.c
.include <lib.mk>

.else

.if exists(${.CURDIR}/.srcs)
.include "${.CURDIR}/.srcs"
.else
all: .srcs
.endif

.NOPATH: .install

all:	.install

.ifdef SRCS
.include <lib.mk>
.endif

.if !make(obj) && exists(${.CURDIR}/.cfg)
.include "${.CURDIR}/.cfg"
.endif

.PRECIOUS: .srcs

.ifnmake .srcs
_x=false
.endif

.srcs:
	@echo "SRCS= \\" > ${.CURDIR}/.srcs
	@cd ${.CURDIR} && /bin/ls -1 *.c | paste -s -d"     \n" - | sed -e 's/^/	/' -e 's/$$/ \\/' >> ${.CURDIR}/.srcs
	@echo >> ${.CURDIR}/.srcs
	@echo Updated .srcs now re-run ${MAKE}; ${_x}

.SUFFIXES:	.test

.c.test:
	${CC} ${CFLAGS} ${CPPFLAGS} ${LDSTATIC} -DMAIN -DTEST -DUNIT_TEST -o ${.TARGET} ${.IMPSRC} ${LDADD} ${XLIBS}

CLEANFILES+= ${SRCS:R:S/$/.test/}

# needs latest lib.mk
.NOPATH:	.libinstall
.install:	.libinstall
		touch ${.TARGET}

.endif
