From 26e4ef08bca2398f978c2510e39821bb36d60f41 Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 29 Nov 2017 12:21:13 -0500 Subject: [PATCH 1/6] [fix] conditional compilation for strndup and drand48 for Windows, using config.h --- configure.ac | 2 +- src/klib/drand48.c | 10 +++++++++- src/klib/drand48.h | 12 +++++++++--- src/strndup.c | 3 +++ src/strndup.h | 2 ++ windows/configure.ac | 2 +- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 4f4bfcc1..0dea296c 100644 --- a/configure.ac +++ b/configure.ac @@ -48,7 +48,7 @@ AC_TYPE_UINT8_T AC_CHECK_TYPES([ptrdiff_t]) # Checks for library functions. -AC_CHECK_FUNCS([malloc realloc getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup]) +AC_CHECK_FUNCS([malloc realloc drand48 getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup]) AC_CONFIG_FILES([Makefile libpostal.pc diff --git a/src/klib/drand48.c b/src/klib/drand48.c index ab9230e3..89632da7 100644 --- a/src/klib/drand48.c +++ b/src/klib/drand48.c @@ -14,6 +14,12 @@ //I've rearranged the source into a header-only implementation for drand48() -Benjamin Kusin +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef HAVE_DRAND48 + #include #include "drand48.h" @@ -67,4 +73,6 @@ double erand48(unsigned short xseed[3]) double drand48(void) { return erand48(_rand48_seed); -} \ No newline at end of file +} + +#endif // HAVE_DRAND48 diff --git a/src/klib/drand48.h b/src/klib/drand48.h index d8fd0f7d..56b55d3c 100644 --- a/src/klib/drand48.h +++ b/src/klib/drand48.h @@ -12,11 +12,15 @@ * to anyone/anything when using this software. */ -//I've rearranged the source into a header-only implementation for drand48() -Benjamin Kusin - #ifndef _DRAND48_H #define _DRAND48_H +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef HAVE_DRAND48 + #define RAND48_SEED_0 (0x330e) #define RAND48_SEED_1 (0xabcd) #define RAND48_SEED_2 (0x1234) @@ -37,5 +41,7 @@ double erand48(unsigned short xseed[3]); double drand48(void); +#endif // HAVE_DRAND48 + +#endif // _DRAND48_H -#endif // _DRAND48_H \ No newline at end of file diff --git a/src/strndup.c b/src/strndup.c index 61f605b6..6d1a9300 100644 --- a/src/strndup.c +++ b/src/strndup.c @@ -1,4 +1,7 @@ +#ifdef HAVE_CONFIG_H #include +#endif + #ifndef HAVE_STRNDUP #include diff --git a/src/strndup.h b/src/strndup.h index 69dea1a7..7cd3bffb 100644 --- a/src/strndup.h +++ b/src/strndup.h @@ -1,7 +1,9 @@ #ifndef STRNDUP_H #define STRNDUP_H +#ifdef HAVE_CONFIG_H #include +#endif #ifndef HAVE_STRNDUP diff --git a/windows/configure.ac b/windows/configure.ac index b41080f6..0a964cf5 100644 --- a/windows/configure.ac +++ b/windows/configure.ac @@ -48,7 +48,7 @@ AC_TYPE_UINT8_T AC_CHECK_TYPES([ptrdiff_t]) # Checks for library functions. -AC_CHECK_FUNCS([malloc realloc getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup]) +AC_CHECK_FUNCS([malloc realloc drand48 getcwd gettimeofday memmove memset regcomp setlocale sqrt strdup strndup]) AC_CONFIG_FILES([Makefile libpostal.pc From 9e837f72092441a5085aa91d1ffc489cdf9da6fa Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 29 Nov 2017 12:26:36 -0500 Subject: [PATCH 2/6] [fix] deleting comment, this is not a header-only implementation --- src/klib/drand48.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/klib/drand48.c b/src/klib/drand48.c index 89632da7..2f4335bd 100644 --- a/src/klib/drand48.c +++ b/src/klib/drand48.c @@ -12,8 +12,6 @@ * to anyone/anything when using this software. */ -//I've rearranged the source into a header-only implementation for drand48() -Benjamin Kusin - #ifdef HAVE_CONFIG_H #include #endif From 2cb0d146e5e4644290d42288a63052e41324b4dd Mon Sep 17 00:00:00 2001 From: Al Date: Wed, 29 Nov 2017 13:12:50 -0500 Subject: [PATCH 3/6] [docs][ci skip] adding a section for Windows installation, shoutouts to @BenK10 and @AeroXuk --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc2c5630..1ce427b8 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ Individual users can also help support open geo NLP research by making a monthly -Installation ------------- +Installation (Mac/Linux) +------------------------ Before you install, make sure you have the following prerequisites: @@ -139,7 +139,10 @@ For example, if you write a program called app.c, you can compile it like this: gcc app.c `pkg-config --cflags --libs libpostal` ``` -**On Windows (MSys2/MinGW)** +Installation (Windows) +---------------------- + +**MSys2/MinGW** For Windows the build procedure currently requires MSys2 and MinGW. This can be downloaded from http://msys2.org. Please follow the instructions on the MSys2 website for installation. @@ -675,6 +678,12 @@ Bug reports, issues and pull requests are welcome. Please read the [contributing Submit issues at: https://github.com/openvenues/libpostal/issues. + +Shoutouts +--------- + +Special thanks to @BenK10 for the initial Windows build and @AeroXuk for integrating it seamlessly into the project and setting up an Appveyor build. + License ------- From f207a4680d64ce2dc3ff8945438d9a136249317e Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 30 Nov 2017 14:09:13 -0500 Subject: [PATCH 4/6] [docs/build] adding make -j4 as the default for make, including in the Travis/Appveyor builds, should make build times faster --- .travis.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99882187..ac880b3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ install: - if [ "$CC" = "gcc" ]; then export CC="gcc-4.8"; fi script: - ./configure --datadir=$(pwd)/data - - make + - make -j4 - if [[ $DICTIONARIES_CHANGED -ne 0 ]]; then ./src/build_address_dictionary; fi; - if [[ $NUMEX_CHANGED -ne 0 ]]; then ./src/build_numex_table; fi; - if [[ $TRANSLIT_CHANGED -ne 0 ]]; then ./src/build_trans_table; fi; diff --git a/README.md b/README.md index 1ce427b8..439443d1 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ git clone https://github.com/openvenues/libpostal cd libpostal ./bootstrap.sh ./configure --datadir=[...some dir with a few GB of space...] -make +make -j4 sudo make install # On Linux it's probably a good idea to run @@ -163,7 +163,7 @@ cd libpostal cp -rf windows/* ./ ./bootstrap.sh ./configure --datadir=[...some dir with a few GB of space...] -make +make -j4 make install ``` Notes: When setting the datadir, the `C:` drive would be entered as `/c`. The libpostal build script automatically add `libpostal` on the end of the path, so '/c' would become `C:\libpostal\` on Windows. From 02d049b8d999ccfdd5b09074f08933a4c4330c21 Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 30 Nov 2017 17:18:04 -0500 Subject: [PATCH 5/6] [build] also trying make -j4 to the Windows build. Set an option on the Appveyor side that will hopefully not build twice on pull requests --- win_build.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win_build.bat b/win_build.bat index 8b0db748..f7779bbe 100644 --- a/win_build.bat +++ b/win_build.bat @@ -17,7 +17,7 @@ IF %COMPILER%==msys2 ( bash -lc "cd $APPVEYOR_BUILD_FOLDER && cp -rf windows/* ./" bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap.sh" bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./configure --datadir=/c" - bash -lc "cd $APPVEYOR_BUILD_FOLDER && make" + bash -lc "cd $APPVEYOR_BUILD_FOLDER && make -j4" bash -lc "cd $APPVEYOR_BUILD_FOLDER && make install" bash -lc "cd $APPVEYOR_BUILD_FOLDER && cp src/.libs/libpostal-*.dll libpostal.dll" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\lib.exe" /def:libpostal.def /out:libpostal.lib /machine:x64 From cf56da98f7df0a1cf955c91056bb4ccbd84a046c Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 30 Nov 2017 17:39:24 -0500 Subject: [PATCH 6/6] [build] only build master on Appveyor so PRs don't trigger multiple builds --- .appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index eac7a36c..b14fe0a8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,6 +3,10 @@ version: 1.0.{build} image: Visual Studio 2015 platform: x64 +branches: + only: + - master + environment: matrix: - COMPILER: msys2