# $Id: PTMakefile,v 1.1 1999/03/11 15:00:30 carlo Exp $
#
# ProtoType Subdirectory Makefile
#
# Copyright (C) 1999
#
# 1024/624ACAD5 1997/01/26 Carlo Wood, Run on IRC <carlo@runaway.xs4all.nl>
# Key fingerprint = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
#
# All rights reserved.
#
# See the file LICENSE for copyright information.
#
# This file may be distributed under the terms of the Q Public License 1.0
# as defined by Troll Tech AS of Norway and appearing in the file LICENSE.QPL
# included in the packaging of this file.
#
#-----------------------------------------------------------------------------
#
# Edit $PROTODIR/Makedefs.h to get it working for your system
#

include ${PROTODIR}/Makedefs.h

OBJS:=$(shell echo "${SRC}" | sed -e 's%\.c %.o %g' -e 's%\.c$$%.o%' -e 's%\.cc %.o %g' -e 's%\.cc$$%.o%')

.PHONY: all build printobjs clean depend
.SUFFIXES:

all:
	${MAKE} -r -C ${BASEDIR} all

%.o: %.c ${PROTODIR}/Makedefs.h
	${CC} ${CFLAGS} ${INCLUDEFLAGS} -I- ${SYSTEMINCLUDEFLAGS} -c $< -o $@

%.o: %.cc ${PROTODIR}/Makedefs.h
	${CC} ${CFLAGS} ${INCLUDEFLAGS} -I- ${SYSTEMINCLUDEFLAGS} -c $< -o $@

build:: .depend ${OBJS}
	@for i in ${SUBDIRS}; do ${MAKE} -C $$i build || exit; done

printobjs:
	@echo "${OBJS}" >&5
	@for i in ${SUBDIRS}; do\
	  for j in `(exec 5>&3; make -C $$i printobjs 1>/dev/null 2>/dev/null) 3>&1`; do\
	    echo $$i/$$j >&5;\
	  done;\
	done;

clean::
	${RM} -f *.o core *.orig .depend*
	@for i in ${SUBDIRS}; do ${MAKE} -C $$i clean; done

depend:: .depend
	@for i in ${SUBDIRS}; do ${MAKE} -C $$i depend || exit; done

.depend: ${SRC}
	@${RM} -f .depend
	@echo '# Program dependencies' > .depend
ifneq (${SRC},)
	${MAKEDEPEND} ${CFLAGS} ${INCLUDEFLAGS} -I- ${SYSTEMINCLUDEFLAGS} ${SRC} >> .depend
endif

#
# include a dependency file
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
