# 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 ----
# ------------------------------------

# file locations for "make install":
# BINDIR     - where to put the yabbs and yahoo binaries
# MANDIR     - where to put the man page for yabbs and yahoo
BINDIR=/usr/yabbs/bin
MANDIR=/usr/local/man/man1

# compiler options, etc:
# CC         - the name of your compiler (must be ANSI)
# CFLAGS     - flags to pass to the compiler
# DEFINES    - options for yabbs (listed below)
#   -DTERMIO     - if using the unix-specific tty driver (in unix.c) this 
#                  says that termio commands should be used (usaully on Sys V
#                  systems).
#   -DSGTTYB     - if using the unix-specific tty driver (in unix.c) this 
#                  says that sgttyb commands should be used (usually on BSD
#                  systems).
#   -DJOBCONTROL - if you system supports job control (control-Z) this will
#                  enable yabbs to be suspended and resumed properly.
#   -DAIX        - needed to compile on AIX 3.x
# LINKFLAGS  - flags to pass to the linker
# LIBS       - libraries to link against
# MAKE       - the name of your make utility
# MFLAGS     - optional flags for make
# STRSTR     - optional objects to be linked in (strstr.o and strsep.o
#              should be added if the linker complains that it can't find
#              them).
# PLATFORM   - platform specific objects (unix.o or msdos.o)
# INTERFACE  - network interface specific objects (socket.o or "wasocket.o
#              djsocket.o").

# BSDish setup
CC=cc
CFLAGS=-O
DEFINES=-DSGTTYB -DJOBCONTROL
LINKFLAGS=
LIBS=-ltermcap
MAKE=make
MFLAGS=
STRSTR=strstr.o strsep.o
PLATFORM=unix.o
INTERFACE=socket.o

# sysVish and Linux setup
#CC=cc
#LINKFLAGS=
#CFLAGS=-O
#LIBS=-ltermcap
#DEFINES=-DTERMIO -DJOBCONTROL
#MAKE=make
#MFLAGS=
#STRSTR=strstr.o strsep.o
#PLATFORM=unix.o
#INTERFACE=socket.o

# MSDOS (using DJGPP) with WATCP libraries setup
# DJGPP is a free version of gcc for 386+ machines running MSDOS.  It is 
# available from oak.oakland.edu in /pub/msdos/djgpp.
# DJGPP should be installed in /djgpp or you'll need the include paths for
# the TCP includes and libraries in this makefile and the one in the yabbslib
# directory.  
# WATCP should be installed as per its instructions.  It can be found on
# ftp.3com.com in /mirrors/djgpp/pub/tcplib.zip.
#CC=gcc
#LINKFLAGS=
#CFLAGS=-O2 -I/djgpp/include/tcp
#LIBS=-lwatcp -lpc
#DEFINES=
#MAKE=make
#MFLAGS=
#STRSTR=
#PLATFORM=msdos.o
#INTERFACE=djsocket.o wasocket.o
#EXE=exe

# --------------------------------------
# ---- OTHER USER SETABLE VARIABLES ----
# --------------------------------------
# the address of the yabbs server (enclosed in quotes).
SERVER="localhost"
# use cp if you don't have install
INSTALL=install -c -s
#INSTALL=cp
INSTALLMAN=cp
INSTALLSCRIPT=$(INSTALLMAN)
# where the default yabbsrc file should be located (enclosed in quotes)
LOCALETC="/usr/local/etc"
# the client home directory is used when a running client detects that 
# it doesn't have one.  having a home directory is important when a public
# system spawns external editors, so that the sysop can put editor and pager
# startup files there to reduce the risk of illegal shell access.
# client home directory (enclosed like "/this/is/a/home")
CLIHOME="/usr/yabbs/data"
# the default editor and pager for clients to use (enclosed in quotes)
# specify "internal" for each to use the internal editor and pager
# WARNING: if you are compiling for a public system and you use any editor
#   or pager besides the internal ones you should test for possible security
#   holes allowing users to gain shell access.
DEFEDITOR="internal"
DEFPAGER="more"
# setup platform files
PLATFORMOBJ=$(PLATFORM)
INTERFACEOBJ=$(INTERFACE)
# yabbslib information
YABBSLIBDIR=yabbslib
YABBSLIBFILE=$(YABBSLIBDIR)/libyabbs.a
USEYABBSLIB=-L$(YABBSLIBDIR) -lyabbs

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

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

all: yabbs yahoo $(EXE)

yabbs: $(YABBS) $(YABBSLIBFILE)
	$(CC) $(LINKFLAGS) $(YABBS) $(USEYABBSLIB) $(LIBS) -o yabbs

yahoo: $(YAHOO) $(YABBSLIBFILE)
	$(CC) $(LINKFLAGS) $(YAHOO) $(USEYABBSLIB) $(LIBS) -o yahoo

$(YABBSLIBFILE):
	cd $(YABBSLIBDIR); $(MAKE) $(MFLAGSLONG)

.c.o: yabbs.h bbsdefs.h bbsfuncs.h menus.h bbs_st.h plevel.h $(YABBSLIBDIR)/yabbslib.h
	$(CC) $(CFLAGS) $(DEFINES) -DDEFPAGER='$(DEFPAGER)' -DDEFEDITOR='$(DEFEDITOR)' -DCLIHOME='$(CLIHOME)' -DLOCALETC='$(LOCALETC)' -c $<

install:
	$(INSTALL) yahoo yabbs $(BINDIR)
	$(INSTALLMAN) yahoo.1 yabbs.1 $(MANDIR)

tar:
	cp *.[ch1] Makefile less-keys COPYING README $(TARDIR)/yabbs/yabbs
	mkdir $(TARDIR)/yabbs/yabbs/yabbslib
	cp $(YABBSLIBDIR)/*.[ch] $(YABBSLIBDIR)/Makefile $(TARDIR)/yabbs/yabbs/$(YABBSLIBDIR)

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

exe:
	strip yabbs
	strip yahoo
	coff2exe -s /djgpp/bin/go32.exe yabbs
	coff2exe -s /djgpp/bin/go32.exe yahoo

