# $Id: Smakefile,v 4.4 1994/05/12 15:22:58 jraja Exp $
#
# Smakefile for agnet.device
#
# Author: ppessi <Pekka.Pessi@hut.fi>
#
# Copyright  1992, 1993 Pekka Pessi
# Copyright  1992 Commodore-Amiga, Inc.
#
# Created      : Thu Jan 21 16:21:09 1993 ppessi
# Last modified: Thu May 12 17:23:11 1994 jraja
#

DEST = amitcp:

DEVICE      = agnet.run

MODNAME      = agnet
VERSION      = 4

INSTALL      = copy clone nopro all
MKDIR	     = Makedir
RCSREV       = rcsrev 

CC	     = SC

#
# DEF="RCS_ID_C=//" if you do not want RCS idents
#
DEFS         = DEF="RCS_ID_C=static char *rcsid" \
               DEF="RCS_ID=//char " \
               DEF=AGREXX
#
# `smake OPTFLAGS=optimize' when you want optimized code
#
OPTFLAGS     = Optimize NoDebug
DEBUGFLAGS   = NoOptimize DEBUG=SF

CFLAGS	     = Data=Far NoSTKCHK Parms=Reg NMInc \
	       STRMerge STREq MCCons ComNest UnSChar NoErrHigh \
	       Ignore=88 NoVersion \
	       OptTime OptInLocal \
 	       OptimizerComplexity=5 \
	       OptimizerDepth=5 \
	       OptimizerRecurdepth=5 \
	       IDIR=netinclude: \
	       $(OPTFLAGS) \
	       $(DEFS)

AS 	     = SC
AFLAGS       = IDIR=include: #-csy -i include: -o

LD           = SC link
LDFLAGS      = NOSTARTUP SMALLCODE SMALLDATA MAP MXREF

STRIPFLAGS   = ND NOICONS

CSOURCE      = init.c agnet.c device.c simplerexx.c lrandom.c
HEADERS      = agnet.h bases.h simplerexx.h lrandom.h

MISCS        = Smakefile agnet_rev.rev

CONFIG       = agnet0.config agnet1.config agnet2.config \
	       agnet4.config agnet5.config

STARTUP      =
OBJECTS      = init.o agnet.o device.o lrandom.o simplerexx.o

LIBS         = LIB:amiga.lib LIB:sc.lib

PROTOS       = agnet_protos.h

.SUFFIXES: .asm .c .o .test .run

all: SCOPTIONS $(DEVICE)

#
# Build the load files
#
.test.run:
		Slink $*.test TO $*.run $(STRIPFLAGS)

agnet.run:	agnet.test
agnet.test:	$(OBJECTS) $(LIBS)
		$(LD) $(STARTUP) $(OBJECTS) TO $@ LIB $(LIBS) $(LDFLAGS)

#
# Make the protos
#
protos:	$(CSOURCE) $(HEADERS)
	$(CC) $(CFLAGS) $(CSOURCE) GPROTOS

#
# Default rules...
#
.c.o:
    -@Delete FORCE QUIET $*.o
    $(CC) $*.c

.asm.o:
    $(AS) RESOPTS $*.asm $(AFLAGS)

#
# All dependencies
#
init.o		: init.c agnet.h $(MODNAME)_rev.h
agnet.o		: agnet.c agnet.h agnet_protos.h bases.h \
		  simplerexx.h $(MODNAME)_rev.h
device.o	: device.c agnet.h agnet_protos.h bases.h \
		  lrandom.h $(MODNAME)_rev.h
simplerexx.o 	: simplerexx.c  simplerexx.h
lrandom.o	: lrandom.c agnet.h lrandom.h

#
# Do not use some weird SCOPTIONS
#
SCOPTIONS: Smakefile
	copy TO $@ <FROM <
$(CFLAGS)
<

#
# Test programs
# (These are not included in the normal distribution)
#
test.o: test.c

writer.o: writer.c

test: test.o
	$(CC) LINK test.o TO test BATCH STANDARDIO

writer: writer.o
	$(CC) LINK writer.o to writer BATCH

rtest3.o: rtest3.c
rtest2.o: rtest2.c
rtest1.o: rtest1.c

rtest1: rtest1.o random-test.o
	$(CC) $(CFLAGS) LINK from rtest1.o random-test.o to rtest1 BATCH

rtest2: rtest2.o random-test.o
	$(CC) $(CFLAGS) LINK from rtest2.o random-test.o to rtest2 BATCH

rtest3: rtest3.o random-test.o
	$(CC) $(CFLAGS) LINK from rtest3.o random-test.o to rtest3 BATCH

random-test.o: random.c
	$(CC) $(CFLAGS) DEFINE=TEST random.c OBJNAME=random-test.o

#
# Get agnet.device revision
#
$(MODNAME)_rev.h:
	$(RCSREV) $(MODNAME) $(MODNAME).c
#
# Install to binary directory
#
install: all $(CONFIG) $(DEST)bin $(DEST)export/Env/Sana2
	$(INSTALL) $(DEVICE) $(DEST)bin/agnet
	$(INSTALL) $(CONFIG) $(DEST)export/Env/Sana2

$(DEST)bin:
	-$(MKDIR) $@

$(DEST)export/Env/Sana2: $(DEST)export/Env
	-$(MKDIR) $@

$(DEST)export/Env: $(DEST)export
	-$(MKDIR) $@

$(DEST)export:
	-$(MKDIR) $@

#
# Clean up directory
#
clean:
    -Delete $(OBJECTS)

cleaner: clean
    -Delete $(DEVICE) \#?.(map|lnk|o|test) SCOPTIONS
