Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = datrie tools man doc tests
SUBDIRS = datrie tools man doc tests win32

EXTRA_DIST = \
README.migration \
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,7 @@ AC_CONFIG_FILES([Makefile
man/Makefile
doc/Makefile
doc/Doxyfile
tests/Makefile])
tests/Makefile
win32/config-msvc.mak
win32/Makefile])
AC_OUTPUT
13 changes: 13 additions & 0 deletions win32/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
EXTRA_DIST = \
build-rules-msvc.mak \
config-msvc.mak \
create-lists-msvc.mak \
create-lists.bat \
create-pc.bat \
detectenv-msvc.mak \
generate-msvc.mak \
info-msvc.mak \
install.mak \
Makefile.vc \
README.txt \
$(NULL)
40 changes: 40 additions & 0 deletions win32/Makefile.vc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# NMake Makefile for building libdatrie on 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"


all: $(DATRIE_LIBS) $(DATRIE_UTILS) all-build-info

# 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

tests: all $(datrie_tests)

# 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 install.mak

!else # "$(VALID_CFGSET)" == "TRUE"
all: help
@echo You need to specify a valid configuration, via
@echo CFG=release or CFG=debug
!endif # "$(VALID_CFGSET)" == "TRUE"

!include info-msvc.mak
34 changes: 34 additions & 0 deletions win32/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Instructions for building libdatrie on Visual Studio
====================================================
Building the libdatrie on Windows is now supported using Visual Studio.

You will need the following items to build libdatrie using Visual Studio:
-libiconv (including the libcharset headers and libraries) if building trietool.exe

Invoke the build by issuing the command:
nmake /f Makefile.vc CFG=[release|debug] [PREFIX=...] <option1=1 option2=1 ...>
where:

CFG: Required. Choose from a release or debug build. Note that
all builds generate a .pdb file for each .dll and .exe built--this refers
to the C/C++ runtime that the build uses.

PREFIX: Optional. Base directory of where the third-party headers, libraries
and needed tools can be found, i.e. headers in $(PREFIX)\include,
libraries in $(PREFIX)\lib and tools in $(PREFIX)\bin. If not
specified, $(PREFIX) is set as $(srcroot)\..\vs$(X)\$(platform), where
$(platform) is win32 for 32-bit builds or x64 for 64-bit builds, and
$(X) is the short version of the Visual Studio used, as follows:
2008: 9
2010: 10
2012: 11
2013: 12
2015, 2017, 2019: 14

Explanation of options, set by <option>=1:
------------------------------------------
LIB_ONLY: Disables building trietool.exe, which eliminates the need for libiconv.

An 'install' target is provided to copy the built items and public headers to appropriate
locations under $(PREFIX), a 'clean' target is provided to remove all the items that are
created during the build, and a 'tests' target is provided to build the test programs.
86 changes: 86 additions & 0 deletions win32/build-rules-msvc.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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 @<<
# $<
# <<
{..\datrie\}.c{vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\}.obj::
$(CC) $(CFLAGS) $(LIBDATRIE_BASE_CFLAGS) /Fovs$(PDBVER)\$(CFG)\$(PLAT)\datrie\ /Fdvs$(PDBVER)\$(CFG)\$(PLAT)\datrie\ /c @<<
$<
<<

{..\tools\}.c{vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\}.obj::
$(CC) $(CFLAGS) $(TRIETOOL_CFLAGS) /Fovs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ /Fdvs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ /c @<<
$<
<<

{..\tests\}.c{vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\}.obj::
@if not exist vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ $(MAKE) /f Makefile.vc CFG=$(CFG) vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests
$(CC) $(CFLAGS) $(LIBDATRIE_BASE_CFLAGS) /Fovs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ /Fdvs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ /c @<<
$<
<<

# Rules for building .lib files
vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.lib: vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.dll

