# Copyright (c) 1986  Stanley T. Shebs, University of Utah.
# This program may be used, copied, modified, and redistributed freely
# for noncommercial purposes, so long as this notice remains intact.

# RCS $Header: Makefile,v 1.2 88/06/21 12:31:56 shebs Locked $

#CC = /usr/public/bin/gnu/gcc -O -fstrength-reduce -finline-functions
# Where xconq itself lives.

DESTDIR = /sic/X11/bin/contrib

# Set this for wherever the library directory should be.

LIBDIR = /sic/X11/lib/x11conq

# Set this for wherever the man page should live.

MANDIR = /sic/X11/man/man6

# Set this to be whatever versions you want built by default.

VERSIONS = x11conq

# Everbody loves to name their libraries differently - alter as necessary.

X11LIB = -lX11

# Ditto for X font libraries.

XFONTPATH = /sic/X11/lib/fonts/misc

# This name sets the default period for xconq.  The standard period is based
# on WWII and thus most familiar, although it lacks realism for serious gamers.

PERIOD	= standard

# Complete lists of files.

MAINSRC = xconq.c init.c do.c move.c attack.c phases.c map.c \
	side.c unit.c order.c util.c input.c help.c period.c \
	ginit.c draw.c output.c mkmap.c play.c pinput.c \
	new_mplay.c mutil.c minit.c mproduce.c mvars.c

AUXSRC = per2c.c hexify.c $(PERIOD).c X11.c

INCLUDE = config.h misc.h side.h unit.h map.h dir.h period.h global.h version.h

# Non-interface-specific object files.

OBJ =	xconq.o init.o do.o move.o attack.o phases.o map.o mkmap.o \
	side.o unit.o order.o util.o input.o help.o period.o \
	ginit.o draw.o output.o $(PERIOD).o play.o \
	new_mplay.o mutil.o minit.o mproduce.o mvars.o

X11OBJ = X11.o Xgc.o X11draw_world.o pinput.o
X10OBJ = draw_world.o

# Optimization is pretty feeble, but do it anyway.
# ABATTACK -> attack unit within town
# LOTS_PLAYERS -> number of players > 7 -> doubles size of view array

CFLAGS = -g -DXCONQLIB=\"$(LIBDIR)\" -DABATTACK -DLOTS_PLAYERS -DTRANFER -DFRENCH

# Do it all.

all:	$(VERSIONS) xconq.doc custom.doc

# X11 xconq.

x11conq: $(OBJ) $(X11OBJ)
	$(CC) -o x11conq $(CFLAGS) $(OBJ) $(X11OBJ) $(X11LIB)

# There is always a default period compiled into the code.

$(PERIOD).c:	lib/$(PERIOD).per per2c
	./per2c <lib/$(PERIOD).per >$(PERIOD).c

# Support things.

per2c:	per2c.o period.o
	$(CC) -o per2c $(CFLAGS) per2c.o period.o

hexify:	hexify.o
	$(CC) -o hexify $(CFLAGS) hexify.o

xconq.doc:	xconq.ms
	nroff -ms xconq.ms >xconq.doc

custom.doc:	custom.ms
	nroff -ms custom.ms >custom.doc

# Installation requires programs in $(DESTDIR) and a library directory.
# Also, fonts might have to go in system's font directory.
# No standard place for formatted docs, you're on your own...

install: X11fonts $(LIBDIR)
	cp $(VERSIONS) $(DESTDIR)
	cp *.6 $(MANDIR)
#	cp lib/*.onx $(XFONTPATH)
#	cp *.doc xxx


$(LIBDIR): lib
	mkdir $(LIBDIR)
	- cp lib/* $(LIBDIR)

# Usual cleaning, and flushing of anything junk-like.

clean:
	rm -f per2c hexify *.o lint.out core

spotless:	clean
	rm -f *conq *.doc $(PERIOD).c

# Pretty output for your favorite fancy printer.

TROFFER = ptroff
PRINTER = lw

paper:
	$(TROFFER) -man -P$(PRINTER) *.6
	$(TROFFER) -ms  -P$(PRINTER) xconq.ms
	$(TROFFER) -ms  -P$(PRINTER) custom.ms

# Local hack to put all the stuff onto a machine that does rdist via crontab.
# This is very useful in a workstation environment.
# (This version assumes NFS - hack as appropriate.)

DISTER = /n/jaguar

rinstall:
	cp -p $(VERSIONS) $(DISTER)$(DESTDIR)
	cp -p lib/* $(DISTER)$(LIBDIR)
#	cp -p *.6 $(DISTER)$(MANDIR)
#	cp -p lib/*.onx $(DISTER)$(XFONTPATH)
#	cp -p lib/*.snf $(DISTER)$(XFONTPATH)
#	cp -p *.doc $(DISTER)xxx

# Use this to take care of the details that shar can't.

X10fonts:
	(cd lib;  sh ../uudfont.sh *.u)

X11fonts:    $(XFONTPATH)/x11conq_standard.snf $(XFONTPATH)/x11conq.snf
	cd ${XFONTPATH} ; mkfontdir
	xset fp rehash

$(XFONTPATH)/x11conq_standard.snf: lib/x11conq_standard.bdf
	bdftosnf lib/x11conq_standard.bdf > ${XFONTPATH}/x11conq_standard.snf
$(XFONTPATH)/x11conq.snf: lib/x11conq.bdf
	bdftosnf lib/x11conq.bdf > ${XFONTPATH}/x11conq.snf

# How the shar files were made.  This is complicated by the need to
# transmit X fonts - uuencoded for X10, bdf files for X11.

kit:
	(cd lib;  sh ../uuefont.sh *.onx;  rm -f *.onx *.snf)
	makekit README Makefile Xdefaults ToDo *.6 *.ms *.h *.c *.sh lib/*

# Tarify for sites that can FTP.

tar:
	tar cvf xconq.tar \
		README Makefile Xdefaults ToDo *.6 *.ms *.h *.c *.sh lib

# Lint needs option to increase working space.

lint:
	lint -n -Zn5000 $(MAINSRC) $(PERIOD).c >lint.out

# Billyuns and billyuns of .h dependencies.

xconq.o:  config.h misc.h period.h side.h unit.h global.h map.h version.h
init.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
do.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
mplay.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
move.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
attack.o:  config.h misc.h period.h side.h unit.h map.h global.h
phases.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
map.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
side.o:  config.h misc.h dir.h period.h side.h unit.h map.h
unit.o:  config.h misc.h period.h side.h unit.h map.h global.h
order.o:  config.h misc.h dir.h period.h side.h unit.h
util.o:  config.h misc.h dir.h
input.o:  config.h misc.h dir.h period.h side.h unit.h global.h
help.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
period.o:  config.h misc.h period.h unit.h
ginit.o:  config.h misc.h dir.h period.h side.h unit.h map.h global.h
draw.o:  config.h misc.h period.h side.h unit.h map.h
output.o:  config.h misc.h period.h side.h unit.h map.h global.h
mkmap.o:  config.h misc.h dir.h period.h map.h
per2c.o:  config.h misc.h period.h
hexify.o:  misc.h
X11.o:  config.h misc.h period.h side.h unit.h map.h X11.h
Xgc.o:  X11.h Xgc.h config.h misc.h side.h period.h
X11draw_world.o:  config.h misc.h side.h map.h X11.h
pinput.o:  config.h misc.h side.h X11.h
play.o:  config.h misc.h side.h X11.h
draw_world.o:  config.h misc.h side.h map.h
standard.o:  config.h period.h
