XCOMM =====================================================================
XCOMM Imakefile - XGalaga v1.6c - ogre@atomic.com - July 7, 1995
XCOMM =====================================================================

XCOMM This is the only line you should have to change.  the high scores
XCOMM file will be written in this directory, change SCOREFILE to put
XCOMM it somewhere else or change the name.  The sounds directory and
XCOMM sound server executable also reside here if sound is supported on
XCOMM your system.  If not doing "make install", set this to where the
XCOMM files are now.

    XGALAGADIR = /usr/games/xgalaga

    SCOREFILE    	= $(XGALAGADIR)/.xgalscores
    SOUNDDIR		= $(XGALAGADIR)/sounds

XCOMM You can get libXpm from ftp.x.org.  If it is already installed
XCOMM with the standard X libs, you shouldn't need to change this.
XCOMM otherwise make these point at wherever you put it.

    XPMLIB 		= -lXpm
    XPMINCLUDE 		= -I/usr/include/X11

    XSPRITELIB          = -L./libsprite -lXsprite

XCOMM Should be defined automatically for appropriate systems
XCOMM #define SOUND

XCOMM Or, if you prefer, you can define NAS_SOUND for network audio
XCOMM #define NAS_SOUND

XCOMM define NOSCOREHOGS to make the high scores only allow one global
XCOMM high score per user.  So if you're at a large site, and one guy
XCOMM is 10x better than everyone else, he will just have the #1 score
XCOMM instead of all 20.
XCOMM Note that if you are upgrading from an old version and want to use
XCOMM this option, you will have to delete your old global high score file.
XCOMM #define NOSCOREHOGS

XCOMM define REALNAME if you'd rather have real names (From the passwd file)
XCOMM be used for high scores (if you don't define it, you will be prompted
XCOMM for a name when you get a high score)
XCOMM #define REALNAME

XCOMM You should not have to change IMAGEDIR unless you rerun
XCOMM mkimgsrc and set it to not compile images in.  IE
XCOMM don't mess with this unless you know what it does.

    IMAGEDIR            = $(XGALAGADIR)/images

XCOMM use gcc if at all possible.  If you can't make sure you set this
XCOMM to an ANSI compiler!
    CC = gcc

XCOMM **** System specific preprocessor flags.  If yours isn't here,
XCOMM **** and you need something changed, tell me about it!

#if defined(LinuxArchitecture)
    SYSDEFS = -Wall
#if !defined(NAS_SOUND)
#define SOUND
XCOMM Uncomment the following line if you only have the PC speaker, AND sound doesn't work
XCOMM otherwise.  There is apparently a bug in recent kernels which makes the detection
XCOMM logic not work.  This fudges the sound server to always assume it's using the PC speaker.
XCOMM #define PCSP_ONLY
    SOUNDSERVER = xgal.sndsrv.linux
    SOUNDOBJS = sound.o
    SOUNDDEV = /dev/dsp
#endif
#endif

#if defined(AIXArchitecture)
    SYSDEFS = 
    SOUNDSERVER =
    SOUNDOBJS =
#endif

#if defined(HPArchitecture)
    CC = gcc
    CDEBUGFLAGS = -O2
    CCOPTIONS = -ansi
    SYSDEFS = -DUSE_LRAND48  -ansi
    SOUNDSERVER =
    SOUNDOBJS =
#endif

#if defined(SunArchitecture) && defined(SVR4Architecture)
    SYSDEFS = -DSOLARIS -DUSE_LRAND48
    SOUNDSERVER =
    SOUNDOBJS =
#else
#if defined(SunArchitecture)
    SYSDEFS =
#if !defined(NAS_SOUND)
#define SOUND
    SOUNDSERVER = xgal.sndsrv.sun
    SOUNDOBJS = sound.o
    SOUNDDEV = /dev/audio
#endif
#endif
#endif

#if defined(UltrixArchitecture)
    SYSDEFS = 
    SOUNDSERVER =
    SOUNDOBJS =
#endif

#if defined(SGIArchitecture)
    SYSDEFS = 
    SOUNDSERVER =
    SOUNDOBJS =
#endif

#if defined(FreeBSDArchitecture)
SYSDEFS = 
#if !defined(NAS_SOUND)
#define SOUND
SOUNDSERVER = xgal.sndsrv.freebsd
SOUNDOBJS = sound.o
SOUNDDEV = /dev/dsp
#endif
#endif

#XCOMM ***********************************************************
#XCOMM ---> You shouldn't need to change anything below this <----
#XCOMM ***********************************************************

    EXTRA_INCLS = $(XPMINCLUDE) 

#ifdef REALNAME
    NAMEDEF = -DUSE_REAL_NAMES
#else
    NAMEDEF =
#endif

#ifdef NOSCOREHOGS
    HOGDEF = -DNOSCOREHOGS
#else
    HOGDEF =
#endif

#ifdef PCSP_ONLY
	PCSPDEF = -DPCSP_ONLY=1
#else
	PCSPDEF = -DPCSP_ONLY=0
#endif

#ifndef SOUND
#ifndef NAS_SOUND
    DEFINES = $(EXTRA_INCLS) $(SYSDEFS) $(NAMEDEF) $(HOGDEF)\
        -DSCOREFILE=\"$(SCOREFILE)\" \
	-DIMAGEDIR=\"$(IMAGEDIR)\"
