From 5983ba633ff23eb801a424689cb1fa19102f5b92 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Mon, 5 Feb 2018 21:15:49 +0900 Subject: [PATCH] Add epsilon library port Signed-off-by: Hiroshi Miura --- .../0001-VS2015-provides-snprintf.patch | 51 ++++++++++ ...CRT-selection-and-warning-supression.patch | 81 +++++++++++++++ ports/epsilon/CONTROL | 3 + ports/epsilon/portfile.cmake | 99 +++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 ports/epsilon/0001-VS2015-provides-snprintf.patch create mode 100644 ports/epsilon/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch create mode 100644 ports/epsilon/CONTROL create mode 100644 ports/epsilon/portfile.cmake diff --git a/ports/epsilon/0001-VS2015-provides-snprintf.patch b/ports/epsilon/0001-VS2015-provides-snprintf.patch new file mode 100644 index 0000000000..0fc664f609 --- /dev/null +++ b/ports/epsilon/0001-VS2015-provides-snprintf.patch @@ -0,0 +1,51 @@ +From 8b5b2ea5ba695252abaad4234c951675d5f733ec Mon Sep 17 00:00:00 2001 +From: Hiroshi Miura +Date: Wed, 7 Feb 2018 12:28:54 +0900 +Subject: [PATCH 1/2] VS2015 provides snprintf + +Signed-off-by: Hiroshi Miura +--- + lib/common.h | 27 +++++++++++++++++++++++---- + 1 file changed, 23 insertions(+), 4 deletions(-) + +diff --git a/lib/common.h b/lib/common.h +index c5db1ed..73c4118 100644 +--- a/lib/common.h ++++ b/lib/common.h +@@ -39,10 +39,29 @@ extern "C" { + /** \addtogroup misc Miscellanea */ + /*@{*/ + +-/* Use _snprintf instead of snprintf under MSVC compiler */ +-#if defined(_WIN32) && !defined(__MINGW32__) +-#define snprintf _snprintf +-#endif ++#ifdef _MSC_VER ++#if _MSC_VER < 1900 // VS2015/17 provides snprintf ++#include ++#include ++/* Want safe, 'n += snprintf(b + n ...)' like function. If cp_max_len is 1 ++* then assume cp is pointing to a null char and do nothing. Returns number ++* number of chars placed in cp excluding the trailing null char. So for ++* cp_max_len > 0 the return value is always < cp_max_len; for cp_max_len ++* <= 0 the return value is 0 (and no chars are written to cp). */ ++static int snprintf(char * cp, int cp_max_len, const char * fmt, ...) ++{ ++ va_list args; ++ int n; ++ ++ if (cp_max_len < 2) ++ return 0; ++ va_start(args, fmt); ++ n = vsnprintf(cp, cp_max_len, fmt, args); ++ va_end(args); ++ return (n < cp_max_len) ? n : (cp_max_len - 1); ++} ++#endif // _MSC_VER < 1900 ++#endif // _MSC_VER + + #ifdef HAVE_CONFIG_H + # include +-- +2.16.1 + diff --git a/ports/epsilon/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch b/ports/epsilon/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch new file mode 100644 index 0000000000..f76aed10b6 --- /dev/null +++ b/ports/epsilon/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch @@ -0,0 +1,81 @@ +From 4969dd6e7b656e92bf1bc921f0cd1af00707e17f Mon Sep 17 00:00:00 2001 +From: Hiroshi Miura +Date: Wed, 7 Feb 2018 10:47:53 +0900 +Subject: [PATCH 2/2] Add CFLAGS for CRT selection and warning supression + +Signed-off-by: Hiroshi Miura +--- + makefile.vc | 2 +- + nmake.opt | 42 +++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 40 insertions(+), 4 deletions(-) + +diff --git a/makefile.vc b/makefile.vc +index 33f1f34..64fb9f3 100644 +--- a/makefile.vc ++++ b/makefile.vc +@@ -20,7 +20,7 @@ EPSILON_EXE = epsilon.exe + +-CFLAGS = /nologo -IC:\OSGeo4W\include -I.\lib -I.\lib\msvc \ ++CFLAGS = /nologo -I$(INSTALLED_ROOT)\include -I.\lib -I.\lib\msvc \ + -I.\src -I..\popt\include \ +- $(OPTFLAGS) ++ $(OPTFLAGS) $(WARNFLAGS) + + default: all + +diff --git a/nmake.opt b/nmake.opt +index d5a51e2..d8088df 100644 +--- a/nmake.opt ++++ b/nmake.opt +@@ -1,9 +1,45 @@ + # Directory tree where EPSILON will be installed. ++!IFNDEF INSTDIR + INSTDIR=C:\OSGeo4W ++!ENDIF ++ ++# Flags to choose CRT variant to link against (e.g. static: /MT, /MTd, dynamic: /MD, /MDd) ++!IFNDEF CRT_FLAGS ++!IFNDEF DEBUG ++CRT_FLAGS=/MD ++!ELSE ++CRT_FLAGS=/MDd ++!ENDIF ++!ENDIF ++ ++# Flags for enforcing PDB use ++!IFNDEF PDB_FLAGS ++PDB_FLAGS=/Fdepsilon.pdb ++!ENDIF ++ ++# Set flags controlling warnings level, and suppression of some warnings. ++!IFNDEF WARNFLAGS ++# 4127: conditional expression is constant ++# 4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' ++# 4275: non – DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' ++# 4786: ?????????? ++# 4100: 'identifier' : unreferenced formal parameter ++# 4245: 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch ++# 4206: nonstandard extension used : translation unit is empty (only applies to C source code) ++# 4351: new behavior: elements of array 'array' will be default initialized (needed for https://trac.osgeo.org/gdal/changeset/35593) ++# 4611: interaction between '_setjmp' and C++ object destruction is non-portable ++# ++WARNFLAGS = /W3 /wd4127 /wd4251 /wd4275 /wd4786 /wd4100 /wd4245 /wd4206 /wd4351 /wd4611 ++!ENDIF ++ ++!IFNDEF OPTFLAGS ++!IFNDEF DEBUG ++OPTFLAGS= $(PDB_FLAGS) /nologo $(CRT_FLAGS) /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG ++!ELSE ++OPTFLAGS= $(PDB_FLAGS) /nologo $(CRT_FLAGS) /EHsc /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG ++!ENDIF ++!ENDIF + +-# Uncomment the first for an optimized build, or the second for debug. +-OPTFLAGS= /nologo /Ox /fp:precise /W3 /MD /D_CRT_SECURE_NO_WARNINGS +-#OPTFLAGS= /nologo /Zi /MD /Fdepsilon.pdb + + # Set the version number for the DLL. Normally we leave this blank since + # we want software that is dynamically loading the DLL to have no problem +-- +2.16.1 + diff --git a/ports/epsilon/CONTROL b/ports/epsilon/CONTROL new file mode 100644 index 0000000000..94f9e1db8d --- /dev/null +++ b/ports/epsilon/CONTROL @@ -0,0 +1,3 @@ +Source: epsilon +Version: 0.9.2 +Description: EPSILON is an Open Source wavelet image compressor, that is aimed on parallel and robust image processing. \ No newline at end of file diff --git a/ports/epsilon/portfile.cmake b/ports/epsilon/portfile.cmake new file mode 100644 index 0000000000..70aee7e1ec --- /dev/null +++ b/ports/epsilon/portfile.cmake @@ -0,0 +1,99 @@ +include(vcpkg_common_functions) + +vcpkg_download_distfile(ARCHIVE + URLS "https://downloads.sourceforge.net/project/epsilon-project/epsilon/0.9.2/epsilon-0.9.2.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fepsilon-project%2Ffiles%2Fepsilon%2F0.9.2%2Fepsilon-0.9.2.tar.gz%2Fdownload%3Fuse_mirror%3Dayera" + FILENAME "epsilon-0.9.2.tar.gz" + SHA512 95f427c68a4a4eb784f7d484d87fc573133983510f6b030663f88955e2446490a07b1343ae4668251b466f67cf9a79bd834b933c57c5ed12327f32174f20ac0f) + +# Extract source into archictecture specific directory, because GDALs' nmake based build currently does not +# support out of source builds. +set(SOURCE_PATH_DEBUG ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-debug/epsilon-0.9.2) +set(SOURCE_PATH_RELEASE ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-release/epsilon-0.9.2) + +foreach(BUILD_TYPE debug release) + vcpkg_extract_source_archive(${ARCHIVE} ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-${BUILD_TYPE}) + vcpkg_apply_patches( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-${BUILD_TYPE}/epsilon-0.9.2 + PATCHES + ${CMAKE_CURRENT_LIST_DIR}/0001-VS2015-provides-snprintf.patch + ${CMAKE_CURRENT_LIST_DIR}/0002-Add-CFLAGS-for-CRT-selection-and-warning-supression.patch + ) +endforeach() + +find_program(NMAKE nmake REQUIRED) +if (VCPKG_CRT_LINKAGE STREQUAL static) + set(CL_FLAGS_REL "/MT /Ox /fp:precise") + set(CL_FLAGS_DBG "/MTd /Zi") + set(TARGET_LIB epsilon.lib) +else() + set(CL_FLAGS_REL "/MD /Ox /fp:precise") + set(CL_FLAGS_DBG "/MDd /Zi") + set(TARGET_LIB epsilon_i.lib) +endif() + +################ +# Release build +################ +message(STATUS "Building ${TARGET_TRIPLET}-rel") +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" INST_DIR_REL) +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc + "INSTDIR=\"${INST_DIR_REL}\"" + MSVC_VER=1900 + CRT_FLAGS=${CL_FLAGS_REL} + INSTALLED_ROOT=${CURRENT_INSTALLED_DIR} + ${TARGET_LIB} + WORKING_DIRECTORY ${SOURCE_PATH_RELEASE} + LOGNAME nmake-build-${TARGET_TRIPLET}-release +) +message(STATUS "Building ${TARGET_TRIPLET}-rel done") + +################ +# Debug build +################ +message(STATUS "Building ${TARGET_TRIPLET}-dbg") +file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" INST_DIR_DBG) +vcpkg_execute_required_process( + COMMAND ${NMAKE} /G -f makefile.vc + "INSTDIR=\"${INST_DIR_DBG}\"" + MSVC_VER=1900 + CRT_FLAGS=${CL_FLAGS_DBG} + DEBUG=1 + INSTALLED_ROOT=${CURRENT_INSTALLED_DIR} + ${TARGET_LIB} + WORKING_DIRECTORY ${SOURCE_PATH_DEBUG} + LOGNAME nmake-build-${TARGET_TRIPLET}-debug +) +message(STATUS "Building ${TARGET_TRIPLET}-dbg done") + +message(STATUS "Packaging ${TARGET_TRIPLET}") +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/epsilon/filters) +if (VCPKG_CRT_LINKAGE STREQUAL dynamic) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin) + file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin/) + file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin/) + file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon_i.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib/) + file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon_i.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/) +else() + file(INSTALL ${SOURCE_PATH_RELEASE}/epsilon.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib/) + file(INSTALL ${SOURCE_PATH_DEBUG}/epsilon.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/) +endif() +file(COPY ${SOURCE_PATH_RELEASE}/lib/epsilon.h + DESTINATION ${CURRENT_PACKAGES_DIR}/include/) +file(GLOB FILTERS ${SOURCE_PATH_RELEASE}/filters/*.filter) +file(INSTALL ${FILTERS} + DESTINATION ${CURRENT_PACKAGES_DIR}/share/epsilon/filters/) +vcpkg_copy_pdbs() +file(INSTALL ${SOURCE_PATH_RELEASE}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/epsilon/ RENAME copyright) +message(STATUS "Packaging ${TARGET_TRIPLET} done") +