# $Id: Smakefile,v 3.2 1993/10/14 00:08:29 ppessi 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: Wed Oct 13 04:00:04 1993 ppessi
#

DEST = amitcp:

DEVICE      = agnet.run

MODNAME      = agnet
VERSION      = 4

INSTALL      = copy clone nopro all
MKDIR	     = Makedir

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     = NoOptimize DEBUG=SF #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 \
	       $(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: version 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 
agnet.o		: agnet.c agnet.h agnet_protos.h bases.h simplerexx.h 
device.o	: device.c agnet.h agnet_protos.h bases.h lrandom.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 


#
# Make a distribution version
#
DIST: 
	-$(MKDIR) $(DIST)
	copy $(CSOURCE) $(HEADERS) $(PROTOS) $(MISCS) to $(DIST)
	-$(MKDIR) $(DIST)/env
	copy $(CONFIGS) $(DIST)/env

#
# Bump agnet.device revision
#
version:
    -BumpRev $(VERSION) $(MODNAME)_rev

$(MODNAME)_rev.h: version

#
# Install to binary directory
#
install: all $(CONFIG) $(DEST)bin $(DEST)env/sana2
	$(INSTALL) $(DEVICE) $(DEST)bin/agnet 
	$(INSTALL) $(CONFIG) $(DEST)env/sana2

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

$(DEST)env/sana2: $(DEST)env
	-$(MKDIR) $@

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

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

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