BINDIR = /usr/local/games
PAD = # -DUSE_PAD
CHMOD = /bin/chmod
MKDIR = /bin/mkdir

CC = gcc
REGULATE_TIMER = -DREG_TIMER
DATADIR = $(BINDIR)/cosmodir
DATAFILE = $(DATADIR)/best.dat
PROTO_DEFINES = -DRANK_FILE=\"$(DATAFILE)\" $(PAD) $(REGULATE_TIMER) $(SIGNAL)
CDEBUGFLAGS = -O2 # -g
LOCAL_LIBRARIES = $(XLIB)
TAR = /bin/tar

SRCS = main.c animation.c cosmo.c ex.c pixmap.c score.c setup.c tiff.c timer.c title.c pad.c
OBJS = $(SRCS:.c=.o)

ComplexProgramTarget(cosmo)

hd: hd.c
	$(CC) -o hd hd.c
pixmap.o: chara.h pixmap.c
chara.h: hd chara.dat
	echo 'unsigned char cdata[] = {' > chara.h
	./hd chara.dat                  >> chara.h
	echo '0x00 };'                  >> chara.h

install::
	@if [ -d $(DATADIR) ]; then echo cosmodir exists, not created.;\
	 else $(MKDIR) $(DATADIR); fi
	$(CHMOD) 711 $(DATADIR)
	@if [ -f $(DATAFILE) ]; then echo ranking file exists, not created.;\
	 else echo > $(DATAFILE); fi
	$(CHMOD) 666 $(DATAFILE)

pack::
	$(TAR) cfz cosmo.tgz *.c *.h Imakefile chara.dat *.doc

clean::
	$(RM) hd chara.h
