#
# @(#) Makefile for XTrojka
#
#
PROGS= xtrojka
XLIBS= -lXaw -lXmu -lXt -lX11 -lXext


#	your favorite C-compiler
#
CC=gcc
#CC=cc


#	your favorite packer 
#
COMPRESS=gzip -v9
#COMPRESS=compress


#	location of the highscorefile
#	Touch 'hiscore.c' and 'score_status_mgr.c' when you change
#	these variables!
#
HSFILE=/usr/local/games/lib/xtrojka.scores
#HSFILE=/tmp/xtrojka.scores
CFLAGS= -DSCOREFILE='"$(HSFILE)"' 

# add library search path
#
CFLAGS+=-L/usr/X11/lib

# on some systems you might add this line, because gcc starts wining
# about 'sizeof(Display)', since Display might be an empty struct;
#
CFLAGS+= -DSIZEOF_WINE

# 	locking (Interesting on network shared dir, but doesn't always work).
#
#CFLAGS += -DLOCKING


#	location of xtrojka game
#
TARGET_DIR=/usr/games


#	location of the manualpage
#
MANDIR=/usr/local/man/man6


#	please comment out for the system you use
#
#	sunos 4.1.3
XDIR=/usr/openwin/include
LIBS=-lm

# solaris
#XDIR=/usr/openwin/include
#LIBS=-lnsl

#
#
#	main
#
#
CFLAGS += -I$(XDIR)

SRCS= mainloop.c screen.c window.c redraw.c resource.c xtrojka.c scan.c \
	menu_mgr.c menu.c score_status_mgr.c hiscore.c prefs.c layout.c \
	actions.c
OBJS= mainloop.o screen.o window.o redraw.o resource.o xtrojka.o scan.o \
	menu_mgr.o menu.o score_status_mgr.o hiscore.o prefs.o layout.o	\
	actions.o
OTHER=Makefile *.h bitmaps COPYRIGHT README manpage stddef.h.FAKE


all: $(PROGS)

xtrojka: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(XLIBS) $(LIBS) -o xtrojka


#
#
tag:
	ctags $(SRCS)

#
#
tar:
	tar cvf xtrojka.tar  $(SRCS) $(OTHER)

#
#
tarz:
	tar cvf xtrojka.tar $(SRCS) $(OTHER);	\
	$(COMPRESS) xtrojka.tar

#
#
install:
	@echo $(HSFILE)|sed -e 's/\//\\\//g'>/tmp/hsn; \
	sed -e "s/__SCOREDIR__/`cat /tmp/hsn`/g" manpage > xtrojka.6; \
	cp xtrojka.6 $(MANDIR); chmod go+r xtrojka.6; \
	cp xtrojka $(TARGET_DIR);chmod go+rx xtrojka; \
	touch $(HSFILE); chmod go+rwx $(HSFILE);
	
clean:
	rm -rf *.o core xtrojka xtrojka.6 
	
#
#
#	dependencies
#
#
mainloop.o: xtrojka.h
screen.o: xtrojka.h screen.h resource.h
redraw.o: xtrojka.h screen.h resource.h
resource.o: xtrojka.h resource.h
xtrojka.o: xtrojka.h resource.h
scan.o: xtrojka.h
menu_mgr.o: menu.h
menu.o: menu.h
hiscore.o: hiscore.h 
score_status_mgr.o: hiscore.h resource.h
prefs.o: prefs.h xtrojka.h
window.o: xtrojka.h screen.h resource.h
layout.o: xtrojka.h screen.h
actions.o: xtrojka.h 


