CC      = gcc
#PROF    = -p
NOCRYPT =

#Uncomment to compile in Cygwin
CYGWIN = -DCYGWIN

# Uncomment the two lines below if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV
#SOLARIS_LINK = -lnsl -lsocket

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

#Intermud-3 - Comment out to disable I3 support in your code
I3 = 1

#Uncomment the line below if you want a performance increase though beware
#your core files may not be as much of a benefit if you do.
#OPT_FLAG = -finline-functions -funroll-loops -fdefer-pop -fstrength-reduce

C_FLAGS = $(OPT_FLAG) -O -g2 -Wall $(CYGWIN) $(PROF) $(NOCRYPT) $(SOLARIS_FLAG)
L_FLAGS = $(OPT_FLAG) $(PROF) $(SOLARIS_LINK) $(NEED_CRYPT)

O_FILES = act_comm.o act_info.o act_move.o act_obj.o act_wiz.o areaconvert.o \
           ban.o bits.o boards.o build.o clans.o color.o comm.o comments.o const.o \
           db.o deity.o fight.o gamble.o grub.o handler.o hashstr.o help.o ident.o \
           interp.o imm_host.o magic.o makeobjs.o mapout.o misc.o mpxset.o mud_comm.o \
           mud_prog.o planes.o player.o polymorph.o reset.o save.o services.o \
           shops.o skills.o special.o tables.o track.o train.o update.o

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c areaconvert.c \
           ban.c bits.c boards.c build.c clans.c color.c comm.c comments.c const.c \
           db.c deity.c fight.c gamble.c grub.c handler.c hashstr.c help.c ident.c \
           interp.c imm_host.c magic.c makeobjs.c mapout.c misc.c mpxset.c mud_comm.c \
           mud_prog.c planes.c player.c polymorph.c reset.c save.c services.c \
           shops.c skills.c special.c tables.c track.c train.c update.c

H_FILES = mud.h color.h bet.h

ifdef I3
   C_FILES := i3.c $(C_FILES)
   O_FILES := i3.o $(O_FILES)
   C_FLAGS := $(C_FLAGS) -DI3 -DI3SMAUG
endif

all:
	$(MAKE) smaug

ifdef CYGWIN
smaug: $(O_FILES)
	rm -f smaug.exe
	$(CC) -o smaug.exe $(O_FILES) $(L_FLAGS)
	chmod g+w smaug.exe
	chmod a+x smaug.exe
	chmod g+w $(O_FILES)

clean:
	rm -f *.o smaug.exe *~
else
smaug: $(O_FILES)
	rm -f smaug
	$(CC) -o smaug $(O_FILES) $(L_FLAGS)
	chmod g+w smaug
	chmod a+x smaug
	chmod g+w $(O_FILES)

clean:
	rm -f *.o smaug *~
endif

.c.o: mud.h
	$(CC) -c $(C_FLAGS) $<
