# HG changeset patch
# User Markus Mützel <markus.muetzel@gmx.de>
# Date 1619100671 -7200
#      Thu Apr 22 16:11:11 2021 +0200
# Node ID d512048c6931b6be666f4ab2c0347003d40881be
# Parent  4e99aee38edb41611e55ae0773754581a857c092
libbiosig: Fix native build (wip!)

diff -r 4e99aee38edb -r d512048c6931 src/dcmtk-4-c++11-related-fixes.patch
--- a/src/dcmtk-4-c++11-related-fixes.patch	Tue Apr 20 20:40:44 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-From: Boris Pek
-Date: Thu, 05 May 2016 15:38:47 +0300
-Subject: [PATCH] fix build with GCC >= 6.x
-
-diff --git a/ofstd/libsrc/ofstd.cc b/ofstd/libsrc/ofstd.cc
---- a/ofstd/libsrc/ofstd.cc
-+++ b/ofstd/libsrc/ofstd.cc
-@@ -175,7 +175,7 @@
- 
- 
- // some systems don't properly define isnan()
--#ifdef HAVE_ISNAN
-+#if defined(HAVE_ISNAN) && (__cplusplus < 201103L)
- #ifndef HAVE_PROTOTYPE_ISNAN
- extern "C"
- {
diff -r 4e99aee38edb -r d512048c6931 src/dcmtk.mk
--- a/src/dcmtk.mk	Tue Apr 20 20:40:44 2021 +0200
+++ b/src/dcmtk.mk	Thu Apr 22 16:11:11 2021 +0200
@@ -23,14 +23,13 @@
     cd '$(1)' && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$(HOST_PREFIX)' \
-        --with-openssl \
+        --without-openssl \
         --with-libtiff \
         --with-libpng \
         --with-libxml \
         --with-libxmlinc='$(HOST_PREFIX)' \
         --with-zlib \
         --without-libwrap \
-	--without-openssl \
         CXX='$(MXE_CXX)' \
         RANLIB='$(MXE_RANLIB)' \
         AR='$(MXE_AR)' \
diff -r 4e99aee38edb -r d512048c6931 src/libb64.mk
--- a/src/libb64.mk	Tue Apr 20 20:40:44 2021 +0200
+++ b/src/libb64.mk	Thu Apr 22 16:11:11 2021 +0200
@@ -18,7 +18,7 @@
 
 define $(PKG)_BUILD
 
-    CC=$(MXE_CC) CXX=$(MXE_CXX) PKG_CONFIG=$(MXE_PKG_CONFIG) AR=$(MXE_AR) $(MAKE) -C '$(1)/src'
+    CC=$(MXE_CC) CXX=$(MXE_CXX) PKG_CONFIG=$(MXE_PKG_CONFIG) AR=$(MXE_AR) CFLAGS='-fPIE' $(MAKE) -C '$(1)/src'
 
     $(INSTALL) -d '$(3)$(HOST_LIBDIR)'
     $(INSTALL) -d '$(3)$(HOST_INCDIR)/b64'
diff -r 4e99aee38edb -r d512048c6931 src/libbiosig.mk
--- a/src/libbiosig.mk	Tue Apr 20 20:40:44 2021 +0200
+++ b/src/libbiosig.mk	Thu Apr 22 16:11:11 2021 +0200
@@ -22,47 +22,23 @@
     cd '$(1)' && ./configure \
         ac_cv_func_malloc_0_nonnull=yes \
         ac_cv_func_realloc_0_nonnull=yes \
+        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix=$(HOST_PREFIX) \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS)
+        CC='$(MXE_CC)' \
+        CXX='$(MXE_CXX)' \
+        RANLIB='$(MXE_RANLIB)' \
+        AR='$(MXE_AR)' \
+        ARFLAGS=rcs \
+        LIBTOOL=$(LIBTOOL) \
+        PKG_CONFIG='$(MXE_PKG_CONFIG)' \
+        PKG_CONFIG_PATH='$(HOST_LIBDIR)/pkgconfig'
 
     # make sure NDEBUG is defined
     $(SED) -i '/NDEBUG/ s|#||g' '$(1)'/biosig4c++/Makefile
 
