#
#  Makefile for Socks5++
#

# installation target
BINDIR=/usr/local/bin

# items to install
BINSRC=socks5pp s5resolver s5dnstls s5host

# build settings
CPPDEBUG=-ggdb
WARNINGS=-Wno-switch
TARGETS=socks5pp s5resolver # ut_resolver popen3_test
CPP=g++

# template for C++ builds
.cc.o:
	$(CPP) $(CPPDEBUG) $(CXXFLAGS) $(WARNINGS) -c $<

# the 'all' and 'rebuild' targets
all: $(TARGETS)
rebuild: clean all

# C++ targets
socks5pp: %: %.o readhosts.o ipchecks.o
	$(CPP) -o $@ $@.o readhosts.o ipchecks.o
s5resolver: %: %.o
	$(CPP) -o $@ $@.o

# clean the build
clean:
	rm -f $(TARGETS) Makefile.bak *.o

# update dependencies
dep depend:
	makedepend -Y *.cc 2>/dev/null

# strip the outputs
strip: all
	strip --strip-unneeded $(TARGETS)

# install targets
install: strip
	# install the compiled executables in $(BINDIR)
	for i in $(BINSRC) ; do install -o root -g root -m 0755 $$i $(BINDIR) ; done

# uninstall targets
uninstall:
	for i in $(BINSRC) ; do rm -vf $(BINDIR)/$$i ; done

# DO NOT DELETE

readhosts.o: readhosts.h fastsplit.h ipchecks.h
s5resolver.o: resname.h
socks5pp.o: addrutils.h ipchecks.h connection.h readhosts.h rmanager.h
socks5pp.o: resolver.h fastsplit.h popen3.h getrss.h s5utils.h pool.h
