diff mbox

gnu: Add libjxr.

Message ID 87eg39qvjh.fsf@openmailbox.org
State New
Headers show

Commit Message

Kei Yamashita Oct. 21, 2016, 8:47 p.m. UTC
This is a patch I think we need before fixing up freeimage. Thoughts?
From ac9a3c00c9b9a8232fa7cde26b2ecc46b94f809c Mon Sep 17 00:00:00 2001
From: Kei Kebreau <kei@openmailbox.org>
Date: Fri, 21 Oct 2016 16:39:50 -0400
Subject: [PATCH] gnu: Add libjxr.

* gnu/packages/images.scm (libjxr): New variable.
* gnu/packages/patches/libjxr-fix-function-signature.patch: New file.
* gnu/packages/patches/libjxr-fix-typos.patch: New file.
* gnu/packages/patches/libjxr-use-cmake.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patches.
---
 gnu/local.mk                                       |   3 +
 gnu/packages/image.scm                             |  26 ++++
 .../patches/libjxr-fix-function-signature.patch    |  16 +++
 gnu/packages/patches/libjxr-fix-typos.patch        |  60 +++++++++
 gnu/packages/patches/libjxr-use-cmake.patch        | 143 +++++++++++++++++++++
 5 files changed, 248 insertions(+)
 create mode 100644 gnu/packages/patches/libjxr-fix-function-signature.patch
 create mode 100644 gnu/packages/patches/libjxr-fix-typos.patch
 create mode 100644 gnu/packages/patches/libjxr-use-cmake.patch

Comments

Leo Famulari Oct. 21, 2016, 11:58 p.m. UTC | #1
On Fri, Oct 21, 2016 at 04:47:14PM -0400, Kei Kebreau wrote:
> This is a patch I think we need before fixing up freeimage. Thoughts?

Thanks for working on this!

> +              (uri (string-append "mirror://debian/pool/main/j/jxrlib/jxrlib_"
> +                                  version ".orig.tar.gz"))

Why not download it from the upstream site? We prefer to do that when
possible.

https://jxrlib.codeplex.com/releases/view/107208

> +    (license
> +     (license:non-copyleft
> +      "file://Makefile"
> +      "See the header of the Makefile in the distribution."))

That looks like a 2 clause BSD license:
https://opensource.org/licenses/BSD-2-Clause

> diff --git a/gnu/packages/patches/libjxr-fix-typos.patch b/gnu/packages/patches/libjxr-fix-typos.patch
> new file mode 100644
> index 0000000..3c051dd
> --- /dev/null
> +++ b/gnu/packages/patches/libjxr-fix-typos.patch
> @@ -0,0 +1,60 @@
> +Description: Fix typos and remove some warnings
> +Author: Mathieu Malaterre <malat@debian.org>

Can you include a link to the source of this patch?

> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch b/gnu/packages/patches/libjxr-use-cmake.patch
> new file mode 100644
> index 0000000..cb5919e
> --- /dev/null
> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
> @@ -0,0 +1,143 @@
> +Description: Prefer a cmake based build system
> +Author: Mathieu Malaterre <malat@debian.org>
> +Forwarded: https://jxrlib.codeplex.com/discussions/440294

Why doesn't upstream's build system work?
Kei Yamashita Oct. 22, 2016, 8:33 a.m. UTC | #2
Leo Famulari <leo@famulari.name> writes:

> On Fri, Oct 21, 2016 at 04:47:14PM -0400, Kei Kebreau wrote:
>> This is a patch I think we need before fixing up freeimage. Thoughts?
>
> Thanks for working on this!
>
>> + (uri (string-append "mirror://debian/pool/main/j/jxrlib/jxrlib_"
>> +                                  version ".orig.tar.gz"))
>
> Why not download it from the upstream site? We prefer to do that when
> possible.
>
> https://jxrlib.codeplex.com/releases/view/107208
>

The URL for the upstream site's tarball is
http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=jxrlib&DownloadId=685250&FileTime=130142428056630000&Build=21031.

Is something like that acceptable in Guix code? I know it works with
wget, but I was hesitant to use it as the source URL.


>> +    (license
>> +     (license:non-copyleft
>> +      "file://Makefile"
>> +      "See the header of the Makefile in the distribution."))
>
> That looks like a 2 clause BSD license:
> https://opensource.org/licenses/BSD-2-Clause
>
Indeed it does. I'll have it changed in the next patch I submit.