#else
    INSTALLSOUND = True

    NASLIB = -laudio

    SOUNDOBJS = nas_sound.o
	
    DEFINES = $(EXTRA_INCLS) $(SYSDEFS) -DSOUND -DNAS_SOUND $(NAMEDEF) $(HOGDEF)\
	-DSCOREFILE=\"$(SCOREFILE)\" \
	-DIMAGEDIR=\"$(IMAGEDIR)\" \
	-DSOUNDDIR=\"$(SOUNDDIR)\"
#endif
#else
    INSTALLSOUND = True

    DEFINES = $(EXTRA_INCLS) $(SYSDEFS) -DSOUND $(NAMEDEF) $(HOGDEF) $(PCSPDEF)\
	-DSCOREFILE=\"$(SCOREFILE)\" \
	-DIMAGEDIR=\"$(IMAGEDIR)\" \
	-DSOUNDSERVER=\"$(XGALAGADIR)/$(SOUNDSERVER)\" \
	-DSOUNDDIR=\"$(SOUNDDIR)\" \
	-DSOUNDDEV=\"$(SOUNDDEV)\"
#endif

    LOCAL_LIBRARIES = $(XSPRITELIB) $(XPMLIB) $(NASLIB) $(XLIB)  -lm

    DEPLIBS = $(DEPXLIB) libsprite/libXsprite.a

    OBJS1 = main.o images.o data.o paths.o title.o \
	explosions.o score.o highscore.o prize.o $(SOUNDOBJS)
    SRCS1 = `echo $(OBJS1) | sed -e 's/\.o/.c/g'`

    PROGRAMS = xgal

#define HasSubDirs YES
SUBDIRS       = libsprite
#define PassCDebugFlags "CC=$(CC)" "CDEBUGFLAGS=$(CDEBUGFLAGS)"
MakeSubdirs($(SUBDIRS))
MakefileSubdirs($(SUBDIRS))

ComplexProgramTarget_1($(PROGRAMS), $(LOCAL_LIBRARIES), )

#ifdef SOUND
NormalProgramTarget($(SOUNDSERVER), $(SOUNDSERVER).o,,,)
#endif

XCOMM libsprite/libXsprite.a:
XCOMM 	cd libsprite ; xmkmf ; make

#ifdef NAS_SOUND
install:: $(PROGRAMS) $(SOUNDSERVER)
	@echo "XGalaga directory is " $(XGALAGADIR)
	@:
	@echo "Creating directory " $(XGALAGADIR)
	@if [ ! -d $(XGALAGADIR) ]; then mkdir $(XGALAGADIR); fi
	@echo "Making an empty high score file"
	@touch $(SCOREFILE)
	@chmod a+rw $(SCOREFILE)
	@:
	@if [ "$(INSTALLSOUND)" = "True" ]; 				\
	 then								\
		echo "Creating directory " $(SOUNDDIR); 		\
		if [ ! -d $(SOUNDDIR) ]; then mkdir $(SOUNDDIR); fi;    \
		echo "Copying sound server to directory " $(SOUNDDIR); \
		$(INSTALL) -c -s $(INSTBINFLAGS) $(SOUNDSERVER) $(XGALAGADIR); \
		echo "Copying sound files into directory " $(SOUNDDIR); \
		cd ./sounds; set -x;					\
		for file in *.raw; do					\
		    auconvert -raw linu8 1 -rate 8000 $$file -file snd `basename $$file .raw`.au \
		    $(INSTALL) -c $(INSTDATFLAGS) `basename $$file .raw`.au $(SOUNDDIR);	\
		done;   						\
	 fi
#else
install:: $(PROGRAMS) $(SOUNDSERVER)
	@echo "XGalaga directory is " $(XGALAGADIR)
	@:
	@echo "Creating directory " $(XGALAGADIR)
	@if [ ! -d $(XGALAGADIR) ]; then mkdir $(XGALAGADIR); fi
	@echo "Making an empty high score file"
	@touch $(SCOREFILE)
	@chmod a+rw $(SCOREFILE)
	@:
	@if [ "$(INSTALLSOUND)" = "True" ]; 				\
	 then								\
		echo "Creating directory " $(SOUNDDIR); 		\
		if [ ! -d $(SOUNDDIR) ]; then mkdir $(SOUNDDIR); fi;    \
		echo "Copying sound server to directory " $(SOUNDDIR); \
		$(INSTALL) -c -s $(INSTBINFLAGS) $(SOUNDSERVER) $(XGALAGADIR); \
		echo "Copying sound files into directory " $(SOUNDDIR); \
		cd ./sounds; set -x;					\
		for file in *.raw; do					\
		    $(INSTALL) -c $(INSTDATFLAGS) $$file $(SOUNDDIR);	\
		done;   						\
	 fi
#endif

all:: $(SOUNDSERVER)

clean::
	cd libsprite ; make clean

dist:
	@make clean
	@rm -f $(EXE) TAGS core
	@makedepend
	@:
	cd .. ; tar czvf $(PROGRAMS).tar.gz $(PROGRAMS)/

proto:
	@cproto $(CDEFS) $(INCLUDEDIRS) $(SRCS) > proto.h

