srcdir		= @srcdir@
VPATH  		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
BINDIR 		= $(exec_prefix)/bin
INSTALL		= @INSTALL@
BINRM		= @BINRM@

# For most systems, these OPTIONS will suffice.  Exceptions:
#
#	* If you're on a Stardent, add  -43
#	* If you're running EP/IX, you may need to add  -systype bsd43
#	  but try it without it first.
OPTIONS= 

# For this, DEFINES is usually ok as-is.  Try it without any of these
# first; if some stuff fails or shows up undefined, then come back and
# add 'em.  Also please drop me a line if you had to add anything...ideally
# things will reach a point where this whole section will be unnecessary.
#
#     * if you want to include the debugging code (so you
#       can help with problem-solving if any crop up), add    -DDEBUG
#     * if you're running Interactive Unix, add		      -DISC
#     * if you're running a USG (System V.2) system, add      -DUSG
#     * if you're running UTS, add			      -DUTS
DEFINES= -DDEBUG 

# The default Archie server; choose one of:
#    archie.ans.net		(USA [NY])  -- no longer valid
#    archie.rutgers.edu		(USA [NJ])
#    archie.sura.net		(USA [MD])
#    archie.unl.edu		(USA [NE])
#    archie.mcgill.ca		(Canada)
#    archie.funet.fi		(Finland/Mainland Europe)
#    archie.au			(Australia)
#    archie.doc.ic.ac.uk	(Great Britain/Ireland)
#    archie.wide.ad.jp		(Japan)
#    archie.ncu.edu.tw		(Taiwan)
#
# Note this only applies to the command-line client; to change the
# default for the Emacs lisp version, set the archie-server variable.
#ARCHIE= archie.ans.net
ARCHIE= archie.sura.net

#	Usually LDFLAGS is empty; if, after you build this, archie
#	 complains that it can't resolve ARCHIE.ANS.NET (or whatever
#	 you defined ARCHIE_HOST as), you need to add `-lresolv'.
#
#	* If you need the PW library (e.g. A/UX), add -lPW
LDFLAGS=
# If you're using ISC, use:
#LDFLAGS= -linet
# If you're using Wallongong TCP/IP on an AT&T box, use:
#LDFLAGS= -lnet -lnsl_s
# If you're using UTS, use:
#LDFLAGS= -lsocket
# If you're using System V Release 4, use:
#LDFLAGS= -L/usr/ucblib -lucb -lsockdns -lnsl
# If you're using Solaris 2.x (don't use /usr/ucb/cc!), use:
#LDFLAGS= -lnsl -lsocket
# If you're using Consensus SVR4, use:
#LDFLAGS= -lnsl_i -lsocket -lucb
# If you're using Dynix/PTX, use:
#LDFLAGS= -lsocket -linet -lnsl -lPW

CC		= @CC@
SOCKS_FLAGS  	= -DSOCKS -DINCLUDE_PROTOTYPES
CDEBUG_FLAGS 	= @CDEBUG_FLAGS@
EXTRA_CFLAGS	=
CFLAGS       	= -I$(srcdir) -I../../include -I$(srcdir)/../../include @CFLAGS@ $(CDEBUG_FLAGS) $(OPTIONS) $(DEFINES) $(SOCKS_FLAGS) -DARCHIE_HOST=\"$(ARCHIE)\" $(EXTRA_CFLAGS)
LIBS         	= -L../../lib -lsocks5 @LDFLAGS@ @EXPORT_LDFLAGS@ @LIBS@ 

VERSION=1.4.1

.SUFFIXES: .c .o
.c.o:
	$(CC) ${CFLAGS} -c $(srcdir)/$*.c

OBJS=	aquery.o archie.o atalloc.o dirsend.o get_pauth.o get_vdir.o getopt.o getopt1.o \
	perrmesg.o procquery.o ptalloc.o regex.o stcopy.o support.o vlalloc.o vl_comp.o

all: Makefile archie

Makefile: $(srcdir)/Makefile.in ../../config.status
	(cd ../..; CONFIG_FILES=clients/archie/Makefile CONFIG_HEADERS= ./config.status)

archie: $(OBJS) ../../lib/libsocks5.a
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)

archie.doc: archie.man
	nroff -man archie.man | tr '\010' _ | sed -e s/__//g > archie.doc

install: archie
	$(INSTALL) -m 111 archie $(BINDIR)/rarchie

# Regain precompiled state
clean: 
	-$(BINRM) $(OBJS) archie archie.doc core 

# Regain distribution state
distclean: clean
	-$(BINRM) Makefile *~ #*# *.bak

$(OBJS): archie.h pmachine.h pcompat.h 
procquery.o: copyright.h

aquery.o: aquery.c
archie.o: archie.c 
atalloc.o: atalloc.c 
dirsend.o: dirsend.c 
get_pauth.o: get_pauth.c 
get_vdir.o: get_vdir.c 
getopt.o: getopt.c 
getopt1.o: getopt1.c 
perrmesg.o: perrmesg.c 
procquery.o: procquery.c 
ptalloc.o: ptalloc.c 
regex.o: regex.c 
stcopy.o: stcopy.c 
support.o: support.c
vlalloc.o: vlalloc.c 
vl_comp.o: vl_comp.c