>> diff --git a/gnu/packages/patches/libjxr-fix-typos.patch
>> b/gnu/packages/patches/libjxr-fix-typos.patch
>> new file mode 100644
>> index 0000000..3c051dd
>> --- /dev/null
>> +++ b/gnu/packages/patches/libjxr-fix-typos.patch
>> @@ -0,0 +1,60 @@
>> +Description: Fix typos and remove some warnings
>> +Author: Mathieu Malaterre <malat@debian.org>
>
> Can you include a link to the source of this patch?
>

This patch comes from Debian's set of patches for the sources. Could I
leave "This patch comes from Debian" with the link to it on the top, or
is more detail necessary?

>> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
>> b/gnu/packages/patches/libjxr-use-cmake.patch
>> new file mode 100644
>> index 0000000..cb5919e
>> --- /dev/null
>> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
>> @@ -0,0 +1,143 @@
>> +Description: Prefer a cmake based build system
>> +Author: Mathieu Malaterre <malat@debian.org>
>> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
>
> Why doesn't upstream's build system work?

Upstream's build system simply doesn't have configuration or
installation targets in the provided Makefile. Using the cmake patch
makes the definition cleaner at the cost of relying on outside work
[1]. If this is not acceptable, I can see about writing manual
replacement phases to the best of my ability.

[1]: https://jxrlib.codeplex.com/discussions/440294
Leo Famulari Oct. 23, 2016, 9:29 p.m. UTC | #3
On Sat, Oct 22, 2016 at 04:33:18AM -0400, Kei Kebreau wrote:
> The URL for the upstream site's tarball is
> http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=jxrlib&DownloadId=685250&FileTime=130142428056630000&Build=21031.
> 
> Is something like that acceptable in Guix code? I know it works with
> wget, but I was hesitant to use it as the source URL.

Now that's an ugly URL! But, I still think we should download the source
code from the upstream site rather than from Debian, whenever possible.

> >> diff --git a/gnu/packages/patches/libjxr-fix-typos.patch
> >> b/gnu/packages/patches/libjxr-fix-typos.patch
> >> new file mode 100644
> >> index 0000000..3c051dd
> >> --- /dev/null
> >> +++ b/gnu/packages/patches/libjxr-fix-typos.patch
> >> @@ -0,0 +1,60 @@
> >> +Description: Fix typos and remove some warnings
> >> +Author: Mathieu Malaterre <malat@debian.org>
> >
> > Can you include a link to the source of this patch?
> >
> 
> This patch comes from Debian's set of patches for the sources. Could I
> leave "This patch comes from Debian" with the link to it on the top, or
> is more detail necessary?

Ideally, patches include a link to their source and a brief explanation
of why we need them. If we write the patch ourselves, then the author(s)
should be named and they should also include an explanation.

One way or another, we should report these bugs upstream.

> >> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
> >> b/gnu/packages/patches/libjxr-use-cmake.patch
> >> new file mode 100644
> >> index 0000000..cb5919e
> >> --- /dev/null
> >> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
> >> @@ -0,0 +1,143 @@
> >> +Description: Prefer a cmake based build system
> >> +Author: Mathieu Malaterre <malat@debian.org>
> >> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
> >
> > Why doesn't upstream's build system work?
> 
> Upstream's build system simply doesn't have configuration or
> installation targets in the provided Makefile. Using the cmake patch
> makes the definition cleaner at the cost of relying on outside work
> [1]. If this is not acceptable, I can see about writing manual
> replacement phases to the best of my ability.
> 
> [1]: https://jxrlib.codeplex.com/discussions/440294

Hm, not an ideal situation.

If Debian is using this patch, we should link to it's source on Debian's
site instead of this message board. I don't know enough about CMake to
judge the patch but I'd be more comfortable if Debian was using it.

What do others think?
Ludovic Courtès Oct. 28, 2016, 1:40 p.m. UTC | #4
Leo Famulari <leo@famulari.name> skribis:

> On Sat, Oct 22, 2016 at 04:33:18AM -0400, Kei Kebreau wrote:

[...]

