# Internet Junkbuster makefile

# $Id: Makefile,v 1.10 2000/09/17 15:00:32 swa Exp $

# define version (will be wired into the binaries, rpm, etc.)
# 
# update the numbers also in jcc.h manually
#
VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_POINT = 2
VERSION_TAIL  = 10
RPM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_POINT)
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_POINT)-$(VERSION_TAIL)
DISTURL  = \"http://www.waldherr.org/junkbuster/\"

# define the OS
OS_NAME = unix
#OS_NAME = win

# -------------------------------------------------------------------------
#
# don't mess anything below this line unless you know what you are doing!
#
# -------------------------------------------------------------------------

# set the distribution name
ifeq ($(OS_NAME),unix)
DISTNAME = \"unix-$(VERSION)\"
else
ifeq ($(OS_NAME),win)
DISTNAME = \"windows-$(VERSION)\"
else
endif
endif

# -------------------------------------------------------------------------
#
# default values. may be overwritten later.
#
# -------------------------------------------------------------------------
# comment out the next line if you do NOT want to use regular expressions
REGEX = -DREGEX
DEFAULT_CFLAGS = -I. $(REGEX) -DSTDC_HEADERS -DHAVE_STRING
PROG   = junkbuster
O      = o
RM     = rm -f
CC     = gcc
MORE_CFLAGS = -O3 -D_DISTNAME="$(DISTNAME)" -D_DISTURL="$(DISTURL)"
W32_OBJS =
W32_FILES =

# -------------------------------------------------------------------------
#
# OS specific values. may be overwritten later. Not verified lately.
#
# -------------------------------------------------------------------------

# use this for Solaris 2.x
#LDFLAGS = -lnsl -lsocket 

# use these for SunOS 4.x
#LDFLAGS = -nsl
#MORE_CFLAGS = -g -DNOSTRERROR

# use this for HPUX 10.01
# you may get pointer assignment warnings
#MORE_CFLAGS = -Ae -g $(MORE_CFLAGS)

# use these with OS/2 EMX (tested with EMX 0.9c)
#CC        = gcc
#MOREFLAGS = -DOS2
#LDFLAGS   = -lsocket -Zexe -s
#RM        = del
#PROG      = junkbstr         # uncomment if you don't use HPFS

# use this for BSD/OS 3.0
#CC=shlicc2

# use these for mingw32
#PROG        = junkbstr.exe
#MORE_CFLAGS = -DWin32_Winsock -O3
#LDFLAGS     = -lwsock32

# use these for Win32
#PROG     = junkbstr.exe
#MORE_CFLAGS = /nologo -MT -Og
#LDFLAGS = wsock32.lib
#O       = obj
#RM      = del


# -------------------------------------------------------------------------
#
# Windows stuff
#
# -------------------------------------------------------------------------
ifeq ($(OS_NAME),win)
# use these for MS VC++
CC     = cl
PROG     = junkbstr.exe
DEBUG_CFLAGS = /Od /MTd /Zi -D_DEBUG
# DEBUG_CFLAGS = /Og /MT -DNDEBUG
MORE_CFLAGS = /nologo $(DEBUG_CFLAGS) -D_WIN32 -DWin32_Winsock -D_DISTNAME="$(DISTNAME)" -D_DISTURL="$(DISTURL)"
DEBUG_LDFLAGS = /debug
# DEBUG_LDFLAGS = /release
LDFLAGS = /link $(DEBUG_LDFLAGS) /subsystem:windows /machine:ix86 wsock32.lib  kernel32.lib user32.lib gdi32.lib comdlg32.lib shell32.lib comctl32.lib w32.res
W32_OBJS =  win32.$(O) w32taskbar.$(O) w32log.$(O) w32rulesdlg.$(O)
W32_FILES = w32.res
# Use this for the old console mode
LDFLAGS = wsock32.lib
else
endif

# -------------------------------------------------------------------------
#
# Windows stuff (for Cygnus' Win32 environment)
#
# -------------------------------------------------------------------------
# works only single-threaded, ini file must turn on
# single_threaded
#DISTNAME    = \"Windoze-2.0.2-10\"
#DISTURL     = \"http://www.???.org/\"
#PROG        = junkbstr.exe
#MORE_CFLAGS = -D_DISTNAME="$(DISTNAME)" -D_DISTURL="$(DISTURL)" -D_WIN32 -D_CYGWIN -DWin32_Winsock -O3 -s
#LDFLAGS     = -lwsock32

