lpmud/mudlib/
lpmud/mudlib/doc/
lpmud/mudlib/doc/LPC/
lpmud/mudlib/log/
lpmud/mudlib/players/
lpmud/mudlib/room/maze1/
lpmud/mudlib/room/sub/
# LPMud 1.4.0 makefile 
CC = gcc 
AR = ar
YACC = yacc
LEX = flex

# If you don't have or care to use lint/splint set this to nothing
LINT =
#LINT = splint

# The suffix appended to executables.  
# This should be set for Cygwin and Windows.
#EXE = .exe
EXE =

#the value of FLAGS is passed to CFLAGS (incl. in subdirs)
RAND=RANDOM
CFLAGS = -D$(RAND) -DLEX -g -O2 -pipe -Wall -W -Wno-parentheses -Wno-unused
LDFLAGS = -g 

# Include directories 
INCS = -I./ 

# See LINT above - these flags for splint
LINTFLAGS = $(INCS) -weak -warnposixheaders +relaxtypes -retvalother

#LIBS may be defined to be any other system libraries you may require
LIBS = -lcrypt

HDR = config.h wiz_list.h sent.h security.h regexp.h object.h lnode.h \
    interpret.h comm.h os.h telnet.h

SRC=lang.y lexical.l main.c lnode.c interpret.c simulate.c object.c backend.c \
    comm1.c ed.c regexp.c wiz_list.c swap.c string_space.c os.c

OBJ=lang.o lexical.o main.o lnode.o interpret.o simulate.o object.o backend.o \
    comm1.o ed.o regexp.o wiz_list.o swap.o string_space.o 

XTRA = README CHANGES.1.4.0-A CHANGES Copyright Makefile INSTALL_NOTES IDEA \
    makefile.bor makefile.vc restart_mud

MISCSRC = count_active.c 
MISCOBJ = $(MISCSRC:.c=.o)

OTHER = mudlib/* 

# Files in the standard distribution
DISTFILES = $(SRC) $(HDR) $(XTRA) $(OTHER) $(MISCSRC) 
PDIST = $(patsubst %,lpmud/%,$(DISTFILES))
RELEASE = dist

# Dependency information
OBJDEPENDS = $(OBJ) $(MISCOBJ) 

TARGETS = parse$(EXE) count_active$(EXE)

all: $(TARGETS)

parse$(EXE) : $(OBJ) 
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) 

count_active$(EXE) : count_active.o
	$(CC) $(LDFLAGS) -o $@ $<

lang.c y.tab.h : lang.y 
	$(YACC) -d lang.y
	mv y.tab.c lang.c

lexical.c : lexical.l
	$(LEX) lexical.l
	mv lex.yy.c lexical.c

clean :
	-rm -f $(TARGETS) lang.c y.tab.h lexical.c $(OBJDEPENDS) $(OBJDEPENDS:.o=.d) 

dist : 
	ln -s ./ lpmud
	-tar czvf lpmud-$(RELEASE).tar.gz $(PDIST) --exclude=.svn
	rm lpmud

# pull in dependency info for *existing* .o files
-include $(OBJDEPENDS:.o=.d)
	
# compile and generate dependency info;
# more complicated dependency computation, so all prereqs listed
# will also become command-less, prereq-less targets
#   sed:    append directory to object target. (gcc bug?)
#   sed:    strip the target (everything before colon)
#   sed:    remove any continuation backslashes
#   fmt -1: list words one per line
#   sed:    strip leading spaces
#   sed:    add trailing colons
%.o: %.c
ifdef LINT
	-$(LINT) $(LINTFLAGS) $*.c
endif	
	$(CC) -c $(CFLAGS) $(INCS) $*.c -o $*.o 
	@$(CC) -MM $(CFLAGS) $(INCS) $*.c > $*.d
	@mv -f $*.d $*.d.tmp
	@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
	  sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
	@rm -f $*.d.tmp