#
# Makefile : BASEDIR Makefile for utilfuncs package. Main targets are 
#            - 'lib' for building utility functions library,
#            - 'tests' for building and running tests, and
#            usual clean and distclean.
#
# Copyright (C) 2006, Sandeep Kumar <shimple0@yahoo.com>
#                     Homepage : http://sandeepkumar.fortunecity.com/
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#

BASEDIR := $(PWD)
BUILDDIR := $(BASEDIR)/build

UTILLIB := $(BUILDDIR)/libutil.a
EXEEXT := .out

CC := gcc
AR := ar
RM := /bin/rm -f

export BASEDIR BUILDDIR UTILLIB EXEEXT CC AR

lib : checkdirs
	make -C $(BASEDIR)/src $(UTILLIB)

checkdirs :
	@if [ ! -d $(BASEDIR)/build ]; then mkdir -p $(BASEDIR)/build; fi

tests : lib
	@make -C $(BASEDIR)/tests tests

runtests : lib
	@make -C $(BASEDIR)/tests runtests

clean :
	$(RM) $(BUILDDIR)/*.o $(UTILLIB) $(BUILDDIR)/*$(EXEEXT)

distclean : clean
	rmdir $(BUILDDIR)
