# chris@alderan.sdata.de
# Makefile for GNU tar program for Microsoft's make
# if you don't want the aspi functions just remove the -DASPI from the
# DEFS line and the aspi.c and aspi.obj from LOCAL_SRC & LOCAL_OBJ
CC = cl
MODEL = M
DEFS = -nologo -DNONAMES -D__MSDOS__ -A$(MODEL) -DNO_REMOTE -DASPI
LIBS = $(MODEL)dir.lib
LINT = $(CC)
LINTFLAGS = -W3
DEF_AR_FILE = \"tar.out\"
# for the next line see the file ASPI.DOC
DEFAULT_TAPE_ID = \"0:4:0\"
DEFBLOCKING = 20
CFLAGS = $(COPTS) $(ALLDEFS)
ALLDEFS = $(DEFS) \
	-DDEF_AR_FILE=$(DEF_AR_FILE) \
	-DDEFBLOCKING=$(DEFBLOCKING)
COPTS = -Ox -G2s
OBJ1 =  tar.obj create.obj extract.obj buffer.obj getoldop.obj list.obj update.obj
OBJ2 =  version.obj names.obj diffarch.obj port.obj wildmat.obj getopt.obj getopt1.obj regex.obj
OBJ3 =  gnu.obj mangle.obj getdate.obj aspi.obj msd_dir.obj
OBJS =	$(OBJ1) $(OBJ2) $(OBJ3)

.c.obj:
        $(CC) $(CFLAGS) -c $*.c

tar.obj: tar.c regex.h tar.h port.h

create.obj: create.c tar.h port.h

extract.obj: extract.c tar.h port.h

buffer.obj: buffer.c rmt.h  tar.h port.h

getoldop.obj: getoldop.c tar.h port.h

list.obj: list.c tar.h port.h

update.obj: update.c tar.h port.h

version.obj: version.c tar.h port.h

names.obj: names.c tar.h port.h

diffarch.obj: diffarch.c tar.h port.h

port.obj: port.c tar.h port.h

wildmat.obj: wildmat.c tar.h port.h

getopt.obj: getopt.c tar.h port.h

getopt1.obj: getopt1.c tar.h port.h

regex.obj: regex.c tar.h regex.h

gnu.obj: gnu.c tar.h port.h

mangle.obj: mangle.c tar.h port.h

getdate.obj: getdate.c tar.h port.h

msd_dir.obj: msd_dir.c tar.h port.h

aspi.obj: aspi.c scsierr.h scsi.h aspi.h
	$(CC) -nologo $(COPTS) -A$(MODEL) -DTAPE_ID=$(DEFAULT_TAPE_ID) \
	-c aspi.c

scsi.obj: aspi.c scsierr.h scsi.h aspi.h
	$(CC) -nologo $(COPTS) -A$(MODEL) -DTAPE_ID=$(DEFAULT_TAPE_ID) \
	-DCTCTRL /Foscsi.obj -c aspi.c

ctctrl.obj: ctctrl.c scsi.h scsierr.h aspi.h

ctctrl.exe: getopt.obj ctctrl.obj scsi.obj
        $(CC) $(COPTS) $(LDFLAGS) -o ctctrl getopt.obj ctctrl.obj scsi.obj

tar.exe: $(OBJS)
        echo $(OBJ1) + >linkcmd
        echo $(OBJ2) + >> linkcmd
        echo $(OBJ3) >> linkcmd
        link @linkcmd, $@,,,, /NOI

all: tar.exe ctctrl.exe

clean:
    -del *.obj
    -del tar.exe
    -del tar.map
    -del ctctrl.exe
    -del ctctrl.map
