### choose the server options

#TARGET = c128
#TARGET = c64
#TARGET = vic20
#TARGET = pet3001
TARGET = pet4001

RAMEXP = none
#RAMEXP = piaexp	# the PIA-based expansion for the C64 and the 128
#RAMEXP = reuexp	# see also the actionreuplay definition in prserver.asm
#RAMEXP = piaexp | reuexp	# both of the above
#RAMEXP = pet96

#CABLE = prlink 	# the default 8-bit/4-bit cable
CABLE = prlink88	# the full 8-bit option of the Amiga cable
#CABLE = transnib	# the TransNib cable.  A 6-wire subset of the above.
#CABLE = pc64		# the 4-bit/4-bit PC64 cable
#CABLE = c64net 	# the 4-bit/2-bit 64NET cable (slow)

### choose the cable object for the clients (should correspond to the above)

## Amiga
CABLEOBJ = pramiga.o	# the Amiga cable
OPTIONS = -DPRLINK88	# allow full 8-bit transfer (Amiga only)
#OPTIONS = -DTRANSNIB	# use the TransNib cable (Amiga only)

## PC
#CABLEOBJ = prtrans8.o	# the 8-bit/4-bit cable
#CABLEOBJ = prtrans4.o	# the 4-bit/4-bit PC64 cable
#CABLEOBJ = prtrans2.o	# the 64NET cable (slow)
OPTIONS += -DDEFAULT_PORT=3	 # default printer port
#OPTIONS += -DDEFAULT_PORT=1	 # default printer port

## generic
OPTIONS += -DWRAP_AROUND	# allow address wraparound in prsave

### choose the compiler and flags

CC = gcc
CFLAGS = -Wall -O6 $(OPTIONS) $(OTHER)
#CFLAGS = -Wall -ggdb -O6 $(OPTIONS) $(OTHER)

TARGETS = prmain prload prsave prrfile prwfile prcart prsample prdisk
MAINOBJ = prload.o prsave.o prrfile.o prwfile.o prdisk.o prcart.o prsample.o \
	  petscii.o
PRTARGETS = prserver.prg prsample.prg prrfile.prg prwfile.prg prdisk.prg

all: $(TARGETS) prprgs

prmain: prmain.o $(MAINOBJ) $(CABLEOBJ)
	$(CC) $(LDFLAGS) -o $@ prmain.o $(MAINOBJ) $(CABLEOBJ)
	chown root $@
	chmod u+s $@

prload:
	ln -sf prmain $@

prsave:
	ln -sf prmain $@

prrfile:
	ln -sf prmain $@

prwfile:
	ln -sf prmain $@

prdisk:
	ln -sf prmain $@

prcart:
	ln -sf prmain $@

prsample:
	ln -sf prmain $@

prprgs: cleanchosen $(PRTARGETS)

prserver.prg: prserver.asm chosen.inc
	dasm prserver.asm -o$@

prsample.prg: prsample.asm chosen.inc
	dasm prsample.asm -o$@

prrfile.prg: prrfile.asm chosen.inc
	dasm prrfile.asm -o$@

prwfile.prg: prwfile.asm chosen.inc
	dasm prwfile.asm -o$@

prdisk.prg: prdisk.asm chosen.inc
	dasm prdisk.asm -o$@

chosen.inc:
	echo target = $(TARGET) >  chosen.inc
	echo ramexp = $(RAMEXP) >> chosen.inc
	echo cable  = $(CABLE)	>> chosen.inc

cleanchosen:
	rm -f chosen.inc

clean:
	rm -f *.o chosen.inc *.bak *.lst a.out

reallyclean: clean
	rm -f $(TARGETS) $(PRTARGETS)