# 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 [email protected] mt /manifest [email protected] /outputresource:$@;2
vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.dll: \
vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\datrie.def \
vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-0.2.pc \
$(libdatrie_dll_OBJS)
link /DLL $(LDFLAGS) /implib:$(@R).lib /def:vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\datrie.def \
-out:$@ @<<
$(libdatrie_dll_OBJS)
<<
@-if exist [email protected] mt /manifest [email protected] /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 [email protected] mt /manifest [email protected] /outputresource:$@;1

vs$(PDBVER)\$(CFG)\$(PLAT)\trietool.exe: vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.lib vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\config.h $(trietool_OBJS)
link $(LDFLAGS) vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.lib $(TRIETOOL_DEP_LIBS) -out:$@ $(trietool_OBJS)
@-if exist [email protected] mt /manifest [email protected] /outputresource:$@;1

$(datrie_tests):
link $(LDFLAGS) $** -out:$@
@-if exist [email protected] mt /manifest [email protected] /outputresource:$@;1

clean:
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-0.2.pc
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.exe
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.dll
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.pdb
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.ilk
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.exp
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\*.lib
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\vc$(PDBVER)0.pdb
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\*.obj
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests\ rd vs$(PDBVER)\$(CFG)\$(PLAT)\datrie-tests
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\vc$(PDBVER)0.pdb
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\*.obj
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\config.h
@-if exist vs$(PDBVER)\$(CFG)\$(PLAT)\trietool\ rd vs$(PDBVER)\$(CFG)\$(PLAT)\trietool
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\vc$(PDBVER)0.pdb
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\datrie.def
@-del /f /q vs$(PDBVER)\$(CFG)\$(PLAT)\datrie\*.obj
@-rd vs$(PDBVER)\$(CFG)\$(PLAT)\datrie
22 changes: 22 additions & 0 deletions win32/config-msvc.mak.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# NMake Makefile portion for enabling features for Windows builds

# These are the base minimum libraries required for building libdatrie.
BASE_INCLUDES = /I$(PREFIX)\include

# Adjust as needed to your setup for libiconv and libcharset
TRIETOOL_DEP_LIBS = iconv.lib charset.lib

# Please do not change anything beneath this line unless maintaining the NMake Makefiles
# Bare minimum features and sources built into libdatrie on Windows

DATRIE_VERSION = @VERSION@
DATRIE_LIBS = vs$(PDBVER)\$(CFG)\$(PLAT)\datrie.lib
LIBDATRIE_BASE_CFLAGS = /I.. /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS
TRIETOOL_CFLAGS = /Ivs$(PDBVER)\$(CFG)\$(PLAT)\trietool $(LIBDATRIE_BASE_CFLAGS) $(BASE_INCLUDES)

# Disable building trietool.exe if requested
!if "$(LIB_ONLY)" == "1"
DATRIE_UTILS =
!else
DATRIE_UTILS = vs$(PDBVER)\$(CFG)\$(PLAT)\trietool.exe
!endif
72 changes: 72 additions & 0 deletions win32/create-lists-msvc.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Convert the source listing to object (.obj) listing in
# another NMake Makefile module, include it, and clean it up.
# This is a "fact-of-life" regarding NMake Makefiles...
# This file does not need to be changed unless one is maintaining the NMake Makefiles

# For those wanting to add things here:
# To add a list, do the following:
# # $(description_of_list)
# if [call create-lists.bat header $(makefile_snippet_file) $(variable_name)]
# endif
#
# if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]
# endif
#
# if [call create-lists.bat footer $(makefile_snippet_file)]
# endif
# ... (repeat the if [call ...] lines in the above order if needed)
# !include $(makefile_snippet_file)
#
# (add the following after checking the entries in $(makefile_snippet_file) is correct)
# (the batch script appends to $(makefile_snippet_file), you will need to clear the file unless the following line is added)
#!if [del /f /q $(makefile_snippet_file)]
#!endif