-    TARGET=$(TARGET) CROSS=$(TARGET) $(MAKE) -C '$(1)' lib tools
-
-    # build mexbiosig package (does not install package)
-    # TARGET='$(TARGET)' $(MAKE) -C '$(1)'/biosig4c++ mexbiosig
-
-    # install library files
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig.h'             '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig2.h'            '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/gdftime.h'            '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig-dev.h'         '$(HOST_INCDIR)/'
-
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.a'          '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.def'        '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.dll.a'      '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.dll'        '$(HOST_BINDIR)/'
+    #TARGET=$(TARGET) CROSS=$(TARGET) $(MAKE) -C '$(1)' lib tools
+    $(MAKE) -C '$(1)' LDLIBS='-liconv -lm -ltinyxml' lib tools
+    $(MAKE) -C '$(1)/biosig4c++' install DESTDIR='$(3)'
 
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.a'             '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libgdf.def'           '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.dll.a'         '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.dll'           '$(HOST_BINDIR)/'
-
-
-    $(INSTALL) -m644 '$(1)/biosig4c++/physicalunits.h'      '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.a'   '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.def' '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.dll.a' '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.dll' '$(HOST_BINDIR)/'
-
-    if [ "$(MXE_WINDOWS_BUILD)" == "yes" ]; then \
-        $(SED) -i '/^Libs:/ s/$$/ -liconv -lws2_32/' $(1)/biosig4c++/libbiosig.pc; \
-    fi
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.pc'         '$(HOST_LIBDIR)/pkgconfig/'
-
-    # install biosig4matlab
-    # $(INSTALL) -d $(HOST_PREFIX)/share/biosig/matlab
-    # cp -r '$(1)'/biosig4matlab/* $(HOST_PREFIX)/share/biosig/matlab/
 endef
 
diff -r 4e99aee38edb -r d512048c6931 src/tinyxml-1-cmakelists.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tinyxml-1-cmakelists.patch	Thu Apr 22 16:11:11 2021 +0200
@@ -0,0 +1,22 @@
+diff -burN tinyxml.orig/CMakeLists.txt tinyxml/CMakeLists.txt
+--- tinyxml.orig/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ tinyxml/CMakeLists.txt	2015-06-21 19:03:09.878168410 +0200
+@@ -0,0 +1,18 @@
++cmake_minimum_required(VERSION 2.8)
++
++file(GLOB SRCS "${CMAKE_SOURCE_DIR}/tiny*.cpp" )
++
++include_directories(${CMAKE_SOURCE_DIR})
++add_definitions(-DTIXML_USE_STL)
++
++add_library(tinyxml ${SRCS})
++
++install(TARGETS tinyxml
++  RUNTIME DESTINATION bin
++  LIBRARY DESTINATION lib
++  ARCHIVE DESTINATION lib)
++
++file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/*.h")
++install(FILES ${HEADERS}
++  DESTINATION include)
++
diff -r 4e99aee38edb -r d512048c6931 src/tinyxml.mk
--- a/src/tinyxml.mk	Tue Apr 20 20:40:44 2021 +0200
+++ b/src/tinyxml.mk	Thu Apr 22 16:11:11 2021 +0200
@@ -17,13 +17,23 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(MXE_CXX) -c -O3 -Wall -Wno-unknown-pragmas -Wno-format -D TIXML_USE_STL '$(1)'/*.cpp
-    cd '$(1)' && $(MXE_AR) cr libtinyxml.a *.o
-    $(MXE_RANLIB) '$(1)/libtinyxml.a'
-    $(INSTALL) -d               '$(HOST_LIBDIR)'
-    $(INSTALL) -m644 '$(1)'/*.a '$(HOST_LIBDIR)'
-    $(INSTALL) -d               '$(HOST_INCDIR)'
-    $(INSTALL) -m644 '$(1)'/*.h '$(HOST_INCDIR)'
+    mkdir '$(1)/.build'
+    cd '$(1)/.build' && cmake '$(1)' \
+      -DCMAKE_INSTALL_PREFIX=$(HOST_PREFIX) \
+      $($(PKG)_CMAKE_FLAGS) \
+      $(CMAKE_CCACHE_FLAGS) \
+      $(CMAKE_BUILD_SHARED_OR_STATIC) \
+      -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
+
+    $(MAKE) -C '$(1)/.build' install
+
+#    cd '$(1)' && $(MXE_CXX) -c -O3 -Wall -Wno-unknown-pragmas -Wno-format -D TIXML_USE_STL '$(1)'/*.cpp
+#    cd '$(1)' && $(MXE_AR) cr libtinyxml.a *.o
+#    $(MXE_RANLIB) '$(1)/libtinyxml.a'
+#    $(INSTALL) -d               '$(HOST_LIBDIR)'
+#    $(INSTALL) -m644 '$(1)'/*.a '$(HOST_LIBDIR)'
+#    $(INSTALL) -d               '$(HOST_INCDIR)'
+#    $(INSTALL) -m644 '$(1)'/*.h '$(HOST_INCDIR)'
 
     #'$(MXE_CXX)' \
     #    -W -Wall -D TIXML_USE_STL -Werror -ansi -pedantic \
