
# generic UNIX makefile
CC = gcc			# req. for linux
#CC = cc				# if you don't have gcc
# Configuration options:
#
# No.   Name            Incompatible with   Description
# (1)   -DSERVER        2                   disables cdb debugger (koth server 
#                                           version)
# (2)   -DGRAPHX        1                   enables platform specific core 
#                                           graphics
# (3)   -DKEYPRESS                          only for curses display on SysV:
#                                           enter cdb upon keypress (use if
#                                           Ctrl-C doesn't work)
# (4)   -DEXT94                             ICWS'94 + SEQ,SNE,NOP,*,{,}
# (5)   -DSMALLMEM                          16-bit addresses, less memory
# (6)   -DXWINGRAPHX    1                   X-Windows graphics (UNIX)
# (7)   -DPERMUTATE                         enables -P switch
# (8)   -DSDLGRAPHX     1                   SDL graphics (generic)
# (9)	-DQ2004			    	    ASW-- add QOP, QJZ, QJN QCN

DBG = -g -W -Wall -pg
#xwin
#CFLAGS = -O4 $(DBG) -DXWINGRAPHX -DEXT94 -DPERMUTATE -DQ2004 $(INC)

#-fomit-frame-pointer

#server
CFLAGS = -O4 $(DBG) -DSERVER -DEXT94 -DPERMUTATE -DQ2004 $(INC)

LFLAGS = -x 
# LIB = -lcurses -ltermlib		# enable this one for curses display

# LIB = -lvgagl -lvga			# enable this one for Linux/SVGA
#LIB = -L/usr/X11R6/lib -lX11		# enable this one for X11

#INC = `sdl-config --cflags`		# enable this one for SDL graphics
#LIB = `sdl-config --libs`		# enable this one for SDL graphics

#ASW -- this is very klunky

#server
LIB = -L../../libquantum-0.2.2-original -lquantum -static -lm

#xwin 
#LIB = -L/usr/X11R6/lib -lX11 -L../../libquantum-0.2.2-original -lquantum -static -lm

INC = -I../../libquantum-0.2.2-original/

SHELL = /bin/sh 

LIBTOOL = $(SHELL) ../../libquantum-0.2.2-original/libtool

EXESUFFIX=
.SUFFIXES: .o .c .c~ .man .doc .6
MAINFILE = pmars$(EXESUFFIX)

HEADER = global.h config.h asm.h sim.h rand.h 
OBJ1 = pmars.o asm.o eval.o disasm.o cdb.o sim.o pos.o rand.o 
OBJ2 = clparse.o global.o token.o 
OBJ3 = str_eng.o

all: flags $(MAINFILE)

flags:
	@echo Making $(MAINFILE) with compiler flags $(CFLAGS)

$(MAINFILE): $(OBJ1) $(OBJ2) $(OBJ3)
	@echo Linking $(MAINFILE)
	@$(LIBTOOL) $(CC) $(CFLAGS) -o $(MAINFILE) $(OBJ1) $(OBJ2) $(OBJ3) $(LIB)
#	@strip $(MAINFILE)
	@echo done

rand.o: rand.h

token.o asm.o disasm.o: asm.h

sim.o cdb.o pos.o disasm.o: sim.h

sim.o: curdisp.c uidisp.c sdldisp.c lnxdisp.c xwindisp.c

xwindisp.c: xwindisp.h pmarsicn.h

lnxdisp.c: lnxdisp.h

$(OBJ1) $(OBJ2) $(OBJ3): Makefile config.h global.h

.c.o:
	@echo Compiling $*.o 
	@$(CC) $(CFLAGS) -c $*.c

clean:
	rm -f $(OBJ1) $(OBJ2) $(OBJ3) core
