#
# 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) 1998 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 mark@pyramid.com



LOCAL_LIBRARIES = 


SRCS =	random_map.c \
	room_gen_onion.c \
        room_gen_spiral.c \
	maze_gen.c \
	reader.c \
	floor.c \
	wall.c \
	monster.c \
	door.c \
	decor.c \
	exit.c \
	treasure.c \
	special.c \
	style.c  \
	rogue_layout.c \
        snake.c \
        square_spiral.c \
	expand2x.c

ALLFILES = $(SRCS) reader.l Makefile.in maze_gen.h random_map.h room_gen.h\
	standalone.c rproto.h expand2x.h

DEPEND = @DEPEND@

SED = @SED@

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

EXTRA_CFLAGS = -Wall


CFLAGS = @CFLAGS@ $(EXTRA_CFLAGS)

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

LIBS = -L../common -lcross @LIBS@ $(EXTRA_LIBS)

SHELL = @BOURNE_SHELL@

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

INSTALL = @INSTALL@

MKDIR = @MKDIR@
CC = @CC@
RM = @RM@
FLEX = @LEX@
AR = @AR@

random_map: $(OBJS) 
	$(RM) -f $@
	$(CC) $(CFLAGS) $(INCLUDES) -c standalone.c
	$(CC) -o $@ $(OBJS) standalone.o  $(LIBS) 

random_map.a: $(OBJS)
	$(RM) -f $@
	$(AR) clq $@ $(OBJS)


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

proto:
	cextract +p -P $(INCLUDES)  \
		-cpp-program="gcc -E -C" \
		$(SRCS)  > rproto.h.bak
	$(SED) -e "s/#if __STDC__/#ifdef __STDC__/" -e "s/__signed/signed/g" -e "/__inline/d" -e "/YY_BUFFER/d" < rproto.h.bak >rproto.h
	chmod 644 rproto.h
	$(RM) -f rproto.h.bak

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

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

distclean:: clean
	$(RM) -f Makefile random_map.a standalone.o

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

reader.c: reader.l
	$(FLEX) -Prmap -i -t reader.l > reader.c
#	sed -e s/yy/YY/g /tmp/reader.c > reader.c

all: random_map random_map.a

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

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



