/* $Id: Imakefile,v 3.50 1995/03/04 19:00:27 bert Exp $
 *
 * XPilot, a multiplayer gravity war game.  Copyright (C) 1991-95 by
 *
 *      Bjrn Stabell        (bjoerns@staff.cs.uit.no)
 *      Ken Ronny Schouten   (kenrsc@stud.cs.uit.no)
 *      Bert Gsbers         (bert@mc.bio.uva.nl)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#
# Imakefile - XPilot
#

##############################################################################
#
# This is where all installation changes are normally done:
#
PREFIX = /usr/local/games
INSTALLDIR = $(PREFIX)
BINDIR = $(PREFIX)
LIBDIR = $(PREFIX)/lib/xpilot

# Manual pages for games usually go to section 6.
MANEXT = 6
MANDIR = $(PREFIX)/man/man$(MANEXT)

# Uncomment the nroff line instead if your system does not have groff.
MANFILT = groff -Tlatin1 -man
#MANFILT = nroff -man

PROGRAMS = xpilot xpilots xp-replay
VERSION = 3.3.1
LOCALGURU = xpilot@cs.uit.no

/*
 * DEFS should be used for program specific defines.
 * Currently supported flags are:
 *
 *  LOG			- try to log every server start
 *  TURN_THRUST		- makes turning drain fuel and gives
 *			  you a nice spark...
 *  SILENT		- makes the server real silent.
 *  SERVER_SOUND	- sound support in the server only, not in the client.
 *  ERASE=1		- use a different, possible faster, frame
 *			  drawing technique which is not perfect yet.
 *			  It needs more work by a volunteer.
 *  SPARC_CMAP_HACK	- try the alternate colormap swapping code
 *			  that talks directly to the sparc hardware
 *			  Only makes sense together with -DERASE=1.
 *			  WARNING: WILL NOT WORK ON ANY OTHER HARDWARE
 *			  CAUTION: dangerous if you don't know
 *			  what it does and how it works.
 *			  It needs more work by a volunteer.
 *  JOYSTICK		- joystick support for Linux 1.0, needs joystick-0.7.
 *  PLOCKSERVER         - Use the plock(2) system call to lock the xpilots
 *			  server into memory, i.e. to inhibit paging/swapping.
 *			  This probably only makes sense in conjunction with
 *			  raising the priority of the server a little, which is
 *			  equivalent to reducing the nice value a few points.
 *			  Note that both require special system privileges.
 *			  Sofar this feature has only been tested on HP-UX.
 *
 * You should also set these appropriately (see config.h):
 *
 *  LOCALGURU		- define to the person in charge
 *			  of xpilot on this site.
 *  LIBDIR		- define to where you want the help-files etc.
 *			  (HELPFILE, MOTDFILE, LOGFILE, MAPDIR and TEXTUREDIR)
 */
DEFS = -DLOCALGURU=\"$(LOCALGURU)\"  -DLIBDIR=\"$(LIBDIR)/\"


/*
 * Imake should specify the right CC if set up reasonably, but if that does
 * not work, try one of these:
 *
 * If you are still unsuccessful, try modifying and using Makefile.orig
 * insted of this file.
 */
/* CC = cc -Aa -D_HPUX_SOURCE +FPD /* HPUX */
/* CC = gcc			/* SUNs with gcc */
/* CC = acc -fast		/* SUNs with acc */
/* CC = cc			/* SGI Indigo (see CCOPTIONS below!) */
/* CC = cc -std1 -non_shared	/* DEC/OSF1 V1.2 */
/* CC = c89			/* DEC/ULTRIX 4.2 with c89 compiler kit */
/* CC = gcc -D__STDC__		/* DEC/ULTRIX with gcc */
/* CC = gcc			/* 386BSD */
/* CC = cc			/* AIX */
/* CC = cc -Xa			/* Sequent's ANSI cc (Dynix/PTX 2 and up) */
/* CC = CC -D_HPUX_SOURCE -D__STDC__	/* HP (USG) C++ - too strict yet */
/*
 * People with ULTRIX having problems or solutions should
 * contact David Chatterton at: davidc@bruce.cs.monash.edu.au
 */


