#
# $Id: //pentools/main/backstealth/makefile#12 $
#
#
# written by:	Stephen J. Friedl
#               Software Consultant
#               Tustin, California USA
#               steve@unixwiz.net
#
#	Simple makefile for backstealth and the associated DLL.
#	This requires GNU make, sorry.
#

CLEAN =

# ------------------------------------------------------------------------
# C++ COMPILER FLAGS
#
# We're anal about our compiler flags, sorry.
#

CDEFS = -DUNICODE -D_UNICODE	# also used by lint flags

CFLAGS = $(CDEFS)

CFLAGS += /nologo	# turn off the damn copyright msg
CFLAGS += /W4		# lots of warnings
CFLAGS += /WX		# warnings are considered errors
CFLAGS += /MD		# use MSVCRT.DLL (no static libc)
CFLAGS += /Gz		# use __stdcall calling convention
CFLAGS += /GF		# enable readonly string pooling
CFLAGS += /YXbscommon.h	# precompiled header support

all : bs.exe mydll.dll enumwin.exe

CLEAN += bs.exe bs.obj
bs.exe : bs.obj bslib.lib
	link /nologo /out:$@ $^ user32.lib advapi32.lib

CLEAN += enumwin.exe enumwin.obj bslib.lib
enumwin.exe : enumwin.obj
	link /nologo /out:$@ $^ user32.lib 

CLEAN += mydll.dll mydll.obj mydll.exp mydll.lib
mydll.dll : mydll.obj bslib.lib
	link /nologo /dll /out:$@ $^ wsock32.lib

%.obj : %.cpp
	$(strip cl /c $(CFLAGS) $*.cpp)

CLEAN += *.pch

clean :
	rm -f $(CLEAN)

bs.obj mydll.obj : injdata.h
bs.obj : getopt.i

# ------------------------------------------------------------------------
# HELPER LIBRARY
#
# We have a handful of small functions that we wish to use in more than
# one place, so we park them in this little library.
#
LOBJS	= dieA.obj dieW.obj \
	  odprintfA.obj odprintfW.obj \
	  stripA.obj stripW.obj \
	  enable_priv.obj

CLEAN += $(LOBJS)

bslib.lib : $(LOBJS)
	lib /nologo /out:$@ $(LOBJS)

# ------------------------------------------------------------------------
# We are pretty fanatic about using PC-Lint on our code, and this part of
# the makefile deals with that 
#
ifdef PCLINTDIR

LFLAGS =			# lint flags

LFLAGS += +ffo			# flush output after each msg
LFLAGS += -D_MT			# corresponds to /MD
LFLAGS += -i$(PCLINTDIR)/lnt	# where to find our files
LFLAGS += $(CDEFS)

.PHONY: lint lint_lib lint_bs lint_mydll

lint : lint_lib lint_bs lint_mydll

lint_lib : $(LOBJS:.obj=.cpp)
	$(strip $(PCLINTDIR)\lint-nt -u $(LFLAGS) local.lnt $^)

lint_bs : bs.cpp
	$(strip $(PCLINTDIR)\lint-nt -u $(LFLAGS) local.lnt $^)

lint_mydll : mydll.cpp
	$(strip $(PCLINTDIR)\lint-nt -u $(LFLAGS) local.lnt $^)

lint_enumwin : enumwin.cpp
	$(strip $(PCLINTDIR)\lint-nt -u $(LFLAGS) local.lnt $^)

endif
