# Unix Makefile for slrn                               -*- sh -*-
#---------------------------------------------------------------------------
# This file is divided into six configurable sections.  The last two sections
# are optional: Section 5 deals with setting up slrn to read the server name 
# from a file.  If you are compiling this on Linux and you want it to work 
# with 'term', look at the 6th section.
#-----------------------------------------------------------------------------
# 1. Choose a C compiler.  It must understand prototypes.
#-----------------------------------------------------------------------------
CC = @CC@
CFLAGS = @CFLAGS@ @X_CFLAGS@
LDFLAGS = @LDFLAGS@
#  Note: gcc -O2 is buggy under Linux.  If you use it, include the
#        -fno-strength-reduce flag!!
#-----------------------------------------------------------------------------
# 2. On a few systems, additional libraries are required.
#-----------------------------------------------------------------------------
MISCLIBS = @X_EXTRA_LIBS@ @TERMCAP@
#MISCLIBS = -lnsl -lsocket                             # Solaris
#MISCLIBS = -ltermcap                                  # NeXT

#-----------------------------------------------------------------------------
# 3. Directory where the slang library, slanglib.a, is located.
#    BUILD SLANG FIRST!!!!  If you do not have it, get it from the same place
#    you picked up slrn.  The current home is space.mit.edu:/pub/davis/slang.
#-----------------------------------------------------------------------------
#Location of slang.h
SLANGINC = @SLANG_INCLUDE@#
#Location of libslang.a
SLANGLIB = @SLANG_LIB_DIR@#
# Note: The relative path names should be done with respect to OBJDIR.
#SLANGLIB = ../../../slang/$(ARCH)elfobjs#    Location of shared elf library
#SLANGINC = ../../../slang/src#               Location of slang.h
#SLANGLIB = $(SLANGINC)/$(ARCH)objs#       Location of libslang.a


#-----------------------------------------------------------------------------
# 4. Location where object files are placed (Absolute pathnames!!)
#-----------------------------------------------------------------------------
OBJDIR = @OBJDIR@
SRCDIR = @SRCDIR@
BINDIR = @bindir@
#-----------------------------------------------------------------------------
# 5. If you want to read the server from a file, uncomment the following
#    lines and edit it as appropriate.  See INSTALL for more information.
#    It is also possible to provide defaults for other variables such as the
#    HOSTNAME, etc...  by editing the slrnfeat.h file.
#-----------------------------------------------------------------------------
#NNTPSERVERFILE = -DNNTPSERVER_FILE=\"/usr/local/lib/news/nntp_server\"
#SLRNLIBDIR = -DSLRN_LIB_DIR=\"/usr/local/lib/news\"
#SLRNLIBDIR = -DSLRN_LIB_DIR=\"$(HOME)/lib/slrn\"

#----------------------------------------------------------------------------
# 6.  Uncomment the following lines for Linux Term compatability.
#MISCLIBS += -ltermnet
#MISCINCLUDES = -include /usr/local/include/termnet.h

# INSTALL program
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

#----------------------------------------------------------------------------
# Nothing below here should require changing.
#----------------------------------------------------------------------------
SHELL = /bin/sh
OBJS = @PROGRAM_OBJECTS@
OFILES = @PROGRAM_OFILES@

EXEC = slrn
CONFIG_H = config.h
ALL_CFLAGS = $(CFLAGS) -Dunix -I$(SLANGINC) \
 $(MISCINCLUDES) $(NNTPSERVERFILE) $(SLRNLIBDIR)
EXECLIBS = -L$(SLANGLIB) -lslang $(MISCLIBS) -lm
DOT_O_DEPS = slrnfeat.h
server_O_DEP = clientlib.c spool.c nntp.c sltcp.c nntplib.c
chmap_O_DEP = chmap.h charmaps.h

slrnpull_O_DEP = score.c xover.c hash.c
slrnpull_DEPS = $(OBJDIR)/util.o $(OBJDIR)/ttymsg.o $(OBJDIR)/version.o\
 $(OBJDIR)/sltcp.o $(OBJDIR)/nntplib.o $(OBJDIR)/slrndir.o

slrnpull_LIBS = $(slrnpull_DEPS)

#
COMPILE_CMD = $(CC) -c $(ALL_CFLAGS)
#
all: $(EXEC)
$(EXEC): $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/$(EXEC)
	@echo $(EXEC) created in $(OBJDIR)
$(OBJDIR)/$(EXEC): $(OBJS)
	cd $(OBJDIR); $(CC) $(OFILES) -o $(EXEC) $(LDFLAGS) $(EXECLIBS)
#
$(OBJDIR):
	-mkdir $(OBJDIR)
#
$(CONFIG_H) : $(SRCDIR)/sysconf.h
	/bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H)
	touch $(CONFIG_H)
#
slangversion: $(OBJDIR)/chkslang
	$(OBJDIR)/chkslang $(EXEC) 10000
#
$(OBJDIR)/chkslang: $(OBJDIR)/chkslang.o
	$(CC) $(OBJDIR)/chkslang.o -o $(OBJDIR)/chkslang
uudecode: uudecode.c $(OBJDIR)/util.o $(OBJDIR)/ttymsg.o
	$(CC) $(ALL_CFLAGS) -DSTANDALONE $(LDFLAGS) -o uudecode uudecode.c $(OBJDIR)/util.o $(OBJDIR)/ttymsg.o $(EXECLIBS)
	touch uudecode.c
clean:
	/bin/rm -f $(OBJDIR)/* *~
distclean: clean
	/bin/rm -rf $(OBJDIR) Makefile sysconf.h
install: all $(BINDIR)
	@echo install not implemented
$(BINDIR):
	- ../mkinsdir.sh $(BINDIR)
# The symlinks target is for my own private use.  It simply creates the object
# directory as a symbolic link to a local disk instead of an NFS mounted one.
symlinks:
	-/bin/rm -f $(ARCH)objs
	mkdir -p $(HOME)/sys/$(ARCH)/objs/slang/src
	ln -s $(HOME)/sys/$(ARCH)/objs/slang/src $(ARCH)objs
#---------------------------------------------------------------------------
# Rules (automatically generated)
#---------------------------------------------------------------------------