# use these for BeOS
#MORE_CFLAGS = -relax_pointers
#LDFLAGS = -map junkbuster.xMAP

# -------------------------------------------------------------------------
#
# Do not change anything below this line
#
# -------------------------------------------------------------------------
CFLAGS  = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)

# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
linux:
	gmake $(PROG)

# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
rpm-dist:
	@gmake clean
# verify that i'm root
#       needs to be done
	cd .. && tar --exclude "ijb/CVS" -cvzf ijb.tar.gz ijb/
# verify all version strings, FLAGS, etc. in the spec file
	cat ../../SPECS/junkbuster.spec | sed 's/^Version:.*/Version: $(RPM_VERSION)/g' | sed 's/^Release:.*/Release: $(VERSION_TAIL)/g' > /tmp/abc && cp -f /tmp/abc ../../SPECS/junkbuster.spec
	cd ../../ && rpm -ba SPECS/junkbuster.spec
	chmod -R a+r ../../RPMS
	chmod -R a+r ../../SRPMS

# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
win-dist:
	echo bar

# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
tarball-dist:
	@gmake clean
	gmake $(PROG) 
#	remove all objects and create the tarball with the binary
	cd .. && rm -f ijb/a.out ijb/core ijb/*.o ijb/*.obj && tar --exclude "ijb/CVS" -cvzf ../ijb-distribution-$(VERSION).tar.gz ijb/
	chmod a+r ../../ijb-distribution-$(VERSION).tar.gz
	@echo Tarball with binary created.

# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
OBJS =	jcc.$(O) parsers.$(O) filters.$(O) loaders.$(O) bind.$(O) conn.$(O) \
	encode.$(O) ssplit.$(O) socks4.$(O) acl.$(O) gnu_regex.$(O) popup.$(O)\
	$(W32_OBJS)

$(PROG): $(OBJS) $(W32_FILES)
	$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LDFLAGS)
	gmake inifiles

clean:
	$(RM) a.out core *.o *.obj $(PROG)

clobber: clean
	$(RM) junkbuster junkbuster.xMAP junkbstr.exe *.pdb *.lib *.exp

inifiles:
#	copy all files from the Unix to Windows flavour (.ini)
##	and convert EOL (including the that holds preferences of the gui)
##	be careful not to mess around with the sed command
##       Note that the '^M' has to be produced by pressing 'Ctrl-V Ctrl-M'
##       in vi, or 'Ctrl-Q Ctrl-M' in emacs.
#	cat config | sed 's/\n//g' > junkbstr.ini
#	sed 's/$//g' aclfile > saclfile.ini
#	sed 's/$//g' imagelist > simage.ini
#	sed 's/$//g' blocklist > sblock.ini
#	sed 's/$//g' cookiefile > scookie.ini
#	sed 's/$//g' forward > sforward.ini
#	sed 's/$//g' trust > strust.ini
#	sed 's/$//g' popup > spopup.ini
#	now to the conversion within junkbstr.ini 
#	(map blockfile to sblock.ini, etc.)
	cat junkbstr.ini | \
	sed 's/\/etc\/junkbuster\/blocklist/sblock.ini/g' | \
	sed 's/\/etc\/junkbuster\/popup/spopup.ini/g' | \
	sed 's/\/etc\/junkbuster\/cookiefile/scookie.ini/g' | \
	sed 's/\/etc\/junkbuster\/forward/sforward.ini/g' | \
	sed 's/\/etc\/junkbuster\/trust/strust.ini/g' | \
	sed 's/\/etc\/junkbuster\/aclfile/sacl.ini/g' | \
	sed 's/\/var\/log\/junkbuster\/jarfile/jar.log/g' | \
	sed 's/\/var\/log\/junkbuster\/junkbuster/junkbstr.log/g' | \
	sed 's/\/etc\/junkbuster\/imagelist/simage.ini/g' > /tmp/def
	cp -f /tmp/def junkbstr.ini


# $Id: Makefile,v 1.10 2000/09/17 15:00:32 swa Exp $
# Written and copyright 1997 Anonymous Coders and Junkbusters Corporation.
# Distributed under the GNU General Public License; see the README file.

# This code comes with NO WARRANTY. http://www.junkbusters.com/ht/en/gpl.html