# In order to obtain the .obj filename that is needed for NMake Makefiles to build DLLs/static LIBs or EXEs, do the following
# instead when doing 'if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]'
# (repeat if there are multiple $(srcext)'s in $(source_list), ignore any headers):
# !if [for %c in ($(source_list)) do @if "%~xc" == ".$(srcext)" @call create-lists.bat file $(makefile_snippet_file) $(intdir)\%~nc.obj]
#
# $(intdir)\%~nc.obj needs to correspond to the rules added in build-rules-msvc.mak
# %~xc gives the file extension of a given file, %c in this case, so if %c is a.cc, %~xc means .cc
# %~nc gives the file name of a given file without extension, %c in this case, so if %c is a.cc, %~nc means a

NULL=

# For libdatrie
!if [call create-lists.bat header datrie_objs.mak libdatrie_dll_OBJS]
!endif

!if [for %c in (..\datrie\*.c) do @call create-lists.bat file datrie_objs.mak vs^$(PDBVER)\^$(CFG)\^$(PLAT)\datrie\%~nc.obj]
!endif

!if [call create-lists.bat footer datrie_objs.mak]
!endif

# For trietool
!if [call create-lists.bat header datrie_objs.mak trietool_OBJS]
!endif

!if [for %c in (..\tools\*.c) do @call create-lists.bat file datrie_objs.mak vs^$(PDBVER)\^$(CFG)\^$(PLAT)\trietool\%~nc.obj]
!endif

!if [call create-lists.bat footer datrie_objs.mak]
!endif

# For test programs
!if [call create-lists.bat header datrie_objs.mak datrie_tests]
!endif

!if [for %c in (..\tests\*.c) do @if not "%~nc" == "utils" @call create-lists.bat file datrie_objs.mak vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~nc.exe]
!endif

!if [call create-lists.bat footer datrie_objs.mak]
!endif

!if [for %c in (..\tests\*.c) do @if not "%~nc" == "utils" @echo vs^$(PDBVER)\^$(CFG)\^$(PLAT)\%~nc.exe: vs^$(PDBVER)\^$(CFG)\^$(PLAT)\datrie.lib vs^$(PDBVER)\^$(CFG)\^$(PLAT)\datrie-tests\%~nc.obj vs^$(PDBVER)\^$(CFG)\^$(PLAT)\datrie-tests\utils.obj>>datrie_objs.mak]
!endif

!include datrie_objs.mak

!if [del /f /q datrie_objs.mak]
!endif
42 changes: 42 additions & 0 deletions win32/create-lists.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@echo off
rem Simple .bat script for creating the NMake Makefile snippets.

if not "%1" == "header" if not "%1" == "file" if not "%1" == "footer" goto :error_cmd
if "%2" == "" goto error_no_destfile

if "%1" == "header" goto :header
if "%1" == "file" goto :addfile
if "%1" == "footer" goto :footer

:header
if "%3" == "" goto error_var
echo %3 = \>>%2
goto done

:addfile
if "%3" == "" goto error_file
echo. %3 \>>%2
goto done

:footer
echo. $(NULL)>>%2
echo.>>%2
goto done

:error_cmd
echo Specified command '%1' was invalid. Valid commands are: header file footer.
goto done

:error_no_destfile
echo Destination NMake snippet file must be specified
goto done

:error_var
echo A name must be specified for using '%1'.
goto done

:error_file
echo A file must be specified for using '%1'.
goto done

:done
33 changes: 33 additions & 0 deletions win32/create-pc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@echo off
rem Simple .bat script for creating the NMake Makefile snippets.

if "%1" == "" goto :error_no_dest
if "%2" == "" goto :error_no_ver
if "%3" == "" goto :error_dst

set pfx=%~dnp3
echo prefix=%pfx:\=/%>%1
echo exec_prefix=^$^{prefix^}>>%1
echo libdir=^$^{prefix^}/lib>>%1
echo includedir=^$^{prefix^}/include>>%1
echo.>>%1
echo Name: datrie>>%1
echo Description: Double-array trie library>>%1
echo Version: %2>>%1
echo Libs: -L^$^{libdir^} -ldatrie>>%1
echo Cflags: -I^$^{includedir^}>>%1
goto done

:error_no_dest
echo No output file specified
goto done

:error_no_ver
echo No version specified
goto done

:error_dst
echo A prefix path must be specified
goto done

:done
Loading