>> >> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
>> >> b/gnu/packages/patches/libjxr-use-cmake.patch
>> >> new file mode 100644
>> >> index 0000000..cb5919e
>> >> --- /dev/null
>> >> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
>> >> @@ -0,0 +1,143 @@
>> >> +Description: Prefer a cmake based build system
>> >> +Author: Mathieu Malaterre <malat@debian.org>
>> >> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
>> >
>> > Why doesn't upstream's build system work?
>> 
>> Upstream's build system simply doesn't have configuration or
>> installation targets in the provided Makefile. Using the cmake patch
>> makes the definition cleaner at the cost of relying on outside work
>> [1]. If this is not acceptable, I can see about writing manual
>> replacement phases to the best of my ability.
>> 
>> [1]: https://jxrlib.codeplex.com/discussions/440294
>
> Hm, not an ideal situation.
>
> If Debian is using this patch, we should link to it's source on Debian's
> site instead of this message board. I don't know enough about CMake to
> judge the patch but I'd be more comfortable if Debian was using it.
>
> What do others think?

Regarding the choice between writing our own installation phase in
Scheme and using this CMake thing instead, I think we should choose the
most concise approach (in terms of lines of code).

If the winner here is the CMake patch, then indeed, we should take the
patch from Debian rather than from a message board (and include
provenance information in the patch, as you wrote.)

That said, I suspect an ‘install’ phase in Scheme would be more concise
than this new CMakeLists.txt (134 lines).

Kei: WDYT?

Thanks!

Ludo’.
Kei Yamashita Oct. 29, 2016, 4:46 a.m. UTC | #5
ludo@gnu.org (Ludovic Courtès) writes:

> Leo Famulari <leo@famulari.name> skribis:
>
>> On Sat, Oct 22, 2016 at 04:33:18AM -0400, Kei Kebreau wrote:
>
> [...]
>
>>> >> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
>>> >> b/gnu/packages/patches/libjxr-use-cmake.patch
>>> >> new file mode 100644
>>> >> index 0000000..cb5919e
>>> >> --- /dev/null
>>> >> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
>>> >> @@ -0,0 +1,143 @@
>>> >> +Description: Prefer a cmake based build system
>>> >> +Author: Mathieu Malaterre <malat@debian.org>
>>> >> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
>>> >
>>> > Why doesn't upstream's build system work?
>>> 
>>> Upstream's build system simply doesn't have configuration or
>>> installation targets in the provided Makefile. Using the cmake patch
>>> makes the definition cleaner at the cost of relying on outside work
>>> [1]. If this is not acceptable, I can see about writing manual
>>> replacement phases to the best of my ability.
>>> 
>>> [1]: https://jxrlib.codeplex.com/discussions/440294
>>
>> Hm, not an ideal situation.
>>
>> If Debian is using this patch, we should link to it's source on Debian's
>> site instead of this message board. I don't know enough about CMake to
>> judge the patch but I'd be more comfortable if Debian was using it.
>>
>> What do others think?
>
> Regarding the choice between writing our own installation phase in
> Scheme and using this CMake thing instead, I think we should choose the
> most concise approach (in terms of lines of code).
>
> If the winner here is the CMake patch, then indeed, we should take the
> patch from Debian rather than from a message board (and include
> provenance information in the patch, as you wrote.)
>
> That said, I suspect an ‘install’ phase in Scheme would be more concise
> than this new CMakeLists.txt (134 lines).
>
> Kei: WDYT?
>

I have been working on writing our own installation phase, and it looks
like it will be more concise. However, the patches need to be in DOS
format to apply. The patch doesn't seem to carry these line returns,
which leads me to believe that a standard git configuration won't accept
them. Is there way around this?

