# $Id: PTMakefile,v 1.6 2000/07/24 21:26:51 carlo Exp $
#
# ProtoType Common Makefile
#
# Copyright (C) 1999-2000, by
#
#   Carlo Wood, Run on IRC <carlo@alinoe.com>
#   RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
#   Fingerprint16 = 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.

include $(PROTODIR)/Makedefs.h

IFLAGS:=$(INCLUDEFLAGS)
INCLUDEFLAGS:=$(patsubst -QI/%,-I/%,$(patsubst -I%,-I../%,$(patsubst -I/%,-QI/%,${INCLUDEFLAGS})))
export INCLUDEFLAGS

OBJS:=$(shell echo "$(CSRC)" "$(CXXSRC)" | sed -e 's%\.c %.o %g' -e 's%\.c$$%.o%' -e 's%\$(CPPEXT) %.o %g' -e 's%\$(CPPEXT)$$%.o%')
ifeq ($(GETSUBOBJS), "yes")
SUBOBJS:=$(shell list='$(SUBDIRS)'; for i in $$list; do for j in `(exec 5>&3; $(MAKE) -C $$i printobjs 1>/dev/null 2>/dev/null) 3>&1`; do echo "$$i/$$j"; done; done)
endif

.PHONY: build all clean depend subdirs printobjs .clean real-clean
.SUFFIXES:

all:
	@if [ "$(BASEDIR)" = "." ]; then \
	  $(MAKE) -r build; \
	else \
	  $(MAKE) -r -C $(BASEDIR) all; \
	fi

subdirs:
	@list='$(SUBDIRS)'; for i in $$list; do $(MAKE) -C $$i build || exit; done

printobjs::

.clean:
	$(RM) -f *.o core *.orig .depend*

clean:: .clean
	@list='$(SUBDIRS)'; for i in $$list; do $(MAKE) -C $$i clean; done

real-clean:: .clean
	@list='$(SUBDIRS)'; for i in $$list; do $(MAKE) -r -C $$i real-clean || exit; done

depend:: .depend-timestamp
	@list='$(SUBDIRS)'; for i in $$list; do $(MAKE) -C $$i depend || exit; done

.depend-timestamp: $(CXXSRC) $(CSRC)
	@$(RM) -f .depend
	@echo >.depend-timestamp
	@echo '# Program dependencies' >.depend
ifneq ($(CXXSRC),)
	$(CXX) $(DFLAGS) $(CXXFLAGS) $(IFLAGS) -I- $(SYSTEMINCLUDEFLAGS) $(CXXSRC) >> .depend
endif
ifneq ($(CSRC),)
	$(CC) $(DFLAGS) $(CFLAGS) $(IFLAGS) -I- $(SYSTEMINCLUDEFLAGS) $(CSRC) >> .depend
endif

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

