PERL-Compatible Regular Expressions – Windows Makefile
(Originally published January 5, 2009)
Recently, for a project at work I needed a 64-bit Windows version of Perl Compatible Regular Expressions. I didn’t want to use a binary built by a third party, so I chose to build it from the latest sources myself, mainly for reproducibility. Also, I don’t know if a 64-bit Windows binary of PCRE even exists.
Unfortunately, PCRE doesn’t have much support for Windows builds, much less a 64-bit build. 64-bit Visual C++ dictates at least VS 2005 or greater. In my case, I am using VS 2005. I created a makefile for this version by creating a project in Visual Studio 6, exporting a makefile, and then making necessary modifications to the compiler and linker flags in the makefile to get what I wanted. VS 2005 cannot generate makefiles, so it’s good to have a VS 6 kicking around for that purpose.
Here is my makefile, in case it’s of any use to you. Note that I have not built the tests – just the DLL and import library. You will probably want to copy it out and name it ‘Makefile’.
# Microsoft Developer Studio Generated NMAKE File, Based on pcre.dsp
!IF “$(CFG)” == “”
CFG=pcre – x64 Debug
!MESSAGE No configuration specified. Defaulting to pcre – x64 Debug.
!ENDIF
!IF “$(CFG)” != “pcre – x64 Release” && “$(CFG)” != “pcre – x64 Debug”
!MESSAGE Invalid configuration “$(CFG)” specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f “pcre.mak” CFG=”pcre – x64 Debug”
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE “pcre – x64 Release” (based on “Win64 Dynamic-Link Library”)
!MESSAGE “pcre – x64 Debug” (based on “Win64 Dynamic-Link Library”)
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF “$(OS)” == “Windows_NT”
NULL=
!ELSE
NULL=nul
!ENDIF
!IF “$(CFG)” == “pcre – x64 Release”
OUTDIR=.Release
INTDIR=.Release
# Begin Custom Macros
OutDir=.Release
# End Custom Macros
ALL : “$(OUTDIR)pcre.dll”
CLEAN :
-@erase “$(INTDIR)pcre_chartables.obj”
-@erase “$(INTDIR)pcre_compile.obj”
-@erase “$(INTDIR)pcre_config.obj”
-@erase “$(INTDIR)pcre_dfa_exec.obj”
-@erase “$(INTDIR)pcre_exec.obj”
-@erase “$(INTDIR)pcre_fullinfo.obj”
-@erase “$(INTDIR)pcre_get.obj”
-@erase “$(INTDIR)pcre_globals.obj”
-@erase “$(INTDIR)pcre_info.obj”
-@erase “$(INTDIR)pcre_maketables.obj”
-@erase “$(INTDIR)pcre_newline.obj”
-@erase “$(INTDIR)pcre_ord2utf8.obj”
-@erase “$(INTDIR)pcre_refcount.obj”
-@erase “$(INTDIR)pcre_study.obj”
-@erase “$(INTDIR)pcre_tables.obj”
-@erase “$(INTDIR)pcre_try_flipped.obj”
-@erase “$(INTDIR)pcre_ucd.obj”
-@erase “$(INTDIR)pcre_valid_utf8.obj”
-@erase “$(INTDIR)pcre_version.obj”
-@erase “$(INTDIR)pcre_xclass.obj”
-@erase “$(OUTDIR)it_pcre.exp”
-@erase “$(OUTDIR)it_pcre.lib”
-@erase “$(OUTDIR)it_pcre1_vc80x64.dll”
-@erase “$(OUTDIR)it_pcre1_vc80x64.ilk”
-@erase “$(OUTDIR)it_pcre1_vc80x64.pdb”
“$(OUTDIR)” :
if not exist “$(OUTDIR)/$(NULL)” mkdir “$(OUTDIR)”
CPP=cl.exe
CPP_PROJ=/nologo /c /I “.” /D “PCRE_EXPORTS” /D “HAVE_CONFIG_H” /D “NDEBUG” /Fo”$(INTDIR)” /Fd”$(INTDIR)”
/RTC1
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /mktyplib203 /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o”$(OUTDIR)pcre.bsc”
BSC32_SBRS=
LINK32=link.exe
LINK32_FLAGS=/nologo /dll /incremental:no /pdb:”$(OUTDIR)pcre.pdb” /debug /machine:x64 /out:”$(OUTDIR)pcre.dll”
/implib:”$(OUTDIR)pcre.lib”
LINK32_OBJS=
“$(INTDIR)pcre_chartables.obj”
“$(INTDIR)pcre_compile.obj”
“$(INTDIR)pcre_config.obj”
“$(INTDIR)pcre_dfa_exec.obj”
“$(INTDIR)pcre_exec.obj”
“$(INTDIR)pcre_fullinfo.obj”
“$(INTDIR)pcre_get.obj”
“$(INTDIR)pcre_globals.obj”
“$(INTDIR)pcre_info.obj”
“$(INTDIR)pcre_maketables.obj”
“$(INTDIR)pcre_newline.obj”
“$(INTDIR)pcre_ord2utf8.obj”
“$(INTDIR)pcre_refcount.obj”
“$(INTDIR)pcre_study.obj”
“$(INTDIR)pcre_tables.obj”
“$(INTDIR)pcre_try_flipped.obj”
“$(INTDIR)pcre_ucd.obj”
“$(INTDIR)pcre_valid_utf8.obj”
“$(INTDIR)pcre_version.obj”
“$(INTDIR)pcre_xclass.obj”
“$(OUTDIR)pcre.dll” : “$(OUTDIR)” $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF “$(CFG)” == “pcre – x64 Debug”
OUTDIR=.Debug
INTDIR=.Debug
# Begin Custom Macros
OutDir=.Debug
# End Custom Macros
ALL : “$(OUTDIR)pcre.dll”
CLEAN :
-@erase “$(INTDIR)pcre_chartables.obj”
-@erase “$(INTDIR)pcre_compile.obj”
-@erase “$(INTDIR)pcre_config.obj”
-@erase “$(INTDIR)pcre_dfa_exec.obj”
-@erase “$(INTDIR)pcre_exec.obj”
-@erase “$(INTDIR)pcre_fullinfo.obj”
-@erase “$(INTDIR)pcre_get.obj”
-@erase “$(INTDIR)pcre_globals.obj”
-@erase “$(INTDIR)pcre_info.obj”
-@erase “$(INTDIR)pcre_maketables.obj”
-@erase “$(INTDIR)pcre_newline.obj”
-@erase “$(INTDIR)pcre_ord2utf8.obj”
-@erase “$(INTDIR)pcre_refcount.obj”
-@erase “$(INTDIR)pcre_study.obj”
-@erase “$(INTDIR)pcre_tables.obj”
-@erase “$(INTDIR)pcre_try_flipped.obj”
-@erase “$(INTDIR)pcre_ucd.obj”
-@erase “$(INTDIR)pcre_valid_utf8.obj”
-@erase “$(INTDIR)pcre_version.obj”
-@erase “$(INTDIR)pcre_xclass.obj”
-@erase “$(OUTDIR)it_pcre.exp”
-@erase “$(OUTDIR)it_pcre.lib”
-@erase “$(OUTDIR)it_pcre1_vc80x64.dll”
-@erase “$(OUTDIR)it_pcre1_vc80x64.ilk”
-@erase “$(OUTDIR)it_pcre1_vc80x64.pdb”
“$(OUTDIR)” :
if not exist “$(OUTDIR)/$(NULL)” mkdir “$(OUTDIR)”
CPP=cl.exe
CPP_PROJ=/nologo /c /I “.” /D “PCRE_EXPORTS” /D “HAVE_CONFIG_H” /Fo”$(INTDIR)” /Fd”$(INTDIR)” /RTC1
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /mktyplib203 /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o”$(OUTDIR)pcre.bsc”
BSC32_SBRS=
LINK32=link.exe
LINK32_FLAGS=/nologo /dll /incremental:yes /pdb:”$(OUTDIR)pcre.pdb” /debug /machine:x64
/out:”$(OUTDIR)pcre.dll” /implib:”$(OUTDIR)pcre.lib”
LINK32_OBJS=
“$(INTDIR)pcre_chartables.obj”
“$(INTDIR)pcre_compile.obj”
“$(INTDIR)pcre_config.obj”
“$(INTDIR)pcre_dfa_exec.obj”
“$(INTDIR)pcre_exec.obj”
“$(INTDIR)pcre_fullinfo.obj”
“$(INTDIR)pcre_get.obj”
“$(INTDIR)pcre_globals.obj”
“$(INTDIR)pcre_info.obj”
“$(INTDIR)pcre_maketables.obj”
“$(INTDIR)pcre_newline.obj”
“$(INTDIR)pcre_ord2utf8.obj”
“$(INTDIR)pcre_refcount.obj”
“$(INTDIR)pcre_study.obj”
“$(INTDIR)pcre_tables.obj”
“$(INTDIR)pcre_try_flipped.obj”
“$(INTDIR)pcre_ucd.obj”
“$(INTDIR)pcre_valid_utf8.obj”
“$(INTDIR)pcre_version.obj”
“$(INTDIR)pcre_xclass.obj”
“$(OUTDIR)pcre.dll” : “$(OUTDIR)” $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF “$(NO_EXTERNAL_DEPS)” != “1″
!IF EXISTS(“pcre.dep”)
!INCLUDE “pcre.dep”
!ELSE
!MESSAGE Warning: cannot find “pcre.dep”
!ENDIF
!ENDIF
!IF “$(CFG)” == “pcre – x64 Release” || “$(CFG)” == “pcre – x64 Debug”
SOURCE=.pcre_chartables.c
“$(INTDIR)pcre_chartables.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_compile.c
“$(INTDIR)pcre_compile.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_config.c
“$(INTDIR)pcre_config.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_dfa_exec.c
“$(INTDIR)pcre_dfa_exec.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_exec.c
“$(INTDIR)pcre_exec.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_fullinfo.c
“$(INTDIR)pcre_fullinfo.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_get.c
“$(INTDIR)pcre_get.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_globals.c
“$(INTDIR)pcre_globals.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_info.c
“$(INTDIR)pcre_info.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_maketables.c
“$(INTDIR)pcre_maketables.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_newline.c
“$(INTDIR)pcre_newline.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_ord2utf8.c
“$(INTDIR)pcre_ord2utf8.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_refcount.c
“$(INTDIR)pcre_refcount.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_study.c
“$(INTDIR)pcre_study.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_tables.c
“$(INTDIR)pcre_tables.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_try_flipped.c
“$(INTDIR)pcre_try_flipped.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_ucd.c
“$(INTDIR)pcre_ucd.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_valid_utf8.c
“$(INTDIR)pcre_valid_utf8.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_version.c
“$(INTDIR)pcre_version.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.pcre_xclass.c
“$(INTDIR)pcre_xclass.obj” : $(SOURCE) “$(INTDIR)”
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF