1stMUD4.0/bin/
1stMUD4.0/doc/MPDocs/
1stMUD4.0/player/
1stMUD4.0/win32/
1stMUD4.0/win32/rom/
MAKE    = @SET_MAKE@
DEP	= @MAKEDEP@
INSTALL = @INSTALL@
CC      = g++ # default: @CXX@
PROF    = -O -ggdb -pipe # default: @CXXFLAGS@
WARN    = -Wall -Werror
LIBS    = @LIBS@
SRC	= @srcdir@
VPATH   = @srcdir@
CONFIG	= config
BIN	= ../bin
HDIR	= h
ODIR    = o

D_FLAGS = @DEFS@
C_FLAGS = ${WARN} ${PROF} ${D_FLAGS} -I${HDIR}
L_FLAGS = ${PROF} ${LIBS}

C_FILES := ${wildcard *.c}
O_FILES := ${patsubst %.c, ${ODIR}/%.o, ${C_FILES}}
H_FILES := ${wildcard ${HDIR}/*.h}

EXE = rom

all: sort ${EXE}

${EXE}: ${sort ${O_FILES}}
	@rm -f ${EXE}
	@${CC} ${L_FLAGS} -o ${EXE} ${O_FILES}
	@${INSTALL} ${EXE} ${BIN}
	@echo "Done."

${ODIR}/%.o: %.c
	@echo "`date +"%X"` : Compiling $<..."
	@${CC} -c ${C_FLAGS} -o $@ $<

%.header: %.h
	@mv -f $< ${HDIR}
	
sort: mkdir ${patsubst %.h, %.header, ${wildcard *.h}}

mkdir: 
	@if [ ! -d ${HDIR} ]; then mkdir ${HDIR}; fi
	@if [ ! -d ${ODIR} ]; then mkdir ${ODIR}; fi

clean:
	@rm -f *.o ${ODIR}/*.o *~ ${HDIR}/*~ ${EXE}
	@echo "Done cleaning."

indent:
	@indent ${C_FILES} ${H_FILES}
	@echo "Done formating files."

backup:
	@${BIN}/backup clean
	@${BIN}/backup all

resetconfig: indent clean
	@rm -f ${CONFIG}/config.cache
	@rm -f ${CONFIG}/config.log
	@rm -f ${CONFIG}/config.status
	@rm -f ${HDIR}/config.h
	@rm -f Makefile
	@cp -f ${CONFIG}/Makefile.orig Makefile
	@rm -f .depend
	@echo > .depend
	@echo "Configuration reset."

beginhelp:
	@echo =============================================================================
	@echo Change into the config directory and run ./configure to create a makefile
	@echo 
	@echo Notes: The makefile configure generates requires a version of make that
	@echo "       has the sort function amoung other things."
	@echo 
	@echo "       On the FreeBSD and OpenBSD platforms you will most likely need to" 
	@echo "       use gmake to compile the code."
	@echo =============================================================================

${CONFIG}/configure: ${CONFIG}/configure.in
	@cd ${CONFIG} && autoconf

# autoheader might not change config.h.in, so touch a stamp file.
${CONFIG}/config.h.in: ${CONFIG}/stamp-h.in

${CONFIG}/stamp-h.in: ${CONFIG}/configure.in
	@cd ${CONFIG} && autoheader
	@cd ${CONFIG} && echo `date +"%X"` > stamp-h.in

${HDIR}/config.h: ${CONFIG}/stamp-h

${CONFIG}/stamp-h: ${CONFIG}/config.h.in ${CONFIG}/config.status
	@cd ${CONFIG} && ./config.status

Makefile: ${CONFIG}/Makefile.in ${CONFIG}/config.status
	@cd ${CONFIG} && ./config.status
	@echo "Done reconfiguration."

${CONFIG}/config.status: ${CONFIG}/configure
	@cd ${CONFIG} && ./config.status --recheck

depend: 
	@if [ "${DEP}" != "error" ]; then \
		${DEP} -DDEPEND -p${ODIR}/ -f- -- ${C_FLAGS} -- ${C_FILES} > .depend; \
	else \
		rm -f .depend; \
		echo > .depend; \
	fi

include .depend