#CC=gcc

SOCKS_LIB=../lib/libsocks.a
IDENT_LIB=../libident/libident.a

# Directory into which sockd and test_sockd_conf programs
# will be installed:
SERVER_BIN_DIR=/usr/etc

# Directory into which the man page files of sockd and test_sockd_conf
# will be installed:
MAN_DEST_DIR=/usr/local/man

INC=../include/socks.h

# Remember to include -Dindex=strchr in OTHER_CFLAGS if
# you don't have index() (Sys-V camp)

# IRIX should use
#OTHER_CFLAGS=-cckr
#RESOLV_LIB=-lsun

# HPUX should use
#OTHER_CFLAGS=-Ac

# AIX should use
#RESOLV_LIB=-lbsd
#OTHER_CFLAGS=-D_BSD -D_NONSTD_TYPES -D_NO_PROTO -DAIX

# SOLARIS should use
#RESOLV_LIB=-lresolv -lnsl -lsocket
#OTHER_CFLAGS=-DSOLARIS -Dindex=strchr -Drindex=strrchr -DUSE_DIRENT 

# Interactive Systems Unix should use
# OTHER_CFLAGS = -DISC

# LINUX should use
#CC=gcc
#RESOLV_LIB=
#OTHER_CFLAGS=-traditional -DLINUX 

# UnixWare should use
#RESOLV_LIB=-lresolv -lnsl -lsocket
#OTHER_CFLAGS= -DSOLARIS -Dindex=strchr -Drindex=strrchr -DUSE_DIRENT
#RANLIB=/bin/true
#INSTALL=bsdinstall

CFLAGS = -I../include -I../libident -g ${OTHER_CFLAGS} 

# The 'install' command is assumed to be the BSD variety (using -m to
# set the file mode). If the default 'install' on your system doesn't
# do that, you have to either specify an alternative one in the line below
# (e.g., /usr/ucb/install) or modify the install instructions.
INSTALL= install

#==================================================

SRC=sockd.c
OBJ=sockd.o
PROG=sockd test_sockd_conf flip_cfmasks

all: echocwd $(PROG)

sockd: $(SRC) $(INC) $(SOCKS_LIB) $(IDENT_LIB)
	$(CC) $(CFLAGS) -o $@ $(SRC) $(SOCKS_LIB) $(IDENT_LIB) $(RESOLV_LIB)

test_sockd_conf: $(SRC) $(INC) $(SOCKS_LIB)
	$(CC) $(CFLAGS) -DTEST -o $@ $(SRC) $(SOCKS_LIB) $(RESOLV_LIB)

flip_cfmasks: flip_cfmasks.c $(INC) $(SOCKS_LIB)
	$(CC) $(CFLAGS) -o $@ flip_cfmasks.c $(SOCKS_LIB) $(RESOLV_LIB)

install: echocwd sockd test_sockd_conf
	$(INSTALL) -m 111 sockd $(SERVER_BIN_DIR)
	$(INSTALL) -m 111 test_sockd_conf $(SERVER_BIN_DIR)
	$(INSTALL) -m 111 flip_cfmasks $(SERVER_BIN_DIR)

install.man: echocwd
	$(INSTALL) -m 444 sockd.8 $(MAN_DEST_DIR)/man8
	$(INSTALL) -m 444 test_sockd_conf.8 $(MAN_DEST_DIR)/man8
	$(INSTALL) -m 444 sockd.conf.5 $(MAN_DEST_DIR)/man5
	$(INSTALL) -m 444 sockd.route.5 $(MAN_DEST_DIR)/man5
	

clean: echocwd
	rm -f $(OBJ) $(PROG) core

echocwd:
	@pwd
