# RCSid:
#	$Id: Makefile.inc,v 1.9 1997/02/08 07:09:10 sjg Exp $
#
#	@(#) Copyright (c) 1995 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@quick.com.au
#

.ifndef _top_inc_
_top_inc_=yes

TOP?=/usr/local

.ifndef _base_inc_
_base_inc_=yes

.include "Makefile.base"

BASE?=/usr/local/src/sjg
.endif

SRCDIR?=${BASE}
INCDIR=${SRCDIR}/include
LIBDIR=${SRCDIR}/lib/obj.${MACHINE}
BINDIR?=${BASE}/bin
MANDIR?=${BASE}/man/cat
ETCDIR?=${BASE}/etc
# this bit of mucking about lets us install without -o -g thus not
# needing to be root.
OWN?=root
GRP?=wheel
BINOWN?=-o${OWN}
BINGRP?=-g${GRP}
LIBOWN?=-o${OWN}
LIBGRP?=-g${GRP}
LIBMODE=644
BINMODE=755
# hope it is in $PATH
INSTALL?=install.sh
BININSTALL_FLAGS=${COPY} ${STRIP} ${BINOWN} ${BINGRP} -m ${BINMODE}
LIBINSTALL_FLAGS=${COPY} ${LIBOWN} ${LIBGRP} -m ${LIBMODE}
STRIP?=
COPY?=
OBJMACHINE=yes
LDSTATIC?=$(STATIC)
LDADD+=${LDSTATIC} -L${LIBDIR} ${LIBS}

CFLAGS+= ${DBG} -I. -I${.CURDIR} -I${.CURDIR}/.. -I${INCDIR}

.ifndef _machine_inc_
_machine_inc_=yes

.if exists(${.CURDIR}/../Makefile.${MACHINE}.inc)
.include "${.CURDIR}/../Makefile.${MACHINE}.inc"
.elif exists(${.CURDIR}/../../Makefile.${MACHINE}.inc)
.include "${.CURDIR}/../../Makefile.${MACHINE}.inc"
.elif exists(${.CURDIR}/../../../Makefile.${MACHINE}.inc)
.include "${.CURDIR}/../../../Makefile.${MACHINE}.inc"
.endif
.endif

.ifndef _conf_done_
_conf_done_=yes

CONFDIR?=${SRCDIR}/conf

.if exists(${CONFDIR}/obj.${MACHINE}/Makefile.inc)
CFLAGS+= -I${CONFDIR}/obj.${MACHINE} -I${CONFDIR}
.include "${CONFDIR}/obj.${MACHINE}/Makefile.inc"
.endif
.else	# _conf_done_
.if exists(/usr/include/stdlib.h) || exists(${INCDIR}/stdlib.h)
CFLAGS+= -DHAVE_STDLIB_H
.endif
.if exists(/usr/include/snmp.h) || exists(${INCDIR}/snmp.h)
CFLAGS+= -DHAVE_SNMP_H
.endif
.endif	# _conf_done_

DBG?= -g

# some standard stuff for building other peoples packages.
.if exists(${.CURDIR}/src)
.PATH: ${.CURDIR}/src
CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/src
.elif exists(${.CURDIR}/../dist)
.PATH: ${.CURDIR}/../dist
CFLAGS+= -I${.CURDIR}/../dist
.endif

.endif	# _top_inc_
