# Makefile                                                                #
# ----------------------------------------------------------------------- #
# Compendium - C++ Container Class Library                                #
# Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved          #
# ----------------------------------------------------------------------- #
# Makefile for cm library.  (Builds for all memory models and win32).     #
#                                                                         #
# Usage: make              - Builds CML.LIB for large memory model        #
#                                                                         #
#        make -DMDL=x      - Builds CMx.LIB for specific model            #
#                            (small, compact, medium, large, huge, win32) #
#                            where x can be s, c, m, l, h, or 32          #
#                                                                         #
#        make all          - Builds CMx.LIB for all memory models         #
#                                                                         #
#        make dirs         - Creates object directories                   #
#                                                                         #
#        make clean        - Removes all object and library files.        #
# ----------------------------------------------------------------------- #

.AUTODEPEND
.SWAP

!if !$d(MDL)
MDL = l
!endif

LIBRARY = cm
INCDIR  = ..\..

.PATH.c   = $(INCDIR)\$(LIBRARY)\source
.PATH.cpp = $(INCDIR)\$(LIBRARY)\source
.PATH.obj = $(INCDIR)\$(LIBRARY)\lib\$(MDL)

LIB = $(LIBRARY)$(MDL).LIB

DEBUG   =
OPT     = -Ox
DEFINES =
FILES   = \
+cmarray.cpp \
+cmassoc.cpp \
+cmbag.cpp \
+cmbdict.cpp \
+cmbintr.cpp \
+cmbtree.cpp \
+cmcont.cpp \
+cmdate.cpp \
+cmdeque.cpp \
+cmhash.cpp \
+cmhdict.cpp \
+cmiter.cpp \
+cmlist.cpp \
+cmobject.cpp \
+cmobjref.cpp \
+cmordarr.cpp \
+cmqueue.cpp \
+cmreserv.cpp \
+cmresfil.cpp \
+cmring.cpp \
+cmset.cpp \
+cmstack.cpp \
+cmstring.cpp \
+cmtime.cpp \
+cmtokens.cpp

SOURCE=$(FILES:+=)
OBJS=$(SOURCE:.cpp=.obj)
LIBOBJS=$(FILES:.cpp=.obj)

!if $(MDL) == "32"
CFLAGS = -c $(DEFINES) $(DEBUG) $(OPT) -n$(.PATH.obj)
CC     = BCC32
!else
CFLAGS = -c -m$(MDL) $(DEFINES) $(DEBUG) $(OPT) -n$(.PATH.obj)
CC     = BCC
!endif

$(LIB)	: $(OBJS)
	!if exist $(LIB) DEL $(LIB)
	CD $(.PATH.obj)
	TLIB /C /0 ..\$(LIB) @&&!
	$(LIBOBJS)
!
	CD ..

.cpp.obj:
	$(CC) $(CFLAGS) -I$(INCDIR) {$* }

dirs:
	-for %m in (s c m l h 32) do md %m
 
clean:
	-for %m in (s c m l h 32) do del %m\*.obj
	DEL *.LIB

all:
	for %m in (s c m l h 32) do make -DMDL=%m
