File dt-port.diff of Package mingw32-darktable
From: Jan Engelhardt <jengelh@inai.de>
Date: 2015-07-16 00:05:19.713298600 +0200
build: fix cumulated errors
src/external/LibRaw/internal/dcraw_common.cpp: In member function 'void LibRaw::apply_tiff()':
src/external/LibRaw/internal/dcraw_common.cpp:5961:52: error: 'strcasestr' was not declared in this scope
|| (tiff_bps == 8 && !strcasestr(make,"Kodak") &&
Needs implementation.
src/external/rawspeed/RawSpeed/pugixml.cpp: In function 'size_t pugi::impl::{anonymous}::strlength(const char_t*)':
src/external/rawspeed/RawSpeed/pugixml.cpp:171:11: error: 'assert' was not declared in this scope
assert(s);
src/external/rawspeed/RawSpeed/pugixml.cpp:171:11: error: 'assert' was not declared in this scope
assert(s);
Needs <cassert>.
src/external/rawspeed/RawSpeed/MosDecoder.cpp:214:71: error: 'memmem' was not declared in this scope
char *neutobj = (char *) memmem(text, size, "NeutObj_neutrals", 16);
needs to use what is in dcraw_common.cpp already.
src/common/darktable.c:697:5: error: implicit declaration of function 'setenv' [-Werror=implicit-function-declaration]
setenv("LANGUAGE", lang, 1);
Needs g_setenv because mingw does not have setenv.
src/common/exif.cc:858:103: error: 'localtime_r' was not declared in this scope
strftime(img->exif_datetime_taken, 20, "%Y:%m:%d %H:%M:%S", localtime_r(&statbuf.st_mtime, &result));
Normally this would be fixed by passing in -D_POSIX_C_SOURCE=200809L
through CXXFLAGS, but dumb cmake won't respect the flags given to it.
---
src/common/darktable.c | 7 ++++---
src/common/exif.cc | 1 +
src/common/opencl.c | 12 ++++++++++++
src/common/utility.c | 9 ++++++++-
src/external/LibRaw/internal/dcraw_common.cpp | 18 +++++++++++++++++-
src/external/rawspeed/RawSpeed/MosDecoder.cpp | 14 ++++++++++++++
src/external/rawspeed/RawSpeed/pugixml.cpp | 3 +++
src/iop/defringe.c | 2 +-
src/iop/levels.c | 4 ++--
src/iop/spots.c | 4 ++--
src/iop/watermark.c | 1 +
11 files changed, 65 insertions(+), 10 deletions(-)
Index: darktable-1.6.7/src/common/darktable.c
===================================================================
--- darktable-1.6.7.orig/src/common/darktable.c
+++ darktable-1.6.7/src/common/darktable.c
@@ -20,6 +20,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#define _POSIX_C_SOURCE 200809L
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
#include <malloc.h>
@@ -670,7 +671,7 @@ int dt_init(int argc, char *argv[], cons
char datadir[PATH_MAX] = { 0 };
dt_loc_get_datadir(datadir, sizeof(datadir));
snprintf(geglpath, sizeof(geglpath), "%s/gegl:/usr/lib/gegl-0.0", datadir);
- (void)setenv("GEGL_PATH", geglpath, 1);
+ g_setenv("GEGL_PATH", geglpath, 1);
gegl_init(&argc, &argv);
#endif
#ifdef USE_LUA
@@ -694,10 +695,10 @@ int dt_init(int argc, char *argv[], cons
"ui_last/gui_language"); // we may not g_free 'lang' since it is owned by setlocale afterwards
if(lang != NULL && lang[0] != '\0')
{
- setenv("LANGUAGE", lang, 1);
+ g_setenv("LANGUAGE", lang, 1);
if(setlocale(LC_ALL, lang) != NULL) gtk_disable_setlocale();
setlocale(LC_MESSAGES, lang);
- setenv("LANG", lang, 1);
+ g_setenv("LANG", lang, 1);
}
// initialize the database
Index: darktable-1.6.7/src/common/exif.cc
===================================================================
--- darktable-1.6.7.orig/src/common/exif.cc
+++ darktable-1.6.7/src/common/exif.cc
@@ -19,6 +19,7 @@
*/
#define __STDC_FORMAT_MACROS
+#define _POSIX_C_SOURCE 200809L
extern "C" {
#ifdef HAVE_CONFIG_H
Index: darktable-1.6.7/src/common/opencl.c
===================================================================
--- darktable-1.6.7.orig/src/common/opencl.c
+++ darktable-1.6.7/src/common/opencl.c
@@ -1105,6 +1105,18 @@ static FILE *fopen_stat(const char *file
return f;
}
+#ifdef _WIN32
+static ssize_t readlink(const char *a, char *b, size_t c)
+{
+ errno = EINVAL;
+ return -1;
+}
+static int symlink(const char *a, const char *b)
+{
+ errno = EPERM;
+ return -1;
+}
+#endif
int dt_opencl_load_program(const int dev, const int prog, const char *filename, const char *binname,
const char *cachedir, char *md5sum, int *loaded_cached)
Index: darktable-1.6.7/src/common/utility.c
===================================================================
--- darktable-1.6.7.orig/src/common/utility.c
+++ darktable-1.6.7/src/common/utility.c
@@ -15,11 +15,17 @@
You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/
-
/* getpwnam_r availibility check */
#if defined __APPLE__ || defined _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE || defined _BSD_SOURCE \
|| defined _SVID_SOURCE || defined _POSIX_SOURCE || defined __DragonFly__ || defined __FreeBSD__ \
|| defined __NetBSD__ || defined __OpenBSD__
+/* da fuq. Don't test for POSIX, test for pwd.h! */
+#define USE_PWD_H 1
+#endif
+
+#define _POSIX_C_SOURCE 200809L
+
+#ifdef USE_PWD_H
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
@@ -32,6 +38,7 @@
#include <config.h>
#endif
+#include <stdlib.h> /* labs */
#include "utility.h"
#include "file_location.h"
Index: darktable-1.6.7/src/external/LibRaw/internal/dcraw_common.cpp
===================================================================
--- darktable-1.6.7.orig/src/external/LibRaw/internal/dcraw_common.cpp
+++ darktable-1.6.7/src/external/LibRaw/internal/dcraw_common.cpp
@@ -21,7 +21,13 @@ it under the terms of the one of three l
for more information
*/
-#include <math.h>
+#include <cmath>
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
+#ifndef __GLIBC__
+# include <boost/algorithm/string.hpp>
+#endif
#define CLASS LibRaw::
#include "libraw/libraw_types.h"
#define LIBRAW_LIBRARY_BUILD
@@ -42,6 +48,16 @@ char *my_memmem (char *haystack, size_t
return 0;
}
#define memmem my_memmem
+
+const char *strcasestr(const char *h, const char *n)
+{
+ std::string hy(h);
+ boost::iterator_range<std::string::iterator> range =
+ boost::algorithm::ifind_first(hy, n);
+ if (range.empty())
+ return NULL;
+ return h + (hy.begin() - range.begin());
+}
#endif
Index: darktable-1.6.7/src/external/rawspeed/RawSpeed/MosDecoder.cpp
===================================================================
--- darktable-1.6.7.orig/src/external/rawspeed/RawSpeed/MosDecoder.cpp
+++ darktable-1.6.7/src/external/rawspeed/RawSpeed/MosDecoder.cpp
@@ -23,6 +23,20 @@
http://www.klauspost.com
*/
+#include <cstring>
+#ifndef __GLIBC__
+static char *my_memmem (char *haystack, size_t haystacklen,
+ char *needle, size_t needlelen)
+{
+ char *c;
+ for (c = haystack; c <= haystack + haystacklen - needlelen; c++)
+ if (!memcmp (c, needle, needlelen))
+ return c;
+ return 0;
+}
+#define memmem my_memmem
+#endif
+
namespace RawSpeed {
MosDecoder::MosDecoder(TiffIFD *rootIFD, FileMap* file) :
Index: darktable-1.6.7/src/external/rawspeed/RawSpeed/pugixml.cpp
===================================================================
--- darktable-1.6.7.orig/src/external/rawspeed/RawSpeed/pugixml.cpp
+++ darktable-1.6.7/src/external/rawspeed/RawSpeed/pugixml.cpp
@@ -16,6 +16,9 @@
#ifndef SOURCE_PUGIXML_CPP
#define SOURCE_PUGIXML_CPP
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
#include "pugixml.hpp"
/*
Index: darktable-1.6.7/src/iop/defringe.c
===================================================================
--- darktable-1.6.7.orig/src/iop/defringe.c
+++ darktable-1.6.7/src/iop/defringe.c
@@ -274,7 +274,7 @@ void process(struct dt_iop_module_t *mod
float thresh;
if(MODE_GLOBAL_AVERAGE == d->op_mode)
{
- avg_edge_chroma = avg_edge_chroma / (width * height) + 10.0 * FLT_EPSILON;
+ avg_edge_chroma = avg_edge_chroma / (width * height) + 10.0 * __FLT_EPSILON__;
thresh = fmax(0.1f, 4.0 * d->thresh * avg_edge_chroma / MAGIC_THRESHOLD_COEFF);
}
else
Index: darktable-1.6.7/src/iop/levels.c
===================================================================
--- darktable-1.6.7.orig/src/iop/levels.c
+++ darktable-1.6.7/src/iop/levels.c
@@ -704,7 +704,7 @@ static gboolean dt_iop_levels_area_expos
{
if(mean_picked_color > p->levels[1])
{
- p->levels[0] = p->levels[1] - FLT_EPSILON;
+ p->levels[0] = p->levels[1] - __FLT_EPSILON__;
}
else
{
@@ -730,7 +730,7 @@ static gboolean dt_iop_levels_area_expos
{
if(mean_picked_color < p->levels[1])
{
- p->levels[2] = p->levels[1] + FLT_EPSILON;
+ p->levels[2] = p->levels[1] + __FLT_EPSILON__;
}
else
{
Index: darktable-1.6.7/src/iop/spots.c
===================================================================
--- darktable-1.6.7.orig/src/iop/spots.c
+++ darktable-1.6.7/src/iop/spots.c
@@ -422,9 +422,9 @@ void process(struct dt_iop_module_t *sel
}
// convert from world space:
- float rad10[2] = { circle->radius, circle->radius };
+ float xrad10[2] = { circle->radius, circle->radius };
float radf[2];
- masks_point_denormalize(piece, roi_in, rad10, 1, radf);
+ masks_point_denormalize(piece, roi_in, xrad10, 1, radf);
const int rad = MIN(radf[0], radf[1]);
const int posx = points[0] - rad;
Index: darktable-1.6.7/src/iop/watermark.c
===================================================================
--- darktable-1.6.7.orig/src/iop/watermark.c
+++ darktable-1.6.7/src/iop/watermark.c
@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <math.h>
#include <assert.h>