#
#  METALBASE 5.1
#
#  Released January 1st, 1992 by Huan-Ti [ t-richj@microsoft.com ]
#
#  Generic makefile for 5.1 library and utilities
#
###############################################################################
#
# CFLAGS=
#    -DNO_VOIDPTR    -- Define if MB shouldn't use the type "void *"
#    -DNO_ENCRYPT    -- Define if MB shouldn't try to use encryption
#    -DNO_UCHAR      -- Define if MB shouldn't   typedef unsigned char uchar
#    -DNO_USHORT     -- Define if MB shouldn't   typedef unsigned short ushort
#    -DNO_ULONG      -- Define if MB shouldn't   typedef unsigned long ulong
#    -DNO_CHARPTR    -- Define if MB shouldn't   typedef char * charptr
#    -DNO_BOOL       -- Define if MB shouldn't   typedef char bool
#    -DNO_BYTE       -- Define if MB shouldn't   typedef uchar byte
#    -DNO_FILE       -- Define if MB shouldn't   typedef int file
#
#    -DLONGARGS      -- To produce new-style prototypes ("void fn(int)")
#    -DMSDOS         -- MS-DOS users should define this if their CC doesn't.
#
# LDOPTS=-f          -- To include floating point stuff for printf()
#
###############################################################################
#
# Update the makefile to include any options in CFLAGS that you may need; then
# just "make install"
#
# NOTE: This makefile is set up to use /usr/bin, /usr/lib and /usr/include --
#       change names in here or just use those directories, as you see fit.
#
###############################################################################

#EXEDIR=/usr/bin
#INCDIR=/usr/include
#LIBDIR=/usr/lib
EXEDIR=../bin
INCDIR=.
LIBDIR=../lib
LIB=libmb.a
CURSES=-lcurses -ltinfo
COPY=cp
CC=cc
LDOPTS=

CFLAGS= -DLONGARGS -DNO_ENCRYPT -DNO_TIMEB -I$(INCDIR) -Otcl

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

BUILD   = $(EXEDIR)/build
MBCONV  = $(EXEDIR)/mbconv
MBDIAG  = $(EXEDIR)/mbdiag
REPORT  = $(EXEDIR)/report
VR      = $(EXEDIR)/vr
LIBRARY = $(LIBDIR)/libmb.a

HEADERS=$(INCDIR)/stdinc.h $(INCDIR)/mbase.h $(INCDIR)/parse.h
TARGETS=$(BUILD) $(MBCONV) $(MBDIAG) $(REPORT) $(VR)

OBJS=mb_cache.o  mb_comp.o   mb_creat.o  mb_inc.o    mb_lock.o   mb_misc.o \
     mb_multi.o  mb_parse.o  mb_rmv.o    mb_time.o   mb_util.o

OTHOBJS=build.o mbconv.o mbdiag.o report.o vr.o input.o

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

ARCHIVE = ar rv $(LIBRARY)
RANLIB  = -ranlib $(LIBRARY)

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

all : $(HEADERS) $(TARGETS)
	

install : all
	@mailscr

$(INCDIR)/mbase.h : mbase.h
	$(COPY) mbase.h $(INCDIR)

$(INCDIR)/stdinc.h : stdinc.h
	$(COPY) stdinc.h $(INCDIR)

$(INCDIR)/parse.h : parse.h
	$(COPY) parse.h $(INCDIR)

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

$(BUILD)   : $(LIBRARY) build.o
	$(CC) $(LDOPTS) -o $@ build.o $(LIBRARY)

$(MBCONV)  : $(LIBRARY) mbconv.o
	$(CC) $(LDOPTS) -o $@ mbconv.o $(LIBRARY)

$(MBDIAG)  : $(LIBRARY) mbdiag.o
	$(CC) $(LDOPTS) -o $@ mbdiag.o $(LIBRARY)

$(REPORT)  : $(LIBRARY) report.o
	$(CC) $(LDOPTS) -o $@ report.o $(LIBRARY)

$(VR)      : $(LIBRARY) vr.o input.o
	$(CC) $(LDOPTS) -o $@ vr.o input.o $(LIBRARY) $(CURSES)

$(LIBRARY) : $(OBJS) $(OTHOBJS)
	$(ARCHIVE) $(OBJS)
	$(RANLIB)

