CC      	= g++

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 #-Wunreachable-code
W_ANSI          = #-pedantic
W_UBER          = -Wall #-W
W_ERROR         = -Werror

WARN		= $(W_ANSI) $(W_UBER) $(W_FORMAT) $(W_MESSY) $(W_FUNC) $(W_TYPE) $(W_EXTRA) $(W_NITPICK) $(W_ERROR)
OPT	    	= -O
DEBUG		= -g

C_FLAGS 	= $(WARN) $(OPT) $(DEBUG)
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 note.o lookup.o magic.o magic2.o \
	  music.o recycle.o save.o scan.o skills.o special.o tables.o \
	  update.o

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

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

clean:
	@rm -f *.o

# find . -name \*.c -a -type f -print0 | xargs -0 -P 1 -r g++ -O -g -MM

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
note.o: note.c merc.h recycle.h tables.h
update.o: update.c merc.h interp.h music.h
alias.o: alias.c merc.h
music.o: music.c merc.h music.h recycle.h
db2.o: db2.c merc.h db.h lookup.h
db.o: db.c merc.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 magic.h
const.o: const.c merc.h magic.h interp.h
flags.o: flags.c merc.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
handler.o: handler.c merc.h interp.h magic.h recycle.h tables.h