/*   CrossFire, A Multiplayer game for X-windows
 *
 *   $Id: Imakefile,v 1.13 1995/04/15 04:44:52 master Exp master $
 *
 *   Copyright (C) 1992 Frank Tore Johansen
 *
 *   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.
 *
 *   The author can be reached via e-mail to frankj@ifi.uio.no.
 */

#include "../config/crossfire.tmpl"

INCLUDES = -I../include $(RPLAY_INCDIR) $(EUTL_INCLUDES)

LOCAL_LIBRARIES = $(DLSYM) $(SOUND_LIBS) $(MALLOC_LIBS) -L../common \
	-lcross $(XPM_LIBS) $(XLIB) $(EUTL_LIBS)

/* I guess the make on OSF systems can handle constructs where the
 * variable is being set to itself?  Gnu make and sun make can't seem
 * to.
 */

#ifdef OSFArchitecture
LOCAL_LIBRARIES = $(LOCAL_LIBRARIES) -lbsd
TARGET = -Dosf1
#endif

DEFINES = -DFONTDIR=\"${FONTDIR}\" -DFONTNAME=\"$(FONTNAME)\" $(TARGET) \
	-DLIBDIR=\"$(C_LIBDIR)\" $(COMPRESS_DEF)



OBJS = \
	apply.o\
	attack.o\
	ban.o\
	c_bind.o\
	c_chat.o\
	c_misc.o\
	c_move.o\
	c_new.o\
	c_object.o\
	c_party.o\
	c_wiz.o\
	commands.o\
	daemon.o\
	egoitem.o \
	encounter.o\
	ericserver.o\
	hiscore.o\
	init.o\
	input.o\
	login.o\
	main.o\
	monster.o\
	move.o\
	newitem.o\
	obwin.o\
	pets.o\
	player.o\
	resurrection.o\
	rune.o\
	shop.o\
	socket.o\
	sounds.o\
	spell_effect.o\
	spell_util.o\
	swamp.o\
	swap.o\
	thief.o\
	time.o\
	xio.o

SRCS = $(OBJS:.o=.c)

PROGRAMS = crossfire

DEPLIBS = ../common/libcross.a

AllTarget(crossfire)
DependTarget()
NormalProgramTarget(crossfire, $(OBJS),$(DEPLIBS), $(LOCAL_LIBRARIES), )
InstallProgram(crossfire,$(C_BINDIR))

install_dirs:
	test -d $(C_BINDIR) || mkdir $(C_BINDIR)

$(C_BINDIR)/crossfire: crossfire
	cp crossfire $(C_BINDIR) /* $(CP) == install, but I don't want strip */
	@sleep 1
	@touch $(C_BINDIR)/crossfire

install_bin: install_dirs $(C_BINDIR)/crossfire

../common/libcross.a:
	(cd ../common; $(MAKE) $(MFLAGS) all)

clean:: distclean

cvsclean:: distclean
	$(RM) Makefile

distclean::
	$(RM) crossfire $(OBJS) Makefile.bak

proto:
	cextract +p -P -I$(INCROOT) $(INCLUDES) -DDEBUG -DXpm_Pix -DLONGJUMP \
		-DStupidSunHeaders -DSOUND_EFFECTS -DDEBUG_MALLOC_LEVEL=1 \
		-I/usr/local/lib/gcc-include -cpp-program="gcc -E -C" \
		$(SRCS)  >../include/sproto.h.bak
	sed -e "s/#if __STDC__/#ifdef __STDC__/" < ../include/sproto.h.bak > ../include/sproto.h
	chmod 644 ../include/sproto.h
	$(RM) ../include/sproto.h.bak

InsertArchive(Imakefile $(SRCS),server)

/*
 * ifi: is just something I use locally to reinstall crossfire on a system
 * which connects several architectures via NFS.
 */

ifi: crossfire install_bin
	$(RM) crossfire
	chmod 2755 $(C_BINDIR)/crossfire
	test -d $(C_BINDIR)/$(HOSTTYPE) || mkdir $(C_BINDIR)/$(HOSTTYPE)
	$(RM) $(C_BINDIR)/$(HOSTTYPE)/last
	date +%d-%H-%M > $(C_BINDIR)/$(HOSTTYPE)/last
	$(MV) $(C_BINDIR)/crossfire $(C_BINDIR)/$(HOSTTYPE)/crossfire.`cat $(C_BINDIR)/$(HOSTTYPE)/last`

relink: force
	$(RM) crossfire
	(cd ../common; make)
	$(MAKE) all

force:
