###########################################################################
#
# Usage: NMAKE -f Makefile.win APACHE={httpd installion dir} PCRE={pcre dir} LIBXML2={LibXML2 dir} [ LUA={Lua dir} ]
#
!IF "$(APACHE)" == "" || "$(PCRE)" == "" || "$(LIBXML2)" == "" || "$(CURL)" == ""
!ERROR NMAKE arguments: APACHE=dir PCRE=dir LIBXML2=dir CURL=dir are required to build mod_security2 for Windows
!ENDIF
# Linking libraries
LIBS = $(APACHE)\lib\libapr-1.lib \
$(APACHE)\lib\libaprutil-1.lib \
$(PCRE)\pcre.lib \
$(CURL)\libcurl.lib \
$(LIBXML2)\win32\bin.msvc\libxml2.lib \
"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" \
"oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "ws2_32.lib" \
"iphlpapi.lib"
# $(SSDEEP)\fuzzy.lib \
###########################################################################
###########################################################################
CC = CL
LINK = link.exe
MT = mt
DEFS = /nologo /O2 /LD /W3 /wd4244 /wd4018 -DWITH_YAJL -DWIN32 -DWINNT -Dinline=APR_INLINE -DAP_DECLARE_STATIC -D_MBCS -D$(VERSION)
DLL = ModSecurityIIS.dll
INCLUDES = -I. -I.. \
-I$(YAJL)\.. \
-I$(PCRE)\include -I$(PCRE) \
-I$(LIBXML2)\include \
-I$(CURL)\include -I$(CURL) \
-I$(APACHE)\include \
-I..\apache2 \
-I..\standalone
# Enables support for SecRemoteRules and external resources.
DEFS=$(DEFS) -DWITH_CURL -DWITH_REMOTE_RULES
# -I$(SSDEEP) \
# Lua is optional
!IF "$(LUA)" != ""
LIBS = $(LIBS) $(LUA)\lua5.1.lib
DEFS=$(DEFS) -DWITH_LUA
INCLUDES = $(INCLUDES) -I$(LUA)\include -I$(LUA) \
!ENDIF
# Yajl/Json is optional
!IF "$(YAJL)" != ""
LIBS = $(LIBS) $(YAJL)\lib\yajl.lib
DEFS=$(DEFS) -DWITH_YAJL
INCLUDES = $(INCLUDES) -I$(YAJL)\include -I$(YAJL) \
!ENDIF
# ssdeep is optional
# !IF "$(SSDEEP)" != ""
# LIBS = $(LIBS) $(SSDEEP)\fuzzy.lib
# DEFS=$(DEFS) -DWITH_SSDEEP
# INCLUDES = $(INCLUDES) -I$(SSDEEP)\include -I$(SSDEEP) \
# !ENDIF
CFLAGS= -MD /Zi $(INCLUDES) $(DEFS)
LDFLAGS = /DEF:"mymodule.def" /DEBUG /OPT:REF /OPT:ICF /MANIFEST /ManifestFile:"ModSecurityIIS.dll.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /TLBID:1 /DYNAMICBASE /NXCOMPAT
OBJS1 = mod_security2.obj apache2_config.obj apache2_io.obj apache2_util.obj \
re.obj re_operators.obj re_actions.obj re_tfns.obj re_variables.obj \
msc_logging.obj msc_xml.obj msc_multipart.obj modsecurity.obj \
msc_parsers.obj msc_util.obj msc_pcre.obj persist_dbm.obj \
msc_reqbody.obj msc_geo.obj msc_gsb.obj msc_unicode.obj acmp.obj msc_lua.obj \
msc_release.obj msc_crypt.obj msc_tree.obj \
msc_status_engine.obj \
msc_json.obj \
msc_remote_rules.obj
OBJS2 = api.obj buckets.obj config.obj filters.obj hooks.obj regex.obj server.obj
OBJS3 = main.obj moduleconfig.obj mymodule.obj
OBJS4 = libinjection_html5.obj \
libinjection_sqli.obj \
libinjection_xss.obj
all: $(DLL)
dll: $(DLL)
$(OBJS1): ..\apache2\$*.c
$(CC) $(CFLAGS) -c ..\apache2\$*.c -Fo$@
$(OBJS4): ..\apache2\libinjection\$*.c
$(CC) $(CFLAGS) -c ..\apache2\libinjection\$*.c -Fo$@
$(OBJS2): ..\standalone\$*.c
$(CC) $(CFLAGS) -c ..\standalone\$*.c -Fo$@
.cpp.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
$(DLL): $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4)
$(LINK) $(LDFLAGS) $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(LIBS)
IF EXIST $(DLL).manifest $(MT) -manifest $(DLL).manifest -outputresource:$(DLL);#1
clean:
del /f *.obj
del /f *.dll
del /f *.exp
del /f *.lib