#  securelib:  a package to enhance network security.
#
#  Written by William LeFebvre, EECS Department, Northwestern University
#  Internet address:  phil@eecs.nwu.edu

#  SHLIB is the location of Sun's "shared library" option.

SHLIB = /usr/lib/shlib.etc

#  DESTDIR is the directory where you want the secure libc installed
#  NOTE:  it is NOT recommended that you install it in /usr/lib!

DESTDIR = /usr/lib/secure

# CONFFILE is the path name of the configuration file.  See the file
# securelib.conf.ex in this distribution for an example.  Then create
# your own securelib.conf.  The Makefile will copy it in to CONFFILE
# during the installation step.

CONFFILE = /etc/securelib.conf

OBJS = accept.o recvfrom.o recvmsg.o _okaddr.o

FILES = README Makefile accept.c recvfrom.c recvmsg.c _okaddr.c \
	patchlevel.h extract_lib install_newlib start.X securelib.conf.ex

CFLAGS=-pic -DCONF_FILE=\"$(CONFFILE)\"

all: shlib

shlib: objs
	./extract_lib $(SHLIB)
	cp $(OBJS) $(SHLIB)/tmp
	(cd $(SHLIB); make)
	touch shlib

objs: $(OBJS)
	touch objs

install: shlib securelib.conf
	./install_newlib $(SHLIB) $(DESTDIR)
	sed -e "s|%DESTDIR%|$(DESTDIR)|" start.X >$(DESTDIR)/start
	chmod +x $(DESTDIR)/start
	cp securelib.conf $(CONFFILE)

securelib.conf:
	@echo "You need to create your own 'securelib.conf' file before"
	@echo "running 'make install'.  Please read the instructions!"
	@exit 1

clean:
	rm -f $(OBJS) shlib objs

tar:
	rm -f securelib.tar
	tar cvf securelib.tar $(FILES)