> Thanks!
>
> Ludo’.
Ludovic Courtès Oct. 29, 2016, 9:02 p.m. UTC | #6
Kei Kebreau <kei@openmailbox.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Leo Famulari <leo@famulari.name> skribis:
>>
>>> On Sat, Oct 22, 2016 at 04:33:18AM -0400, Kei Kebreau wrote:
>>
>> [...]
>>
>>>> >> diff --git a/gnu/packages/patches/libjxr-use-cmake.patch
>>>> >> b/gnu/packages/patches/libjxr-use-cmake.patch
>>>> >> new file mode 100644
>>>> >> index 0000000..cb5919e
>>>> >> --- /dev/null
>>>> >> +++ b/gnu/packages/patches/libjxr-use-cmake.patch
>>>> >> @@ -0,0 +1,143 @@
>>>> >> +Description: Prefer a cmake based build system
>>>> >> +Author: Mathieu Malaterre <malat@debian.org>
>>>> >> +Forwarded: https://jxrlib.codeplex.com/discussions/440294
>>>> >
>>>> > Why doesn't upstream's build system work?
>>>> 
>>>> Upstream's build system simply doesn't have configuration or
>>>> installation targets in the provided Makefile. Using the cmake patch
>>>> makes the definition cleaner at the cost of relying on outside work
>>>> [1]. If this is not acceptable, I can see about writing manual
>>>> replacement phases to the best of my ability.
>>>> 
>>>> [1]: https://jxrlib.codeplex.com/discussions/440294
>>>
>>> Hm, not an ideal situation.
>>>
>>> If Debian is using this patch, we should link to it's source on Debian's
>>> site instead of this message board. I don't know enough about CMake to
>>> judge the patch but I'd be more comfortable if Debian was using it.
>>>
>>> What do others think?
>>
>> Regarding the choice between writing our own installation phase in
>> Scheme and using this CMake thing instead, I think we should choose the
>> most concise approach (in terms of lines of code).
>>
>> If the winner here is the CMake patch, then indeed, we should take the
>> patch from Debian rather than from a message board (and include
>> provenance information in the patch, as you wrote.)
>>
>> That said, I suspect an ‘install’ phase in Scheme would be more concise
>> than this new CMakeLists.txt (134 lines).
>>
>> Kei: WDYT?
>>
>
> I have been working on writing our own installation phase, and it looks
> like it will be more concise.

Cool, thanks!

> However, the patches need to be in DOS format to apply. The patch
> doesn't seem to carry these line returns, which leads me to believe
> that a standard git configuration won't accept them. Is there way
> around this?

But that’s unrelated to removing the CMakeLists.txt patch and adding
your own install phase, right?  :-)

From the description I’m not sure exactly what the problem is, but
perhaps the ‘--binary’ option of ‘patch’ can help?  You can specify it
in ‘patch-flags’:

  https://www.gnu.org/software/guix/manual/html_node/origin-Reference.html

Ludo’.
diff mbox

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c6cd586..911af78 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -633,6 +633,9 @@  dist_patch_DATA =						\
   %D%/packages/patches/libdrm-symbol-check.patch		\
   %D%/packages/patches/libevent-dns-tests.patch			\
   %D%/packages/patches/libextractor-ffmpeg-3.patch		\
+  %D%/packages/patches/libjxr-fix-function-signature.patch	\
+  %D%/packages/patches/libjxr-fix-typos.patch			\
+  %D%/packages/patches/libjxr-use-cmake.patch			\
   %D%/packages/patches/liboop-mips64-deplibs-fix.patch		\
   %D%/packages/patches/libotr-test-auth-fix.patch		\
   %D%/packages/patches/liblxqt-include.patch			\
diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 4b064bb..b1b40b3 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -11,6 +11,7 @@ 
 ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2016 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2016 Kei Kebreau <kei@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -129,6 +130,31 @@  image files in PBMPLUS PPM/PGM, GIF, BMP, and Targa file formats.")
             (sha256 (base32
                      "1cz0dy05mgxqdgjf52p54yxpyy95rgl30cnazdrfmw7hfca9n0h0"))))))
 
