# COOL MS-DOS Borland C++ 3.1 Makefile
# 1992 Sep    Jam    created

# I had to add some special OPTIONS because of Borland bugs:
#-O-i is because "inlining intrinsics" optimization defines some <string.h>
#  functions as macros; ANSI C++ will require they be inlines for overloading
#-w-sig is to remove "conversion may lose sig. digs" warnings
#  they're caused by 'long' array indexes
#-w-amp is to remove "superfolous & when taking address of function" warnings;
#  silly warning
#-w-amb is to remove "ambiguous operators need parens" warnings;
#  too common in C++ because of "cout << 1+2"
#-w-cln is to remove "constant is long" warnings;
#  too common in COOL code, besides, I just want to know when assigned to int
#-DDBLRET_HACK is because of bug when using a double return value immediately
#  in an expression (rounding error) -- you must assing it to a temporary

OPTIONS=-O-i -DDBLRET_HACK -w-amp -w-sig -w-amb -w-cln $(OPTIONS)

#  The .objs before "base_vec" do not need templates.
#  Code using List apparently needs -vi- to workaround a BC++ bug.
#  The code in Random.C has some bugs probably because it assumes 32-bit ints.
#  BaseBinary_Node was renamed base_bnn and BaseBinary_Tree was renamed
#     base_bnt.  A file base_bin.h was created which #includes both
#     headers so that code is portable from MS-DOS to UNIX filesystems.

OBJFILES=\
   test.obj \
   char.obj \
   string.obj \
   regexp.obj \
   gen_stri.obj \
   bit_set.obj \
   bit_tabl.obj \
   random.obj \
   complex.obj \
   bignum.obj \
   rational.obj \
   timer.obj \
   date_tim.obj \
   calendar.obj \
   timezone.obj \
   country.obj \
   base_vec.obj \
   vector.obj \
   base_lis.obj \
   list.obj \
   pair.obj \
   base_m_v.obj \
   base_has.obj \
   hash_tab.obj \
   associat.obj \
   value.obj \
   property.obj \
   n_node.obj \
   d_node.obj \
   nt_state.obj \
   n_tree.obj \
   base_bnn.obj \
   base_bnt.obj \
   binary_n.obj \
   binary_t.obj \
   m_vector.obj \
   base_mat.obj \
   matrix.obj \
   quaterni.obj \
   base_sta.obj \
   stack.obj \
   base_que.obj \
   queue.obj \
   set.obj \

LIBNAME=cool

# Directory to put .objs -- it should be a subdirectory of this directory
OBJDIR=objs
.path.obj=$(OBJDIR)

CC=bcc
LINK=tlink
TLIB=tlib
INCDIR=c:\borlandc\include;..;.
LIBDIR=c:\borlandc\lib

MODEL=l
!if $(DEBUGGING)
OPTIONS=-v $(OPTIONS)
!else
OPTIONS=-O2 $(OPTIONS)
!endif

$(LIBNAME).lib: $(LIBNAME).rsp turboc.cfg $(OBJFILES)
   $(TLIB) $(LIBNAME).lib @$(LIBNAME).rsp

# Does every BC++ installation have 'makersp.exe'?
$(LIBNAME).rsp: makefile
   makersp "+- $(OBJDIR)\\\\%s " &&!
   $(OBJFILES)
! > $(LIBNAME).rsp

all.out:
   make $(LIBNAME).lib > all.out
   cd tests
   make runall.out >> ..\all.out
   cd ..\examples
   make runall.out >> ..\all.out
   cd ..

.C.obj:
   $(CC) -c -P $(OPTIONS) { $< }

turboc.cfg: makefile
   echo -m$(MODEL) -w -d -n$(OBJDIR) -I$(INCDIR) > turboc.cfg

$(LIBNAME).zip:
   cd ..
   pkzip -a -r -P $(LIBNAME) cool\*.*
   cd cool

clean:
   - del objs\*.obj
   - del examples\*.err
   - del examples\*.obj
   - del examples\*.exe
   - del examples\*.out
   - del tests\*.err
   - del tests\*.obj
   - del tests\*.exe
   - del tests\*.out
   - del *.lib
   - del *.out
