-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NMake Makefiles for Visual Studio builds
This adds a set of Visual Studio NMake Makefiles that can be used to build libpsl, either as a DLL or as a static .lib. Building of the psl tool and the tests in tests/ (but not fuzz, since those tests use fmemopen(), that is not supported on Windows) are also supported. A simplified "install" target is provided that copies the build results to a default or set prefix with the pkg-config file so that other packages (such as libsoup) with build systems that depend on this .pc file can be built. These files make use of autotools stuff so that they have the up-to-date version info upon a release. Currently, only builds using the ICU runtime/builtin or with no runtime/builtin are supported with Visual Studio builds.
- Loading branch information
Showing
17 changed files
with
1,044 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
EXTRA_DIST = \ | ||
build-rules-msvc.mak \ | ||
config.h.win32 \ | ||
config-msvc.mak \ | ||
create-lists.bat \ | ||
create-lists-msvc.mak \ | ||
detectenv-msvc.mak \ | ||
generate-msvc.mak \ | ||
install-msvc.mak \ | ||
libpsl-pc.py \ | ||
Makefile.vc \ | ||
pc_base.py \ | ||
replace.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# NMake Makefile for building libpsl Windows | ||
|
||
# The items below this line should not be changed, unless one is maintaining | ||
# the NMake Makefiles. Customizations can be done in the following NMake Makefile | ||
# portions (please see comments in the these files to see what can be customized): | ||
# | ||
# detectenv-msvc.mak | ||
# config-msvc.mak | ||
|
||
!include detectenv-msvc.mak | ||
|
||
# Include the Makefile portion that enables features based on user input | ||
!include config-msvc.mak | ||
|
||
!if "$(VALID_CFGSET)" == "TRUE" | ||
|
||
# Include the Makefile portion to convert the source and header lists | ||
# into the lists we need for compilation and introspection | ||
!include create-lists-msvc.mak | ||
|
||
all: $(PSL_LIB) $(PSL_UTILS) build-info | ||
|
||
tests: $(PSL_TEST_DATA) $(PSL_TESTS) build-info | ||
|
||
# Include the build rules for sources, DLLs and executables | ||
!include build-rules-msvc.mak | ||
|
||
# Include the rules for build directory creation and code generation | ||
!include generate-msvc.mak | ||
|
||
# Include the Makefile portion that enables installing the build results | ||
!include install-msvc.mak | ||
!else | ||
!error No CFG (or invalid CFG) value specified. Valid values are release or debug. | ||
!endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# NMake Makefile portion for compilation rules | ||
# Items in here should not need to be edited unless | ||
# one is maintaining the NMake build files. The format | ||
# of NMake Makefiles here are different from the GNU | ||
# Makefiles. Please see the comments about these formats. | ||
|
||
# Inference rules for compiling the .obj files. | ||
# Used for libs and programs with more than a single source file. | ||
# Format is as follows | ||
# (all dirs must have a trailing '\'): | ||
# | ||
# {$(srcdir)}.$(srcext){$(destdir)}.obj:: | ||
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<< | ||
# $< | ||
# << | ||
|
||
{..\src\}.c{$(CFG)\$(PLAT)\libpsl\}.obj:: | ||
$(CC) $(BASE_CFLAGS) $(PSL_ADDITIONAL_CFLAGS) $(PSL_INCLUDES) /Fo$(CFG)\$(PLAT)\libpsl\ /c @<< | ||
$< | ||
<< | ||
|
||
{..\tools\}.c{$(CFG)\$(PLAT)\psl\}.obj:: | ||
$(CC) $(BASE_CFLAGS) $(PSL_INCLUDES) /Fo$(CFG)\$(PLAT)\psl\ /c @<< | ||
$< | ||
<< | ||
|
||
# Make sure we generate suffixes_dafsa.c before trying to compile psl.c | ||
$(CFG)\$(PLAT)\libpsl\psl.obj: $(CFG)\$(PLAT)\libpsl\suffixes_dafsa.c | ||
|
||
# Inference rules for building the test programs | ||
# Used for programs with a single source file. | ||
# Format is as follows | ||
# (all dirs must have a trailing '\'): | ||
# | ||
# {$(srcdir)}.$(srcext){$(destdir)}.exe:: | ||
# $(CC)|$(CXX) $(cflags) $< /Fo$*.obj /Fe$@ [/link $(linker_flags) $(dep_libs)] | ||
|
||
{..\tests\}.c{$(CFG)\$(PLAT)\}.exe: | ||
@if not exist $(PSL_UTILS) $(MAKE) -f Makefile.vc $(PSL_MAKE_OPTIONS) $(PSL_UTILS) | ||
@if not exist $(CFG)\$(PLAT)\tests $(MAKE) -f Makefile.vc $(PSL_MAKE_OPTIONS) $(CFG)\$(PLAT)\tests | ||
$(CC) $(PSL_TEST_CFLAGS) $(PSL_INCLUDES) /Fo$(CFG)\$(PLAT)\tests\ /Fe$@ \ | ||
$< /link $(LDFLAGS) $(PSL_LIB) $(PSL_ADDITIONAL_LIBS) | ||
@if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 | ||
|
||
# Rules for building .lib files | ||
!ifdef STATIC | ||
$(PSL_LIB): $(CFG)\$(PLAT)\libpsl ..\config.h $(libpsl_OBJS) | ||
lib $(ARFLAGS) /out:$@ @<< | ||
$(libpsl_OBJS) | ||
<< | ||
|
||
!else | ||
$(PSL_LIB): $(PSL_DLL) | ||
!endif | ||
|
||
# Rules for linking DLLs | ||
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds): | ||
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items) | ||
# link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] [/implib:$(lib_name_if_needed)] -out:$@ @<< | ||
# $(dependent_objects) | ||
# << | ||
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 | ||
|
||
$(PSL_DLL): ..\config.h $(libpsl_OBJS) | ||
link $(LDFLAGS) $(PSL_ADDITIONAL_LIBS) /DLL /out:$@ @<< | ||
$(libpsl_OBJS) | ||
<< | ||
@if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 | ||
|
||
# Rules for linking Executables | ||
# Format is as follows (the mt command is needed for MSVC 2005/2008 builds): | ||
# $(dll_name_with_path): $(dependent_libs_files_objects_and_items) | ||
# link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<< | ||
# $(dependent_objects) | ||
# << | ||
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 | ||
|
||
$(CFG)\$(PLAT)\psl.exe: $(PSL_LIB) $(CFG)\$(PLAT)\psl $(psl_OBJS) | ||
link $(LDFLAGS) $(PSL_LIB) $(PSL_ADDITIONAL_LIBS) /PDB:$(@R)-tool.pdb /out:$@ @<< | ||
$(psl_OBJS) | ||
<< | ||
@if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 | ||
|
||
# Show the build configuration for this build | ||
build-info: | ||
@echo ------------------------------- | ||
@echo Build configuration for libpsl: | ||
@echo ------------------------------- | ||
@echo Configuration/Platform: $(CFG)/$(PLAT) | ||
@echo Library Build Type: $(PSL_LIBTYPE) | ||
@echo Enabled Runtime: $(ENABLED_RUNTIME) | ||
@echo Enabled Builtin: $(ENABLED_BUILTIN) | ||
@if not "$(ENABLED_BUILTIN)" == "none" echo PSL File: $(PSL_FILE) | ||
|
||
clean: | ||
@if exist $(CFG)\$(PLAT)\psl.dafsa del $(CFG)\$(PLAT)\psl.dafsa | ||
@if exist $(CFG)\$(PLAT)\psl_ascii.dafsa del $(CFG)\$(PLAT)\psl_ascii.dafsa | ||
@if exist .\libpsl.pc del /f /q .\libpsl.pc | ||
@-del /f /q $(CFG)\$(PLAT)\*.exe | ||
@-del /f /q $(CFG)\$(PLAT)\*.lib | ||
@-del /f /q $(CFG)\$(PLAT)\*.pdb | ||
@-del /f /q $(CFG)\$(PLAT)\*.dll.manifest | ||
@-del /f /q $(CFG)\$(PLAT)\*.dll | ||
@-del /f /q $(CFG)\$(PLAT)\*.ilk | ||
@-if exist $(CFG)\$(PLAT)\tests del /f /q $(CFG)\$(PLAT)\tests\*.obj | ||
@-del /f /q $(CFG)\$(PLAT)\libpsl\*.obj | ||
@-del /f /q $(CFG)\$(PLAT)\libpsl\suffixes_dafsa.c | ||
@-del /f /q ..\config.h | ||
@-del /f /q vc$(PDBVER)0.pdb | ||
@-rmdir /s /q $(CFG)\$(PLAT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# NMake Makefile portion for enabling features for Windows builds | ||
|
||
# You may change these lines to customize various items | ||
|
||
!ifndef PSL_FILE | ||
PSL_FILE=..\list\public_suffix_list.dat | ||
!endif | ||
|
||
!ifndef PSL_TESTFILE | ||
PSL_TESTFILE=..\list\tests\tests.txt | ||
!endif | ||
|
||
PSL_FILE_INPUT = $(PSL_FILE:\=/) | ||
PSL_TESTFILE_INPUT = $(PSL_TESTFILE:\=/) | ||
|
||
# We only support using the ICU runtime and/or builtin, or no runtime | ||
# and/or builtin for Visual Studio builds | ||
!if "$(CFG)" == "Release" || "$(CFG)" == "release" | ||
ICUUC_LIB = icuuc.lib | ||
!else | ||
ICUUC_LIB = icuucd.lib | ||
!endif | ||
|
||
ICONV_LIB = iconv.lib | ||
GETTEXT_LIB = intl.lib | ||
|
||
# Please do not change anything beneath this line unless maintaining the NMake Makefiles | ||
# Version info | ||
|
||
PACKAGE_NAME=@PACKAGE_NAME@ | ||
PACKAGE_VERSION=@PACKAGE_VERSION@ | ||
PACKAGE_URL=@PACKAGE_URL@ | ||
|
||
# Bare minimum features and sources built into libpsl on Windows | ||
|
||
!if "$(PLAT)" == "x64" | ||
SSIZE_T_DEF = signed __int64 | ||
!else | ||
SSIZE_T_DEF = signed int | ||
!endif | ||
|
||
PSL_ADDITIONAL_LIBS = ws2_32.lib | ||
PSL_ADDITIONAL_CFLAGS = /DBUILDING_PSL | ||
|
||
BASE_CFLAGS = \ | ||
$(CFLAGS) \ | ||
/D_CRT_SECURE_NO_WARNINGS \ | ||
/D_CRT_NONSTDC_NO_WARNINGS \ | ||
/DHAVE_CONFIG_H \ | ||
/Dssize_t="$(SSIZE_T_DEF)" | ||
|
||
PSL_INCLUDES = /I..\include /I.. /I$(CFG)\$(PLAT)\libpsl /I$(PREFIX)\include | ||
|
||
# We build the psl.dll or psl.lib at least, with the psl.exe utility | ||
PSL_LIB = $(CFG)\$(PLAT)\psl.lib | ||
PSL_UTILS = $(CFG)\$(PLAT)\psl.exe | ||
|
||
PSL_TESTS = \ | ||
$(CFG)\$(PLAT)\test-is-public.exe \ | ||
$(CFG)\$(PLAT)\test-is-public-all.exe \ | ||
$(CFG)\$(PLAT)\test-is-cookie-domain-acceptable.exe | ||
|
||
PSL_TEST_DATA = \ | ||
$(CFG)\$(PLAT)\psl.dafsa \ | ||
$(CFG)\$(PLAT)\psl_ascii.dafsa | ||
|
||
PSL_MAKE_OPTIONS = CFG^=$(CFG) | ||
|
||
!ifndef STATIC | ||
!ifdef USE_LIBTOOL_DLLNAME | ||
PSL_DLL_PREFIX = lib | ||
PSL_DLL_SUFFIX = -5 | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) USE_LIBTOOL_DLLNAME^=$(USE_LIBTOOL_DLLNAME) | ||
!else | ||
PSL_DLL_PREFIX = | ||
PSL_DLL_SUFFIX = | ||
!endif | ||
!endif | ||
|
||
PSL_DLL = $(CFG)\$(PLAT)\$(PSL_DLL_PREFIX)psl$(PSL_DLL_SUFFIX).dll | ||
|
||
# ENABLE_RUNTIME_ICU and ENABLE_BUILTIN_ICU are currently dummy arguments to NMake | ||
ENABLED_RUNTIME = | ||
ENABLED_BUILTIN = | ||
|
||
!ifndef DISABLE_RUNTIME | ||
BASE_CFLAGS = $(BASE_CFLAGS) /DWITH_LIBICU=1 | ||
ENABLED_RUNTIME = libicu | ||
!else | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) DISABLE_RUNTIME^=1 | ||
ENABLED_RUNTIME = none | ||
!endif | ||
|
||
!ifndef DISABLE_BUILTIN | ||
BASE_CFLAGS = $(BASE_CFLAGS) /DBUILTIN_GENERATOR_LIBICU=1 | ||
ENABLED_BUILTIN = libicu | ||
!else | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) DISABLE_BUILTIN^=1 | ||
ENABLED_BUILTIN = none | ||
!endif | ||
|
||
!ifdef STATIC | ||
BASE_CFLAGS = $(BASE_CFLAGS) /DPSL_STATIC | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) STATIC^=1 | ||
PSL_LIBTYPE = static | ||
!else | ||
PSL_LIBTYPE = DLL | ||
!endif | ||
|
||
!if "$(DISABLE_RUNTIME)" == "" || "$(DISABLE_BUILTIN)" == "" | ||
PSL_ADDITIONAL_LIBS = $(PSL_ADDITIONAL_LIBS) $(ICUUC_LIB) | ||
PSL_TESTS = \ | ||
$(PSL_TESTS) \ | ||
$(CFG)\$(PLAT)\test-is-public-builtin.exe \ | ||
$(CFG)\$(PLAT)\test-registrable-domain.exe | ||
!endif | ||
|
||
!ifdef USE_GETTEXT | ||
USE_ICONV=1 | ||
PSL_ADDITIONAL_LIBS = $(PSL_ADDITIONAL_LIBS) $(GETTEXT_LIB) | ||
BASE_CFLAGS = $(BASE_CFLAGS) /DUSE_GETTEXT=1 | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) USE_GETTEXT^=1 | ||
!endif | ||
|
||
!ifdef USE_ICONV | ||
PSL_ADDITIONAL_LIBS = $(PSL_ADDITIONAL_LIBS) $(ICONV_LIB) | ||
BASE_CFLAGS = $(BASE_CFLAGS) /DUSE_ICONV=1 | ||
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) USE_ICONV^=1 | ||
!endif | ||
|
||
PSL_TEST_CFLAGS = $(BASE_CFLAGS) /DPSL_TESTFILE=\"$(PSL_TESTFILE_INPUT)\" /DPSL_FILE=\"$(PSL_FILE_INPUT)\" | ||
|
||
# Visual Studio 2013 or earlier does not have snprintf(), | ||
# so use _snprintf() which seems to be enough for our purposes | ||
!if $(VSVER) < 14 | ||
PSL_TEST_CFLAGS = $(PSL_TEST_CFLAGS) /Dsnprintf=_snprintf | ||
!endif |
Oops, something went wrong.