#
#  Copyright (C) 1993 Tito Flagella.
#
#  This file is part of the POSSO Customizable Memory Manager (CMM).
#
#  Permission to use, copy, and modify this software and its documentation is
#  hereby granted only under the following terms and conditions.  Both the
#  above copyright notice and this permission notice must appear in all copies
#  of the software, derivative works or modified versions, and any portions
#  thereof, and both notices must appear in supporting documentation.
# 
#  Users of this software agree to the terms and conditions set forth herein,
#  and agree to license at no charge to all parties under these terms and
#  conditions any derivative works or modified versions of this software.
#  
#  This software may be distributed (but not offered for sale or transferred
#  for compensation) to third parties, provided such third parties agree to
#  abide by the terms and conditions of this notice.  
#  
#  THE SOFTWARE IS PROVIDED "AS IS" AND THE COPYRIGHT HOLDERS DISCLAIM ALL
#  WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL THE COPYRIGHT HOLDERS
#  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
#  ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
#  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
#  OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
#  USER GUIDE
#  The most useful targets in this make file are:
#  "test"  compiles and runs all tests (listed in TESTS) reporting which
#        ones succeeded and which failed.
#  "clean"  removes all object code from this directory.
#  "demo1", "demo2" etc. run various demonstration programs.

SHELL	= /bin/sh
AR	= ar rv
CP	= copy
LN	= copy
RM	= del /q

CXXFLAGS = -O3 -DNDEBUG
CXXFLAGS = -DNDEBUG
CFLAGS   = -g -O -DNDEBUG
CC  = unicl
CXX = unicl
IncDir	 = $(ALDORROOT)\include
LibDir   = $(ALDORROOT)\lib
DocDir   = $(ALDORROOT)\share\doc
PossoDir = ..\posso

SRC = $(MAKEDIR)

CCFILES = cmm.cc tempheap.cc msw.cc 
CFILES = memory.c
HFILES = machine.h cmm.h tempheap.h msw.h
LibCmm = $(LibDir)\libcmm.a

O = (
C = )
OBJS = $(CCFILES:%.cc=$(LibCmm)$(O)%.obj$(C)) $(CFILES:%.c=$(LibCmm)$(O)%.obj$(C))

TESTS = test2    test3    test5    test6       testp5 

TSRC  = test2.cc test3.cc test5.cc test6.cc  \
	testp5.cc

MISCS = ChangeLog Copyright FileList Makefile Makefile.auto Makefile.dist \
	Makefile.schema Makefile.schema.orig README doc

OKFILES = $(CCFILES) $(CFILES) $(HFILES) $(TSRC) $(MISCS)


all: $(LibCmm)

junk:
	@ ls -d $(OKFILES) * | sort | grep -v CVS | uniq -u

clean:
	$(RM) *.obj $(TESTS) libCmm.a

test : ${TESTS}
	@$(RM) tests.out
	@for %%i in ($(TESTS)) do  ( 
	@	echo Running %%i ...
	@	%%i >> tests.out 
	@)

demo: demo1 demo2

samples:
	@cd doc 
	@$(MAKE) samples
	@cp Copyright $(DocDir)/cmm/Copyright

$(LibCmm): $(OBJS)
	rem doranlib $(LibCmm)

$(LibCmm)(cmm.obj): cmm.cc $(HFILES)
	cd $(LibDir) 
	echo "$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\cmm.cc" 
	$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\cmm.cc 
	$(LIB) /out:$(LibCmm) cmm.obj 
	$(RM) cmm.obj

$(LibCmm)(tempheap.obj): tempheap.cc tempheap.h $(HFILES)
	cd $(LibDir) 
	echo "$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\tempheap.cc" 
	$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\tempheap.cc 
	$(LIB) /out:$(LibCmm) tempheap.obj 
	$(RM) tempheap.obj

$(LibCmm)(msw.obj): msw.cc msw.h $(HFILES)
	cd $(LibDir) 
	echo "$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\msw.cc" 
	$(CXX) $(CXXFLAGS) -c -I$(IncDir) $SRC\msw.cc 
	$(LIB) /out:$(LibCmm) msw.obj 
	$(RM) msw.obj

$(LibCmm)(memory.obj): memory.c machine.h 
	cd $(LibDir) 
	echo "$(CC) $(CFLAGS) -c -I$(IncDir) $SRC/memory.c" 
	$(CC) $(CFLAGS) -c -I$(IncDir) $SRC\memory.c 
	$(LIB) /out:$(LibCmm) memory.obj 
	$(RM) memory.obj

test2:	test2.cc $(LibCmm)
	$(CXX) $(CXXFLAGS) -o test2 test2.cc $(LibCmm)
test3:	test3.cc $(LibCmm)
	$(CXX) $(CXXFLAGS) -o test3 test3.cc $(LibCmm)
test5:	test5.cc  $(LibCmm)
	$(CXX) $(CXXFLAGS) -o test5 test5.cc $(LibCmm) 
test6:	test6.cc  $(LibCmm)
	$(CXX) $(CXXFLAGS) -o test6 test6.cc $(LibCmm)
testp2: testp2.c $(LibCmm)
	${CC} ${CFLAGS} -g -o testp2 testp2.c $(LibCmm)
testp3: testp3.c $(LibCmm)
	${CC} ${CFLAGS} -g -o testp3 testp3.c $(LibCmm)
testp5: testp5.cc $(LibCmm)
	${CXX} ${OPTS} -o testp5 ${CXXFLAGS} testp5.cc  $(LibCmm)
demo1:	demo1.cc  $(LibCmm)
	$(CXX) $(CXXFLAGS) -o demo1 demo1.cc  $(LibCmm)
demo2:	demo2.cc  $(LibCmm)
	$(CXX) $(CXXFLAGS) -o demo2 demo2.cc  $(LibCmm)

