#
# RAM $Id: Makefile 4 2008-10-11 04:28:06Z ram $
#

CC      	= g++

# Comment out the -Wmissing-format-attribute flag if you're using gcc 2.95
# or upgrade!
#
# The W_CONLY set of flags are only valid when using C, not for C++
# -Wmissing-declarations is C only under g++ 4.2.x and older!

W_FORMAT        = -Wformat -Wformat-security -Wmissing-format-attribute
W_NITPICK       = -Wpointer-arith -Winline
W_MESSY         = -Wmissing-braces -Wparentheses -Wshadow -Wredundant-decls
W_TYPE          = -Wcast-qual -Wcast-align -Wchar-subscripts -Wreturn-type -Wswitch -Wwrite-strings
W_EXTRA         = -Wunused -Wuninitialized #-Wmissing-declarations #-Wunreachable-code
W_CONLY		= #-Wmissing-prototypes -Wstrict-prototypes 
W_ANSI          = #-pedantic
W_UBER          = -Wall
W_ERROR         = -Werror

WARN		= $(W_ANSI) $(W_UBER) $(W_FORMAT) $(W_MESSY) $(W_FUNC) $(W_TYPE) $(W_EXTRA) $(W_NITPICK) $(W_CONLY) $(W_ERROR)
OPT	    	= -O
DEBUG		= -g
CRYPT		= #-DNOCRYPT		# Uncomment to use clear-text passwords
RAND		= #-DOLD_RAND		# Uncomment if your random number generator is broken
MALLOC		= #-DMALLOC_DEBUG	# Uncomment for extra malloc debugging code
SOCIAL		= #-DSOCIAL_DEBUG	# Uncomment for debugging of the socials

OPTIONS		= $(OPT) $(DEBUG) $(CRYPT) $(RAND) $(MALLOC) $(SOCIAL)

C_FLAGS 	= $(WARN) $(OPTIONS)
L_FLAGS 	= $(DEBUG)
SOLARIS_LIBS	= -lsocket -lresolv -lnsl
LINUX_LIBS	= -lcrypt

LIBS		= $(LINUX_LIBS)

O_FILES		= act_comm.o act_enter.o act_info.o act_move.o act_obj.o \
		  act_wiz.o alias.o ban.o comm.o const.o \
		  db.o db2.o effects.o fight.o flags.o \
		  handler.o healer.o interp.o lookup.o magic.o \
		  magic2.o music.o note.o recycle.o save.o \
		  scan.o skills.o special.o tables.o update.o

rom: $(O_FILES)
	@rm -f $@
	$(CC) $(L_FLAGS) -o $@ $(O_FILES) $(LIBS)
	@ls -l $@

%o : %c
	$(CC) $(C_FLAGS) -c $< -o $@

tags :
	@rm -f $@
	@ctags *.[ch]
	@ls -l $@

clean:
	@rm -f *.o

spotless:
	@rm -f *.o tags rom

dep:
	@find . -name \*.c -a -type f -print0 | xargs -0 -P 1 -r $(CC) $(OPTIONS) -MM

#--- Dependancies go below here ---

act_enter.o: act_enter.c merc.h interp.h
effects.o: effects.c merc.h recycle.h
act_obj.o: act_obj.c merc.h interp.h
scan.o: scan.c merc.h interp.h
note.o: note.c merc.h interp.h recycle.h tables.h
update.o: update.c merc.h interp.h music.h
alias.o: alias.c merc.h interp.h
music.o: music.c merc.h interp.h music.h recycle.h
db2.o: db2.c merc.h db.h lookup.h
db.o: db.c merc.h interp.h db.h recycle.h music.h lookup.h
recycle.o: recycle.c merc.h recycle.h
magic.o: magic.c merc.h interp.h magic.h recycle.h
act_comm.o: act_comm.c merc.h interp.h recycle.h tables.h
tables.o: tables.c merc.h tables.h
lookup.o: lookup.c merc.h tables.h
magic2.o: magic2.c merc.h interp.h magic.h
act_move.o: act_move.c merc.h interp.h
save.o: save.c merc.h recycle.h lookup.h tables.h
interp.o: interp.c merc.h interp.h
special.o: special.c merc.h interp.h magic.h
skills.o: skills.c merc.h interp.h magic.h recycle.h
fight.o: fight.c merc.h interp.h
comm.o: comm.c merc.h interp.h recycle.h tables.h telnet.h
healer.o: healer.c merc.h interp.h magic.h
const.o: const.c merc.h magic.h interp.h
flags.o: flags.c merc.h interp.h tables.h
act_wiz.o: act_wiz.c merc.h interp.h recycle.h tables.h lookup.h
act_info.o: act_info.c merc.h interp.h magic.h recycle.h tables.h \
  lookup.h
ban.o: ban.c merc.h recycle.h interp.h
handler.o: handler.c merc.h interp.h magic.h recycle.h tables.h