DalekenMUD/
DalekenMUD/data/
DalekenMUD/data/notes/
DalekenMUD/data/player/
DalekenMUD/data/system/poses/
DalekenMUD/doc/Homepage/images/
DalekenMUD/log/
# Makefile for Linux 2.xx.xx systems.
# This file will only be picked up by GNU make.  It will assume
# that gcc exists.
# Slight modifications should make it possible for this to
# work on other OS's.
# By default this makefile makes a large executable with debugging
# information.  There are optim, profile and archaic options.
#	--Symposium

# Changes you might have to make to password encryption work:
#	1. remove -lcrypt from LINKLIB line
#	2. use crypt.c: add crypt.c to the C_FILES
# Try step 1 first, and if that doesn't work, try step 2.

### Choose the option you want to use from the three below, only one can
# be chosen, the preferred one is to have debugging enabled.
# FYI, you can actually use -g3 -O, it still works well in the debugger
# and is somewhat optimised, but the compiler works pretty hard.
#
PROF     = -pg		# sometimes only '-p'
DEBUG    = -ggdb3 -DDEBUG
O_FLAGS  = -O2
SUPER_OPTIMISE = -O3 -finline-functions -funroll-loops -fdefer-pop \
	-fomit-frame-pointer -fstrength-reduce

# Use this with gcc if you have lots of RAM, speeds up compile.
PIPE	= -pipe

# For optimised compilers
MACHINE	= # -m486

OPTIONAL = $(DEBUG) $(MACHINE)

# Libraries needed for compilation.
LINKLIB	= -lm -lcrypt

BINDIR	= ../bin
TARGET	= $(BINDIR)/daleken.new
DEP_FILE = .dependencies
CC      = gcc
MAKE	= make --no-print-directory
CFLAGS	= $(OPTIONAL) -Wall $(PIPE)
LDFLAGS	= $(OPTIONAL) $(LINKLIB)

# These are the files that are needed, if you add any files to the system
# please add the name to this list.

C_FILES = act_comm.c act_info.c act_fight.c act_move.c act_obj.c act_wiz.c \
	bit.c callback.c comm.c const.c db_io.c db.c event.c fight.c \
	handler.c interp.c magic_def.c magic_misc.c magic_off.c mem.c \
	mob_commands.c mud_prog.c note.c olc.c olc_act.c olc_misc.c \
	olc_save.c regexp.c religion.c save.c special.c ssm.c string.c update.c

H_FILES = config.h const.h db.h event.h function.h global.h mud.h olc.h \
	regexp.h types.h

OBJDIR = obj
O_FILES = $(addprefix $(OBJDIR)/,$(subst .c,.o,$(C_FILES)))

all: $(TARGET)
install: $(TARGET)
$(TARGET): $(OBJDIR) $(O_FILES)
	-rm -f $(TARGET)
	$(CC) $(LDFLAGS) -o $(TARGET) $(O_FILES)
	@chmod 664 $(O_FILES)	# -rw-rw-r--
	@chmod 2770 $(TARGET)	# -rwxrws---
#	@$(BINDIR)/tagupdate
#	@$(BINDIR)/buildupdate < ../system/SYSINFO.TXT

$(OBJDIR)/%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@
	@chmod 664 $@		# -rw-rw-r--
#	@touch .build

$(OBJDIR):
	mkdir $(OBJDIR)

# Automagically generate lists of dependencies using the preprocessor.
# You might like to run this before anything else.
dep depend $(DEP_FILE):
	-rm -f $(DEP_FILE)
	for i in $(C_FILES); do echo -n $(OBJDIR)/ >> $(DEP_FILE); $(CPP) -MM $$i >> $(DEP_FILE); done

-include $(DEP_FILE)

clean:
	rm -rf $(OBJDIR) *.o $(TARGET) *.c~ *.h~ $(DEP_FILE)
#	$(BINDIR)/tagupdate

## All the strange ways you might like to compile.
# optimise	- optimised.
# profile	- profiling support
# archaic	- make it run on a low spec machine (i.e. a 386).

optim:
	@echo You have chosen to optimise the code.
	@echo This means you will probably have to wait a little longer.
	$(MAKE) -k OPTIONAL="$(O_FLAGS) $(MACHINE)"
	strip $(TARGET)

# Profile Daleken with gprof (GNU profiler)
profile: clean
	$(MAKE) OPTIONAL="$(PROF)"

archaic: clean
	@echo Making a special executable for an older computer.
	$(MAKE) OPTIONAL="$(O_FLAGS) -mno-486"

# For all those tags files needed by the good editors.
tags: $(C_FILES) $(H_FILES)
	ctags $(C_FILES) $(H_FILES)

TAGS: $(C_FILES) $(H_FILES)
	etags $(C_FILES) $(H_FILES)