/*
 * CDEBUGFLAGS should specify optimalization or debug information (or both).
 * Try not defining anything first.
 */
/* CDEBUGFLAGS = -g				/* General debug flag */
/* CDEBUGFLAGS = -O				/* General optimize flag */
/* CDEBUGFLAGS = +O3 +FPD			/* HPUX cc optimize flags (no +ESlit) */
/* CDEBUGFLAGS = -g -z +w1			/* HPUX cc debug flags */
/* CDEBUGFLAGS = -g2 -O2			/* SGI debug */
/* CDEBUGFLAGS = -O2				/* SGI optimize */
/* CDEBUGFLAGS = -O -Hfsingle -w		/* AIX on a 3090 Mainframe */
/* CDEBUGFLAGS = -O2 -fstrength-reduce		/* gcc optimize flags */
/* CDEBUGFLAGS = -Wc,-O3			/* Dynix/PTX 2 flags */


/*
 * If you're using Solaris CMW, you'll have to use Makefile.std or
 * tweak the Imakefile.  If you add support for CMW in the Imakefile,
 * drop us a mail, eh? :)
 */

/*
 * For sound support, you must uncomment either one of these
 * following lines and customize the paths
 */
/* #define NCD_SOUND			/* Uncomment for NCD sound support */
NCDAUDIOINC = -I/usr/local/include
NCDAUDIOLIB = -L/usr/local/lib -laudio

/* #define RPLAY_SOUND			/* Uncomment for rplay sound support */
RPLAYAUDIOINC = -I/usr/local/include
RPLAYAUDIOLIB = -L/usr/local/lib/rplay -lrplay

/* #define AF_SOUND			/* Uncomment for AF sound support */
AFAUDIOINC = -I/usr/include/AF
AFAUDIOLIB = -lAF -lAFUtil

/* Note that this doesn't really work well.  Dunno why.  Blame Alib & Aserver. */
/* #define HP_SOUND			/* Uncomment for HP sound support */
HPAUDIOINC = 
HPAUDIOLIB = -lAlib

/*
 * Miscellaneous.
 * SGI users must select their CCOPTIONS here.
 */
/* STRDUP_OBJ = strdup.o		/* Uncomment if you lack strdup() */
/* STRCASECMP_OBJ = strcasecmp.o	/* Uncomment if you lack strcasecmp()*/
/* CCOPTIONS = -I/usr/local/include	/* You might need this one */
/* CCOPTIONS = -xansi -prototypes -D__STDC__	/* For SGI (needed!) SGI */

/* TOP_INCLUDES =			/* Sun users with GCC need this */
/* EXTRALIB = -ldnet_stub		/* DEC/OSF1 DECnet library required */
/* EXTRALIB = -lsocket -lnsl		/* Solaris needs these */
/* EXTRALIB =				/* normal */

/* Don't need Xext.  So kill it since some people have it badly installed. */
EXTENSIONLIB =

############### DO NOT TOUCH ANYTHING BELOW THIS LINE #####################

/*
 * Sound part
 */
#if defined(NCD_SOUND)
  AUDIOINC = $(NCDAUDIOINC)
  AUDIOLIB = $(NCDAUDIOLIB)
  AUDIOSRC = ncdaudio.c
  AUDIOOBJ = ncdaudio.o
  DEFINES = $(DEFS) -DSOUND
#else
#if defined(RPLAY_SOUND)
  AUDIOINC = $(RPLAYAUDIOINC)
  AUDIOLIB = $(RPLAYAUDIOLIB)
  AUDIOSRC = rplayaudio.c
  AUDIOOBJ = rplayaudio.o
  DEFINES = $(DEFS) -DSOUND
#else
#if defined(AF_SOUND)
  AUDIOINC = $(AFAUDIOINC)
  AUDIOLIB = $(AFAUDIOLIB)
  AUDIOSRC = afaudio.c
  AUDIOOBJ = afaudio.o
  DEFINES = $(DEFS) -DSOUND
