#CC=gcc
SOCKS_LIB=../lib/libsocks.a
IDENT_LIB=../libident/libident.a

# Directory into which sockd and test_sockd_conf programs
# will be installed:
BIN_DEST_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/man8

INC=../include/socks.h

# IRIX should use the next two lines:
#CCKR=-cckr
#RESOLV_LIB=-lsun

CFLAGS=-I../include -I../libident -g $(CCKR)

# 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 shell_cmd.c percent_x.c
OBJ=sockd.o shell_cmd.o percent_x.o
PROG=sockd test_sockd_conf

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)

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

install.man: echocwd sockd.8 test_sockd_conf.8
	$(INSTALL) -m 444 sockd.8 $(MAN_DEST_DIR)
	$(INSTALL) -m 444 test_sockd_conf $(MAN_DEST_DIR)

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

echocwd:
	@pwd
