/*
 * Imakefile for cbzone
 *     Christopher Alexander North-Keys, Group Talisman, Sat 31 Jul 1993
 * predecessor was by:
 *     Todd Mummert, CMU, January 1991
 */
SRCS =  c_main.c \
        c_move.c \
        c_graphics.c \
        c_scores.c \
        c_gpr.c \
        c_parseopts.c \
        c_draw.c \
        c_explode.c

OBJS =  c_main.o \
        c_move.o \
        c_graphics.o \
        c_scores.o \
        c_gpr.o \
        c_parseopts.o \
        c_draw.o \
        c_explode.o

HDRS =  c_config.h \
        c_structs.h \
        c_defs.h \
        c_externs.h \
        c_colors.h \
        c_includes.h \
        PatchLevel.h

ETCS =  cbzone.help \
        cbzone.motd \
		cbzone.script \
		cbzone.highscores \
		Cbzone.ad

MISC =  Imakefile \
        Makefile.orig \
        INSTALL \
        ChangeLog \
        bitmaps

SOUNDS = sounds/enemy_seen.au \
         sounds/game_begin.au \
         sounds/game_end.au \
         sounds/move_blocked.au \
         sounds/object_explodes.au \
         sounds/salvo_fired.au \
         sounds/user_died.au \
         sounds/user_shoots.au

# this is where the shellscript, and executable will go
# TANK_BINDIR = $(BINDIR)
TANK_BINDIR= /usr/local/games

# this is where the scorefile and helpfile will go
# TANK_LIBDIR = $(LIBDIR)
TANK_LIBDIR = /usr/local/games/lib/cbzone

# this is where the app-defaults file will go
# TANK_APPDIR = $(XAPPLOADDIR)
TANK_APPDIR = $(TANK_LIBDIR)

# this is where the sound files go
TANK_SOUNDDIR = $(TANK_LIBDIR)/sounds

DEFINES = -DTANKDIR=\"$(TANK_LIBDIR)\"

LOCAL_LIBRARIES = $(XTOOLLIB) $(XLIB) -lm

AllTarget(cbzone.script)
AllTarget(cbzone.exec)
           
MakeDirectories(install,$(TANK_BINDIR) $(TANK_LIBDIR) $(TANK_APPDIR) $(TANK_SOUNDDIR))
InstallProgram(cbzone.exec,$(TANK_BINDIR))
InstallNamedProg(cbzone.script,cbzone,$(TANK_BINDIR))
InstallNonExec(cbzone.help,$(TANK_LIBDIR))
InstallNonExec(cbzone.motd,$(TANK_LIBDIR))
InstallNonExec(cbzone.highscores,$(TANK_LIBDIR))
InstallNamedNonExec(Cbzone.ad,Cbzone,$(TANK_APPDIR))
InstallMultiple($(SOUNDS),$(TANK_SOUNDDIR))

install::
	@if chgrp games $(TANK_BINDIR)/cbzone.exec $(TANK_LIBDIR)/cbzone.highscores 2>/dev/null ; then \
		(set -x ; chmod 2755 $(TANK_BINDIR)/cbzone.exec ) ; \
		(set -x ; chmod 664 $(TANK_LIBDIR)/cbzone.highscores ) ; \
	else \
		echo 'Failed: chgrp games for "cbzone.exec", "cbzone.highscores".' ; \
		echo '         highscore file exists but could not be protected.' ; \
		( set -x ; chmod 666 $(TANK_LIBDIR)/cbzone.highscores ) ; \
	fi

cbzone.highscores:
	touch $@
	chmod 664 $@

cbzone.exec: $(OBJS) $(DEPLIBS)
    RemoveTargetProgram($@)
    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)

cbzone.script : cbzone.script.src
	rm -f $@
	sed 's|@TANK_APPDIR@|$(TANK_APPDIR)|g;s|@TANK_LIBDIR@|$(TANK_LIBDIR)|g;s|@TANK_SOUNDDIR@|$(TANK_SOUNDDIR)|g' < $< > $@

clean::
	$(RM) cbzone.exec cbzone.script

tar: cbzone.tar.Z

cbzone.tar.Z:  $(SRCS) $(HDRS) $(ETCS) $(MISC) $(SOUNDS)
	rm -rf cbzone.tar cbzone.tar.Z
	tar -cf cbzone.tar $(SRCS) $(HDRS) $(ETCS) $(MISC) $(SOUNDS)
	compress cbzone.tar

#---------------------eof
