OBJS = miscutil.o msgbase.o yalk.o gfiles.o llist.o \
       strlwr.o tochars.o bbs.o main.o $(STRSTR)
YAHOO = yahoo.o tochars.o

# if you are compiling the whole yabbs package all of the setable variables
# should be transferred from the root makefile automagically.  If not just
# copy them.

# ------------------------------------
# ---- SYSTEM DEPENDENT VARIABLES ----
# ------------------------------------

# BSDish setup
CC=gcc
CFLAGS=-DBSD -DTERMIO=0 -O6
MAKE=make
MFLAGS=
STRSTR=
# if the loader can't find strstr and strsep add this line
# STRSTR=strstr.o strsep.o

# sysVish and Linux setup (untested)
#CC=cc
#CFLAGS=-DTERMIO=1
#MAKE=make
#MFLAGS=
#STRSTR=strstr.o strsep.o

# --------------------------------------
# ---- OTHER USER SETABLE VARIABLES ----
# --------------------------------------
# the address of the yabbs server (in quotes, like "name.of.server").
SERVER="localhost"
# use cp if you don't have install
INSTALL=install -c -s
#INSTALL=cp
# where you want it installed
BIN=../bin

# ---------------------------------------------------
# ---- shouldn't need to change stuff under here ----
# ---------------------------------------------------
MFLAGSLONG=$(MFLAGS) "CC=$(CC)" "CFLAGS=$(CFLAGS)"

all: yabbs yahoo

yabbs: $(OBJS) $(STRSTR) yabbs.h bbsdefs.h bbsfuncs.h yabbslib/yabbslib.o patchlevel.h
	$(CC) $(OBJS) yabbslib/yabbslib.o -ltermcap -o yabbs

yahoo: $(YAHOO) yabbslib/yabbslib.h
	$(CC) $(YAHOO) $(STRSTR) yabbslib/yabbslib.o -o yahoo

yabbslib/yabbslib.o:
	cd yabbslib;$(MAKE) $(MFLAGSLONG)

.c.o: yabbs.h bbsdefs.h bbsfuncs.h menus.h bbs_struct.h
	$(CC) $(CFLAGS) -DSERVER='$(SERVER)' -c $<

install:
	$(INSTALL) yahoo yabbs $(BIN)

tar:
	cp *.[ch1] Makefile $(TARDIR)/yabbs/yabbs
	mkdir $(TARDIR)/yabbs/yabbs/yabbslib
	cp yabbslib/*.[ch] yabbslib/Makefile $(TARDIR)/yabbs/yabbs/yabbslib

clean:
	cd yabbslib;$(MAKE) $(MFLAGSLONG) clean
	-rm *.o yabbs yahoo
