#
#  PROJECT
#      CSV Library (Libcsv)
#
#  DESCRIPTION
#      The src-level Makefile
#
#  DEVELOPER
#      Scott C. Karlin   (scott@cs.princeton.edu)
#
#  HISTORY
#      24 Apr 2003  sck  Initial Version
#
#  CVS ID
#      $Id: Makefile,v 1.2 2003/05/23 17:05:53 scott Exp $
#

##############################################################################
#
#  Give default values to PPC, IXP, and I386 when these are not set on the
#  command line or from the environment.  These control which architectures
#  for which library is to be built.
#

PPC  ?= no
IXP  ?= no
I386 ?= yes

##############################################################################
#
#  Create SUBDIRS based on PPC, IXP, and I386
#

SUBDIRS =
ifeq ($(strip $(PPC)),yes)
SUBDIRS += ppc
endif
ifeq ($(strip $(IXP)),yes)
SUBDIRS += arm
endif
ifeq ($(strip $(I386)),yes)
SUBDIRS += i386
endif

##############################################################################
#
#  The Shell
#
SHELL = /bin/sh

##############################################################################

.PHONY : all install clean veryclean distclean


define submake
	for i in $(SUBDIRS); do \
	   if [ -f $$i/Makefile ]; then \
	      (cd $$i; ${MAKE} $@); \
	   fi \
	done
endef



all:
	@$(submake)

install:
	@$(submake)

clean:
	@$(submake)

veryclean:
	@$(submake)

distclean:
	@$(submake)


##############################################################################
#
#  Sanity check that we are not trying to simultaneously build and clean
#
ifeq ($(findstring all,$(MAKECMDGOALS)),all)            #  *all
ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)        #  *clean
$(error Cannot simultaneously build/install and clean)
endif
endif

##############################################################################