#else
#if defined(HP_SOUND)
  AUDIOINC = $(HPAUDIOINC)
  AUDIOLIB = $(HPAUDIOLIB)
  AUDIOSRC = hpaudio.c
  AUDIOOBJ = hpaudio.o
  DEFINES = $(DEFS) -DSOUND
#else
  AUDIOINC =
  AUDIOLIB =
  AUDIOSRC =
  AUDIOOBJ =
  DEFINES = $(DEFS)
#endif
#endif
#endif
#endif

INCLUDES = $(AUDIOINC)

/*
 * Now DEFINES and LOCAL_INCLUDES should've been set up properly.
 */

MATHLIB = -lm

#
# 'Server' program, xpilots, object and source files
#
OBJS1 = server.o event.o map.o math.o cmdline.o net.o netserver.o \
        play.o player.o rules.o update.o collision.o error.o frame.o \
        robot.o option.o socklib.o timer.o saudio.o \
        $(STRCASECMP_OBJ) $(STRDUP_OBJ)
SRCS1 = server.c event.c map.c math.c cmdline.c net.c netserver.c \
        play.c player.c rules.c update.c collision.c error.c frame.c \
        robot.c option.c socklib.c timer.c saudio.c
#
# Client program, xpilot...
#
OBJS2 = xpilot.o client.o join.o net.o netclient.o paint.o dbuff.o xinit.o \
        default.o math.o xevent.o syslimit.o error.o socklib.o caudio.o \
	widget.o configure.o usleep.o record.o texture.o xpmread.o \
	$(AUDIOOBJ) $(STRDUP_OBJ)
SRCS2 = xpilot.c client.c join.c net.c netclient.c paint.c dbuff.c xinit.c \
        default.c math.c xevent.c syslimit.c error.c socklib.c caudio.c \
	widget.c configure.c usleep.c record.c texture.c xpmread.c \
	$(AUDIOSRC)
#
# Playback program, xp-replay...
#
OBJS3 = xp-replay.o buttons.o
SRCS3 = xp-replay.c buttons.c

#
# Make handshake and server program
#
ComplexProgramTarget_1(xpilots, $(AUDIOLIB), $(MATHLIB) $(EXTRALIB))
ComplexProgramTarget_2(xpilot,  $(AUDIOLIB) $(XLIB), $(MATHLIB) $(EXTRALIB))
ComplexProgramTarget_3(xp-replay,  $(XLIB), $(MATHLIB))

#
# Install the rest.
#
install::
	@for prog in $(PROGRAMS); do \
	    if [ -r $(BINDIR)/$$prog-$(VERSION) ]; then \
		rm -f $(BINDIR)/$$prog-$(VERSION); \
	    fi; \
	    ( set -x ; ln $(BINDIR)/$$prog $(BINDIR)/$$prog-$(VERSION) ) \
	done
	@cd ../man6; for manpage in xpilot xpilots; do \
	    ( set -x ; $(MANFILT) <$$manpage.6 >$(MANDIR)/$$manpage.$(MANEXT) ) \
	done
	$(MKDIRHIER) $(LIBDIR)/maps;
	$(MKDIRHIER) $(LIBDIR)/textures;
	@cd ../lib; for libfile in *; do \
	    if [ -f $$libfile ]; then \
		( rm -f $(LIBDIR)/$$libfile; \
		  set -x; \
		  $(INSTALL) -c $(INSTDATFLAGS) $$libfile $(LIBDIR) ) \
	    fi \
	done
	@cd ../lib/maps; for mapfile in *; do \
	    ( rm -f $(LIBDIR)/maps/$$mapfile; \
	      set -x; \
	      $(INSTALL) -c $(INSTDATFLAGS) $$mapfile $(LIBDIR)/maps ) \
	done
	@cd ../lib/textures; for texturefile in *; do \
	    ( rm -f $(LIBDIR)/textures/$$texturefile; \
	      set -x; \
	      $(INSTALL) -c $(INSTDATFLAGS) $$texturefile $(LIBDIR)/textures ) \
	done

#
# Special rules
#
etags::
	etags -t *.[chips]

# Last line?
