SHELL = /bin/sh

# Copyright (C) 1996,1997,1998 W.H.Scholten
# Makefile for gsitest



# ------------------------------------------------------------------
#  DEBUGGING
# ------------------------------------------------------------------
#only try -Wall once in a while as it sucks for class headers
#COMPILE		= -Wall
#Selective debug: (you can enable debug in each separate file by
#uncommenting #define DEBUG before the #include "debug.h"):
COMPILE	= -g -DDEBUG -Wall


# ------------------------------------------------------------------
#  DEFINITIES
# ------------------------------------------------------------------
DD		= dd

SOUNDDEV	= /dev/dsp
MIXERDEV	= /dev/mixer
SOURCE		= .
DATA		= ./data

LIBS		= -lc

SOUNDDIR	= $(LIBDIR)/ldef/ldef-sounds


PRG=gsitest

CFLAGS=-DMIXERDEV=\"/dev/mixer\" -DDSPDEV=\"/dev/dsp\" -DBINDIR=\"/usr/games\"  -DSOUNDSERVER=\"gsi_server\"

#OPTIMIZE	:= $(OPTIMIZE) -s
#OPTIMIZE:=$(OPTIMIZE) -s -m386
#for smaller code on x86's

#OPTIMIZE=-O2 -fomit-frame-pointer -funroll-loops -m486
#OPTIMIZE=-O2 -fomit-frame-pointer -m486
OPTIMIZE=-O2 -fomit-frame-pointer

ALL_CFLAGS	= $(OPTIMIZE) $(COMPILE) $(CFLAGS)

INCLUDES = -I/usr/local/include -I../..

# ------------------------------------------------------------------
#  Targets
# ------------------------------------------------------------------
all:	gsitest

gsitest: main.o sound.o
	$(CC) $(ALL_CFLAGS) -o $(PRG) main.o sound.o -lc -lm -lncurses


install: utils installnow

installnow:

install.utils:
	cp $(UTILOBJS) /usr/local/bin

uninstall:

clean:
	rm -rf $(strip *~ $(SOURCE)/*~ $(SOURCE)/*.o core gsitest)

clean.utils:
	rm -rf $(strip *~ $(UTILOBJS) $(LANDSCAPEOBJ))


distclean: clean
	rm -f $(SOURCE)/TAGS
	rm -f $(BINTARFILE)
	rm -f $(strip $(UTILOBJS) $(LANDSCAPEOBJ))


mostlyclean:
	rm -rf *~ core $(PRG) $(SNDSERVER) $(SOURCEOBJS) $(SOUNDOBJ)

realclean: distclean


TAGS:
#	etags $(SOURCE)/*.c -o $(SOURCE)/TAGS
	etags $(SOURCE)/*.cc -o $(SOURCE)/TAGS

info:
	@echo "No documentation available (except for the man page)."

dvi:
	@echo "No documentation available (except for the man page)."

dist: distclean
	mkdir $(PRG)
	mkdir $(PRG)/$(SOURCE)
	mkdir $(PRG)/$(DATASRC)
	cp -dpf $(DISTFILES) $(PRG)
	for i in $(DISTDIRS) ; do cp -dpf $$i/* $(PRG)/$$i ; done
	tar -czf $(TARFILE) $(PRG)/*
	rm -rf $(PRG)

bindist: $(PRG)
	mv $(PRG) $(PRG).binary
	mkdir $(PRG)
	cp -dpf $(DISTFILES) $(PRG)
	rm -f $(PRG)/Makefile
	mv $(PRG)/Makefile.binary $(PRG)/Makefile
	mv $(PRG).binary $(PRG)/$(PRG)
	tar -czf $(BINTARFILE) $(PRG)/*
	mv $(PRG)/$(PRG) $(PRG).binary
	rm -rf $(PRG)
	mv $(PRG).binary $(PRG)



# ------------------------------------------------------------------
#  Implicit rules
# ------------------------------------------------------------------
# Compile C files to object files.
%.o: %.c
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) $(INCLUDES) -c -o $(addprefix $(dir $<), $(notdir $@)) $<

# Compile assembler files to object files.
%.s: %.c
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) $(INCLUDES) -S -o $(addprefix $(dir $<), $(notdir $@)) $<

# Compile C++ files to object files
%.o: %.cc
#	g++ $(ALL_CFLAGS) $(LDFLAGS) $(INCLUDES) -c -o $(addprefix $(dir $<), $(notdir $@)) $<

	$(CC) $(ALL_CFLAGS) $(LDFLAGS) $(INCLUDES) -c -o $(addprefix $(dir $<), $(notdir $@)) $<

%.c: %.bin
	utils/b2c  $< 8

#%.c_dat: %.bin
#	utils/b2c  $< 8
#	mv $< $<.c_dat

#	b2c  $< 8 > $(addprefix $(dir $<), $(notdir $@))


# ------------------------------------------------------------------
#  Secondary targets
# ------------------------------------------------------------------

# ------------------------------------------------------------------
#  Secondary targets compiled directly (no .o files)
# ------------------------------------------------------------------

# ------------------------------------------------------------------
#  Dependencies (not complete)
# ------------------------------------------------------------------

# DO NOT DELETE
