#
# Makefile for crossfire 0.95.0 and beyond
#
# This file will eventually be replaced by a configure script.  But for
# now, this simple makefile should do the job.
#
#   Copyright (C) 1992 Frank Tore Johansen
#   Copyright (C) 2001 Mark Wedel
#
#   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 mwedel@scruz.net


VPATH = @srcdir@
srcdir = @srcdir@

LOCAL_LIBRARIES = ../common/libcross.a ../random_maps/random_map.a ../socket/socket.a


SRCS = \
	alchemy.c\
	apply.c\
	attack.c\
	ban.c\
	c_chat.c\
	c_misc.c\
	c_move.c\
	c_new.c\
	c_object.c\
	c_party.c\
	c_range.c\
	c_wiz.c\
	commands.c\
	daemon.c\
	disease.c\
	egoitem.c \
	hiscore.c\
	gods.c\
	init.c\
	login.c\
	main.c\
	monster.c\
	move.c\
	pets.c\
	player.c\
	plugins.c\
	resurrection.c\
	rune.c\
	shop.c\
	skills.c\
	skill_util.c\
	spell_effect.c\
	spell_util.c\
	swamp.c\
	swap.c\
	time.c\
	timers.c\
	weather.c

ALLFILES = $(SRCS) Makefile.in

DEPEND = @DEPEND@

SED = @SED@

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

CFLAGS = @CFLAGS@ $(EXTRA_CFLAGS)

INCLUDES= $(EXTRA_INCLUDES) -I../include -I$(srcdir)/../include

LDFLAGS = @LDFLAGS@

LIBS = @LIBS@ $(EXTRA_LIBS)

SHELL = @BOURNE_SHELL@

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@

INSTALL = @INSTALL@

MKDIR = @MKDIR@
CC = @CC@
RM = @RM@

crossfire: $(OBJS) $(LOCAL_LIBRARIES)
	$(RM) -f $@
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LIBS)


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

../random_maps/random_map.a:
	(cd ../random_maps; $(MAKE) $(MFLAGS) all)

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

depend:
	$(DEPEND) $(DEPENDFLAGS) -- $(CFLAGS) $(INCLUDES) -I../include -- $(SRCS)

proto:
	cproto -D__CEXTRACT__ $(INCLUDES)  \
		$(SRCS)  >../include/sproto.h
	chmod 644 ../include/sproto.h

archive:
	@if [ ! -d $(ARCHIVE)/server ]; then $(MKDIR) $(ARCHIVE)/server; fi
	$(CP) $(ALLFILES) $(ARCHIVE)/server

clean::
	$(RM) -f crossfire $(OBJS) Makefile.bak

distclean:: clean
	$(RM) -f Makefile

.c.o:
	$(CC) $(CFLAGS) $(INCLUDES) -c $*.c

all: crossfire

patchlist::
	@echo $(SRCS) > .patchlist

install:: crossfire
	@if [ ! -d ${bindir} ]; then \
		$(MKDIR) -p ${bindir}; \
	fi
	$(INSTALL) crossfire ${bindir}/crossfire
