# @(#)Makefile	1.34

# gcc is the only one that gets the PERFORMANCE :)
CC = gcc
CFLAGS = -O2
CFLAGS += -g -Wall 
CFLAGS += -Wlarger-than-10000
CFLAGS += -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align
CFLAGS += -Wwrite-strings -Waggregate-return
CFLAGS += -Wnested-externs -Winline
#CFLAGS += -Wid-clash-8 -Wtraditional -Wredundant-decls -Wshadow -Wconversion
CPPFLAGS=

all: pramsim.info pramsim

obj=core.o time.o net.o vars.o init.o simulate.o command.o \
    sysc.o disassemble.o stimu_fast.o stimu_slow.o


############################################################
# Machine
############################################################

# sparc only
CFLAGS += -msparclite
#CFLAGS += -msupersparc

# SunOS braindead headerfiles ...
#CPPFLAGS += -I/home/hirbli/ansi-includes


############################################################
# Features
############################################################

###### Shared mem host interface ########
# for testing the host program only
#ext_obj += /home/dst/pram/pram/src/pram_mem.o
#CPPFLAGS += -DMOD_DEV_MAPPING

###### External nettest #################
# for testing the hardware only
#clsp=/home/cls/pram/c/chiptest
#ext_obj += $(clsp)/dmamodule.o $(clsp)/netfinterface.o $(clsp)/nettest.o
#CPPFLAGS += -DMOD_EXTERN_NET

###### Benchmarking #####################
# benchmarking the simulator. not working
#obj += bench.o
#CPPFLAGS += -DMOD_BENCHMARK

###### Autonice feature #################
# nice -1 every hour
#CPPFLAGS += -DAUTONICE


############################################################
# Dependencies
############################################################
bench.o: bench.c processor.h prozflags.h commands.h glovars.h simul.h
command.o: command.c processor.h prozflags.h commands.h glovars.h simul.h \
  sim_cmds.h
core.o: core.c processor.h prozflags.h commands.h simul.h glovars.h net.h
disassemble.o: disassemble.c processor.h prozflags.h commands.h glovars.h \
  simul.h cmd_table.h
init.o: init.c init.h processor.h prozflags.h commands.h simul.h glovars.h net.h
net.o: net.c glovars.h processor.h prozflags.h commands.h simul.h net.h
simulate.o: simulate.c processor.h prozflags.h commands.h glovars.h simul.h
stimu_fast.o stimu_slow.o: stimu.c processor.h prozflags.h commands.h glovars.h simul.h net.h
sysc.o: sysc.c processor.h prozflags.h commands.h simul.h glovars.h
time.o: time.c
vars.o: vars.c glovars.h processor.h prozflags.h commands.h simul.h

stimu_fast.o: stimu.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -DFAST -o $@ -c stimu.c

stimu_slow.o: stimu.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c stimu.c

cmd_table.h: commands.h disassemble.c
	$(CC) -o gen_table -DBUILD_TABLE disassemble.c
	./gen_table > cmd_table.h
	rm -f gen_table

pramsim: $(obj)
	$(CC) -o pramsim $(obj) $(ext_obj) $(LDLIBS)

pramsim.o: $(obj)
	$(LD) -r -o pramsim.o $(obj)

clean:
	rm -f *.o pramsim gen_table cmd_table.h pramsim.tgz

tar:
	gtar cvhzf pramsim.tgz pramsim.texi README TODO Makefile *.c *.h

.SUFFIXES: .texi .texi~ .info

.texi.info:
	makeinfo $*.texi
