src/
src/unused/
CC      = gcc -DMEMWATCH

MACHINE = -mcpu=i686 -march=pentium

#Uncomment the line below if you are getting undefined crypt errors.
NEED_CRYPT = -lcrypt

#Set this to -DNOCRYPT to disable encrypted password support
NOCRYPT =

#Some systems need this for dynamic linking to work
EXPORT_SYMBOLS = -export-dynamic

INDENT = indent
INDENT_FLAGS = -ts4 -nut -bap -bli0 -di10 -l78 -lp -nbc -i8 -sc -cdb -c1 -cd1 -nbfda -npcs -bad -hnl -nce -npsl -bl

#Misc compiler options
OPT_FLAG = -pipe -Os
DEBUG_FLAG = -ggdb3
#PROF_FLAG = -p

W_FLAGS = -Wall -Werror -Wformat-security -Winline -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wredundant-decls

C_FLAGS = $(MACHINE) $(W_FLAGS) $(DEBUG_FLAG) $(OPT_FLAG) $(PROF_FLAG) $(NOCRYPT) $(EXPORT_SYMBOLS)
L_FLAGS = $(MACHINE) $(DEBUG_FLAG) $(OPT_FLAG) $(PROF_FLAG) $(EXPORT_SYMBOLS) $(NEED_CRYPT) -lz -lpthread -lstdc++
D_FLAGS = $(MACHINE) $(W_FLAGS) $(DEBUG_FLAG) $(OPT_FLAG) $(PROF_FLAG)

#C_FLAGS = -Wall -O -ggdb $(NOCRYPT)
#L_FLAGS = -lz -lcrypt -lpthread

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c bit.c mccp.c \
	board.c build.c clan.c comm.c daemon.c db.c angel.c x-socials.c\
	demon.c drow.c fight.c kav_wiz.c handler.c kav_fight.c kav_info.c \
	interp.c mage.c magic.c mem.c monk.c monk2.c ninja.c olc.c \
	olc_act.c olc_save.c save.c special.c string.c arena.c auction.c\
	update.c vamp.c ww.c shapeshifter.c tanarri.c undead_knight.c \
        samurai.c wizutil.c const.c cyborg.c lich.c jope.c religion.c \
        jobo_king.c jobo_fight.c jobo_act.c jobo_wiz.c jobo_util.c \
        jobo_comm.c jobo_save.c social-edit.c jobo_update.c spiderdroid.c \
        jobo_quest.c msp.c kav_soundex.c desc_map.c jobo_shop.c zarius_proj.c \
	zarius.c changes.c vote.c skyblade.c ghoul.c draconian.c thief.c \
	shadow.c priest.c jedi.c psycho.c giant.c hobbit.c fae.c drone.c \
	zarius_quest.c zarius_bank.c olc_mpcode.c mob_prog.c weather.c \
	mob_cmds.c recycle.c wizlist.c zarius_comm.c zarius_games.c mudmsg.c \
	zarius_shop.c md5.c resistance.c music.c hutoshi.c class.c memwatch.c \
	akurei.c elemental.c drexx_eq.c

CHATOS = chat/akey.o chat/allkeys.o chat/chatmain.o chat/eliza.o

O_FILES := $(patsubst %.c,o/%.o,$(C_FILES))

H_FILES = $(wildcard *.h)

MCLOUD = mcloud

all:
	(cd chat;$(MAKE);cd ..)
	$(MAKE) -s mcloud

neat:
	$(INDENT) $(INDENT_FLAGS) $(C_FILES) $(H_FILES)

mcloud: $(O_FILES)
	rm -f $(MCLOUD)
	$(CC)  -o $(MCLOUD) $(O_FILES) $(CHATOS) $(L_FLAGS)
	echo "Done compiling mcloud.";
	chmod g+w $(MCLOUD)
	chmod a+x $(MCLOUD)
	chmod g+w $(O_FILES)

purge:
	rm -f o/*.o $(MCLOUD) core
	rm -f chat/*.o
	rm -f chat/chat
	rm -f ../area/core*

clean:
	rm -f o/*.o $(MCLOUD) core
	rm -f chat/*.o
	rm -f ../area/core*
	rm -f chat/chat

o/%.o: %.c
	echo " Compiling $@....";
	$(CC) -c -g $(C_FLAGS) $< -o $@
	
.c.o: merc.h
	$(CC) -c $(C_FLAGS) $<