ackfuss-4.3.9/area/
ackfuss-4.3.9/board/
ackfuss-4.3.9/help/e/
ackfuss-4.3.9/help/f/
ackfuss-4.3.9/help/h/
ackfuss-4.3.9/help/l/
ackfuss-4.3.9/help/n/
ackfuss-4.3.9/help/q/
ackfuss-4.3.9/help/s/
ackfuss-4.3.9/help/u/
ackfuss-4.3.9/help/v/
ackfuss-4.3.9/help/y/
ackfuss-4.3.9/help/z/
ackfuss-4.3.9/npc/a/
ackfuss-4.3.9/npc/b/
ackfuss-4.3.9/npc/c/
ackfuss-4.3.9/npc/d/
ackfuss-4.3.9/npc/e/
ackfuss-4.3.9/npc/f/
ackfuss-4.3.9/npc/h/
ackfuss-4.3.9/npc/i/
ackfuss-4.3.9/npc/k/
ackfuss-4.3.9/npc/l/
ackfuss-4.3.9/npc/n/
ackfuss-4.3.9/npc/o/
ackfuss-4.3.9/npc/p/
ackfuss-4.3.9/npc/r/
ackfuss-4.3.9/npc/s/
ackfuss-4.3.9/npc/w/
ackfuss-4.3.9/player/c/
CC   = g++
VERS = AckFUSS 4.3.9
#PROF    = -pg

# Debugging flags possible:  DEBUG_MEM DEBUG_MEM_CORRUPT DEBUG_MEM_DUP_FREE
# DEBUG_MEM is most basic, just checks magic numbers when freeing
# DEBUG_MEM_CORRUPT checks every free block to see if magic numbers ok, every
#                   call to alloc_mem
#		    Also makes calls to void check_free_mem(void) check for
#		    corrupted free memory blocks.
# DEBUG_MEM_DUP_FREE checks to see if freed blocks are overlapping every call
# 		     to mem_alloc.
#

#-DDEBUG_MEM -DDEBUG_MEM_CORRUPT -DDEBUG_MEM_DUP_FREE
#-DDEBUG_MEM -DDEBUG_MEM_CORRUPT

#Uncomment to compile in Cygwin
#CYGWIN = -DCYGWIN -DWIN32

#-Wshadow -Werror -Wconversion -Wwrite-strings
W_FLAGS = -Wall -Wformat-security -Wpointer-arith -Wredundant-decls -Wcast-align
C_FLAGS = -O2 -g $(W_FLAGS) -DACK_43 $(PROF)
L_FLAGS = -lcrypt -lm

#IMC2 - Comment out to disable IMC2 support
IMC = 1
IMC_FILES = imc.c sha256.c

C_FILES = $(filter-out $(IMC_FILES),$(wildcard *.c))

ifdef IMC
   C_FILES = $(wildcard *.c)
   C_FLAGS := $(C_FLAGS) -DIMC -DIMCACK
endif

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

H_FILES = $(wildcard h/*.h)

all:
	@$(MAKE) -j2 ack

# pull in dependency info for *existing* .o files
-include dependencies.d

ifdef CYGWIN
ack: $(O_FILES)
	@rm -f ack.exe
	@$(CC) -o ack.exe $(O_FILES) $(L_FLAGS)
	@echo "Generating dependency file ...";
	@$(CC) -MM $(C_FLAGS) $(C_FILES) > dependencies.d
	@perl -pi -e 's.^([a-z]).o/$$1.g' dependencies.d
	@echo "Done compiling $(VERS).";
	@chmod g+w ack.exe
	@chmod a+x ack.exe
	@chmod g+w $(O_FILES)

clean:
	@rm -f o/*.o ack.exe dependencies.d ../area/core
else
ack: $(O_FILES)
	@rm -f ack
	@$(CC) -o ack $(O_FILES) $(L_FLAGS)
	@echo "Generating dependency file ...";
	@$(CC) -MM $(C_FLAGS) $(C_FILES) > dependencies.d
	@perl -pi -e 's.^([a-z]).o/$$1.g' dependencies.d
	@echo "Done compiling $(VERS).";
	@chmod g+w ack
	@chmod a+x ack
	@chmod g+w $(O_FILES)

clean:
	@rm -f o/*.o ack dependencies.d ../area/core
endif

o/%.o: %.c
	@echo "Compiling `echo $@ | cut -c 3-` ...";
	@$(CC) -c $(C_FLAGS) $< -o $@

scan: scan.o
	rm -f scan
	$(CC) $(L_FLAGS) -o scan scan.o