+(define-public libjxr
+  (package
+    (name "libjxr")
+    (version "1.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://debian/pool/main/j/jxrlib/jxrlib_"
+                                  version ".orig.tar.gz"))
+              (sha256
+               (base32
+                "00w3f3cmjsm3fiaxq5mxskmp5rl3mki8psrf9y8s1vqbg237na67"))
+              (patches (search-patches "libjxr-fix-function-signature.patch"
+                                       "libjxr-use-cmake.patch"
+                                       "libjxr-fix-typos.patch"))))
+    (build-system cmake-build-system)
+    (arguments '(#:tests? #f)) ; no check target
+    (synopsis "Implementation of the JPEG XR standard")
+    (description "JPEG XR is an approved ISO/IEC International standard (its
+official designation is ISO/IEC 29199-2). This library is an implementation of that standard.")
+    (license
+     (license:non-copyleft
+      "file://Makefile"
+      "See the header of the Makefile in the distribution."))
+    (home-page "https://jxrlib.codeplex.com/")))
+
 (define-public jpegoptim
   (package
    (name "jpegoptim")
diff --git a/gnu/packages/patches/libjxr-fix-function-signature.patch b/gnu/packages/patches/libjxr-fix-function-signature.patch
new file mode 100644
index 0000000..9efc339
--- /dev/null
+++ b/gnu/packages/patches/libjxr-fix-function-signature.patch
@@ -0,0 +1,16 @@ 
+Description: Fix function signature
+Author: Mathieu Malaterre <malat@debian.org>
+Origin: upstream, https://jxrlib.codeplex.com/SourceControl/changeset/04cf339385b8196f98025b43a366a0790deac994
+Bug-Debian: http://bugs.debian.org/748590
+
+--- jxrlib-1.1.orig/image/decode/JXRTranscode.c
++++ jxrlib-1.1/image/decode/JXRTranscode.c
+@@ -47,7 +47,7 @@ EXTERN_C Void FreeCodingContextDec(CWMIm
+ EXTERN_C Int StrEncInit(CWMImageStrCodec *);
+ EXTERN_C Void StrIOEncTerm(CWMImageStrCodec *);
+ EXTERN_C Void FreeCodingContextEnc(CWMImageStrCodec *);
+-EXTERN_C Void encodeMB(CWMImageStrCodec *, Int, Int);
++EXTERN_C Int encodeMB(CWMImageStrCodec *, Int, Int);
+ EXTERN_C Int  writeIndexTableNull(CWMImageStrCodec *);
+ EXTERN_C Void writePacketHeader(BitIOInfo *, U8, U8);
+ 
diff --git a/gnu/packages/patches/libjxr-fix-typos.patch b/gnu/packages/patches/libjxr-fix-typos.patch
new file mode 100644
index 0000000..3c051dd
--- /dev/null
+++ b/gnu/packages/patches/libjxr-fix-typos.patch
@@ -0,0 +1,60 @@ 
+Description: Fix typos and remove some warnings
+Author: Mathieu Malaterre <malat@debian.org>
+
+Index: jxrlib-1.1/CMakeLists.txt
+===================================================================
+--- jxrlib-1.1.orig/CMakeLists.txt
++++ jxrlib-1.1/CMakeLists.txt
+@@ -91,7 +91,7 @@ add_library(jxrglue ${OBJ_GLUE} ${OBJ_TE
+ set_property(TARGET jxrglue
+   PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
+ )
+-set_property(TARGET jxrglue PROPERTY LINK_INTERFACE_LIBRARIES "")
++#set_property(TARGET jxrglue PROPERTY LINK_INTERFACE_LIBRARIES "")
+ set_property(TARGET jxrglue PROPERTY COMPILE_FLAGS -w)
+ # VERSION/SOVERSION
+ set_property(TARGET jxrglue PROPERTY VERSION 1.1)
+@@ -104,14 +104,15 @@ install(TARGETS jxrglue
+ #if(HAVE_STRLCPY_BSD)
+ #	target_link_libraries(jxrglue ${BSD_LIBRARY})
+ #endif()
+-target_link_libraries(jxrglue jpegxr m)
++#target_link_libraries(jxrglue m)
++target_link_libraries(jxrglue PRIVATE jpegxr m)
+ # Enc app files
+ set(ENCAPP JxrEncApp)
+ add_executable(${ENCAPP} ${DIR_EXEC}/${ENCAPP}.c)
+ set_property(TARGET ${ENCAPP}
+   PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
+ )
+-set_property(TARGET ${ENCAPP} PROPERTY COMPILE_FLAGS -w)
++#set_property(TARGET ${ENCAPP} PROPERTY COMPILE_FLAGS -w)
+ target_link_libraries(${ENCAPP} jxrglue) # jpegxr)
+ install(TARGETS ${ENCAPP} RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR})
+ # Dec app files
+Index: jxrlib-1.1/jxrencoderdecoder/JxrEncApp.c
+===================================================================
+--- jxrlib-1.1.orig/jxrencoderdecoder/JxrEncApp.c
++++ jxrlib-1.1/jxrencoderdecoder/JxrEncApp.c
+@@ -578,7 +578,7 @@ main(int argc, char* argv[])
+ 
+     //================================
+     Call(PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION));
+-    Call(pCodecFactory->CreateCodec(&IID_PKImageWmpEncode, &pEncoder));
++    Call(pCodecFactory->CreateCodec(&IID_PKImageWmpEncode, (void**)&pEncoder));
+ 
+     //----------------------------------------------------------------
+     Call(PKCreateTestFactory(&pTestFactory, WMP_SDK_VERSION));
+Index: jxrlib-1.1/jxrgluelib/JXRMeta.h
+===================================================================
+--- jxrlib-1.1.orig/jxrgluelib/JXRMeta.h
++++ jxrlib-1.1/jxrgluelib/JXRMeta.h
+@@ -34,7 +34,7 @@
+ 
+ #ifndef UNREFERENCED_PARAMETER
+ #define UNREFERENCED_PARAMETER(P) { (P) = (P); }
+-#endif UNREFERENCED_PARAMETER
++#endif /*UNREFERENCED_PARAMETER*/
+ 
+ //================================================================
+ // Container
diff --git a/gnu/packages/patches/libjxr-use-cmake.patch b/gnu/packages/patches/libjxr-use-cmake.patch
new file mode 100644
index 0000000..cb5919e
--- /dev/null
+++ b/gnu/packages/patches/libjxr-use-cmake.patch
@@ -0,0 +1,143 @@ 
+Description: Prefer a cmake based build system
+Author: Mathieu Malaterre <malat@debian.org>
+Forwarded: https://jxrlib.codeplex.com/discussions/440294
+
+Index: jxrlib-1.1/CMakeLists.txt
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ jxrlib-1.1/CMakeLists.txt	2014-03-26 17:05:04.429637801 +0100
+@@ -0,0 +1,134 @@
++# Copyright Mathieu Malaterre <malat@debian.org>
++# BSD (Same as jxrlib)
++cmake_minimum_required(VERSION 2.8)
++project(jxrlib C)
++
++# Need shared libs for ABI
++set(BUILD_SHARED_LIBS ON)
++
++# helper macro to preserve original Makefile convention
++macro(JXR_MAKE_OBJ SET_NAME)
++  foreach(src ${SRC_${SET_NAME}})
++    list(APPEND OBJ_${SET_NAME} ${DIR_${SET_NAME}}/${src})
++  endforeach()
++endmacro()
++
++include(TestBigEndian)
++test_big_endian(ISBIGENDIAN)
++if(ISBIGENDIAN)
++  set(DEF_ENDIAN _BIG__ENDIAN_)
++endif()
++
++set(DIR_SYS image/sys)
++set(DIR_DEC image/decode)
++set(DIR_ENC image/encode)
++
++set(DIR_GLUE jxrgluelib)
++set(DIR_TEST jxrtestlib)
++set(DIR_EXEC jxrencoderdecoder)
++
++if(NOT JXRLIB_INSTALL_BIN_DIR)
++  set(JXRLIB_INSTALL_BIN_DIR "bin")
++endif()
++
++if(NOT JXRLIB_INSTALL_LIB_DIR)
++  set(JXRLIB_INSTALL_LIB_DIR "lib")
++endif()
++
++if(NOT JXRLIB_INSTALL_INCLUDE_DIR)
++  set(JXRLIB_INSTALL_INCLUDE_DIR "include/jxrlib")
++endif()
++
++include_directories(
++  common/include
++  ${DIR_SYS}
++  ${DIR_GLUE}
++  ${DIR_TEST}
++)
++
++# where is strlcpy ?
++include(CheckSymbolExists)
++check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
++#set(CMAKE_REQUIRED_LIBRARIES bsd)
++#CHECK_SYMBOL_EXISTS(strlcpy "string.h" HAVE_STRLCPY4)
++# on linux, strlcpy is in -lbsd:
++#if(NOT HAVE_STRLCPY)
++#  include(CheckLibraryExists)
++#  find_library(BSD_LIBRARY bsd)
++#  check_library_exists(bsd "strlcpy" ${BSD_LIBRARY} HAVE_STRLCPY_BSD)
++#endif()
++
++# JPEG-XR
++set(SRC_SYS adapthuff.c image.c strcodec.c strPredQuant.c strTransform.c perfTimerANSI.c)
++JXR_MAKE_OBJ(SYS)
++set(SRC_DEC decode.c postprocess.c segdec.c strdec.c strInvTransform.c strPredQuantDec.c JXRTranscode.c)
++JXR_MAKE_OBJ(DEC)
++set(SRC_ENC encode.c segenc.c strenc.c strFwdTransform.c strPredQuantEnc.c)
++JXR_MAKE_OBJ(ENC)
++
++add_library(jpegxr ${OBJ_ENC} ${OBJ_DEC} ${OBJ_SYS})
++set_property(TARGET jpegxr
++  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
++)
++set_property(TARGET jpegxr PROPERTY LINK_INTERFACE_LIBRARIES "")
++set_property(TARGET jpegxr PROPERTY COMPILE_FLAGS -w)
++# VERSION/SOVERSION
++set_property(TARGET jpegxr PROPERTY VERSION 1.1)
++set_property(TARGET jpegxr PROPERTY SOVERSION 0)
++install(TARGETS jpegxr
++  EXPORT JXRLibTargets
++  RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR} COMPONENT Applications
++  LIBRARY DESTINATION ${JXRLIB_INSTALL_LIB_DIR} COMPONENT Libraries
++)
++
++# JXR-GLUE
++set(SRC_GLUE JXRGlue.c JXRMeta.c JXRGluePFC.c JXRGlueJxr.c)
++JXR_MAKE_OBJ(GLUE)
++set(SRC_TEST JXRTest.c JXRTestBmp.c JXRTestHdr.c JXRTestPnm.c JXRTestTif.c JXRTestYUV.c)
++JXR_MAKE_OBJ(TEST)
++
++add_library(jxrglue ${OBJ_GLUE} ${OBJ_TEST})
++set_property(TARGET jxrglue
++  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
++)
++set_property(TARGET jxrglue PROPERTY LINK_INTERFACE_LIBRARIES "")
++set_property(TARGET jxrglue PROPERTY COMPILE_FLAGS -w)
++# VERSION/SOVERSION
++set_property(TARGET jxrglue PROPERTY VERSION 1.1)
++set_property(TARGET jxrglue PROPERTY SOVERSION 0)
++install(TARGETS jxrglue
++  EXPORT JXRLibTargets
++  RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR} COMPONENT Applications
++  LIBRARY DESTINATION ${JXRLIB_INSTALL_LIB_DIR} COMPONENT Libraries
++)
++#if(HAVE_STRLCPY_BSD)
++#	target_link_libraries(jxrglue ${BSD_LIBRARY})
++#endif()
++target_link_libraries(jxrglue jpegxr m)
++# Enc app files
++set(ENCAPP JxrEncApp)
++add_executable(${ENCAPP} ${DIR_EXEC}/${ENCAPP}.c)
++set_property(TARGET ${ENCAPP}
++  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
++)
++set_property(TARGET ${ENCAPP} PROPERTY COMPILE_FLAGS -w)
++target_link_libraries(${ENCAPP} jxrglue) # jpegxr)
++install(TARGETS ${ENCAPP} RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR})
++# Dec app files
++set(DECAPP JxrDecApp)
++add_executable(${DECAPP} ${DIR_EXEC}/${DECAPP}.c)
++set_property(TARGET ${DECAPP}
++  PROPERTY COMPILE_DEFINITIONS __ANSI__ DISABLE_PERF_MEASUREMENT ${DEF_ENDIAN}
++)
++set_property(TARGET ${DECAPP} PROPERTY COMPILE_FLAGS -w)
++target_link_libraries(${DECAPP} jxrglue) # jpegxr)
++install(TARGETS ${DECAPP} RUNTIME DESTINATION ${JXRLIB_INSTALL_BIN_DIR})
++
++# install rules
++install(FILES jxrgluelib/JXRGlue.h jxrgluelib/JXRMeta.h jxrtestlib/JXRTest.h
++  image/sys/windowsmediaphoto.h
++  DESTINATION ${JXRLIB_INSTALL_INCLUDE_DIR} COMPONENT Headers
++)
++install(DIRECTORY common/include/ DESTINATION ${JXRLIB_INSTALL_INCLUDE_DIR}
++  FILES_MATCHING PATTERN "*.h"
++)