Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add package djvulibre #1286

Merged
merged 13 commits into from Jul 26, 2016
Merged

add package djvulibre #1286

merged 13 commits into from Jul 26, 2016

Conversation

darealshinji
Copy link
Contributor

@darealshinji darealshinji commented Apr 8, 2016

I wasn't able to build v3.5.27 yet. I was able to build shared libraries but they were broken.
Right now only shared libraries can be build and used. Static libraries, if build, are broken.


PKG := djvulibre
$(PKG)_IGNORE := 3.5.27
$(PKG)_VERSION_ := 3.5.25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, $(PKG)_VERSION_ should be renamed to $(PKG)_SHORTVERSION.

@starius
Copy link
Member

starius commented Apr 8, 2016

Can you combine all patches to single file in git like format, please?
To create such patch, ./tools/patch-tool-mxe can be used:

$ ./tools/patch-tool-mxe init djvulibre
$ cd gits/djvulibre-3.5.25
$ git apply path/to/first.patch
$ git commit -m 'description (reason, error fixed, etc)'
$ git apply path/to/second.patch
$ git commit -m 'description (reason, error fixed, etc)'
and so on
$ cd -
$ ./tools/patch-tool-mxe export djvulibre

Single file with all patches in unified format makes browsing history easier.

@darealshinji
Copy link
Contributor Author

@starius
Copy link
Member

starius commented Apr 9, 2016

Like this? https://gist.github.com/darealshinji/e0da804a3eff975954408232a3e4cf1b

No, it lacks commit messages, author and date.

I contributed all the changes in the pull request to your branch: https://github.com/darealshinji/mxe/pull/1

improvements of djvulibre
@darealshinji
Copy link
Contributor Author

Ah, thanks. Merged.

@starius
Copy link
Member

starius commented Apr 9, 2016

Why are shared targets disabled?

@darealshinji
Copy link
Contributor Author

I was able to build them but they didn't seem to work. Maybe you can give it a try?

@starius
Copy link
Member

starius commented Apr 9, 2016

I have built static targets. They produce the following files:
https://gist.github.com/74156e2a0a1662f9a2b9f7723a4b0948

Please prevent installation of $(PREFIX)/$(TARGET)/bin/*.exe and $(PREFIX)/$(TARGET)/bin/any2djvu. The latter is a shell script.

Please prevent installation of $(PREFIX)/$(TARGET)/share/man.

Are other files in $(PREFIX)/$(TARGET)/share needed to use this library? They seem to be a documentation. If they are not needed, please prevent their installation as well.

Please provide a simple test: file src/test-djvulibre.c and a command in the build rules, which produces executable $(PREFIX)/$(TARGET)/bin/test-djvulibre.exe from it. It should use pkg-config to generate compiler and linker flags. The executable should exit with 0 exit status, of course.

Having this work done, it will be easier to deal with shared targets, I think.

@darealshinji
Copy link
Contributor Author

Should the executables still be built or should I only build the library?

@starius
Copy link
Member

starius commented Apr 10, 2016

Executables should be built to catch build errors.

@darealshinji
Copy link
Contributor Author

Alright. To only install the build stuff you can use make -C libdjvu install-lib install-include install-pkgconfig.
This installs the following files for me:

include/libdjvu/ddjvuapi.h
include/libdjvu/miniexp.h
lib/libdjvulibre.a
lib/pkgconfig/ddjvuapi.pc
lib/libdjvulibre.la

Will this serve as a test program?

#include <windows.h>
#include <libdjvu/ddjvuapi.h>

int main(int argc, char *argv[])
{
    ddjvu_context_t *djvu_test;
    djvu_test = ddjvu_context_create(argv[0]);
    ddjvu_context_release(djvu_test);
    return 0;
}

@starius
Copy link
Member

starius commented Apr 10, 2016

Will this serve as a test program?

Can it work without include of windows.h to keep it cross-platform?
Otherwise looks good to me.

@darealshinji
Copy link
Contributor Author

windows.h wasn't necessary. And the created test program works as expected on Windows and returns 0.

@starius
Copy link
Member

starius commented Apr 10, 2016

I'm investigating shared build issues. i686-w64-mingw32.shared works with the patch.

x86_64-w64-mingw32.shared is still broken because of linking problems with jpeg.

I am going to make another pull request against your branch.

@starius
Copy link
Member

starius commented Apr 10, 2016

I have fixed shared targets in a pull request https://github.com/darealshinji/mxe/pull/2

starius and others added 2 commits April 10, 2016 19:21
Patch "fix linking errors in shared builds" fixes i686-w64-mingw32.shared.

Change of djvulibre.mk fixes x86_64-w64-mingw32.shared by changing deplibs
check method to "objdump". See the explanations below.
On Wheezy (at least) "file" returns "data" for x86-64 object files from
libmsvcp60.a. Therefore the check fails with the following message:

*** Warning: linker path does not have real file for library -lmsvcp60.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libmsvcp60 and none of the candidates passed a file format test
*** using a file magic. Last file checked: /home/mxe/mxe-djvulibre/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.3/../../../../x86_64-w64-mingw32.shared/lib//libmsvcp60.a
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.

Then it compiled static library and failed when compiling djvulibre-test.c
because of missing -ljpeg.
djvulibre: enable shared targets
--disable-desktopfiles \
$(if $(BUILD_SHARED),\
lt_cv_deplibs_check_method='file_magic file format (pe-i386|pe-x86-64)' \
lt_cv_file_magic_cmd='$$OBJDUMP -f')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an indication that the libtool included in the tarball is ancient. Try using autoreconf -fi instead of manually specifying the variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starius and others added 2 commits April 10, 2016 23:28
Changes of ./configure were moved to ./configure.ac
to preserve them after `autoreconf -fi`.

See #1286 (comment)
djvulibre: call autoreconf -fi, not change options
@darealshinji
Copy link
Contributor Author

Maybe for the static targets we should add #define MINILISPAPI __declspec(dllexport) and #define DDJVUAPI __declspec(dllexport) to the headers, otherwise the users will always have to manually add -DDLL_EXPORT to their build flags to link against the static libraries.

@TimothyGu
Copy link
Member

Maybe for the static targets we should add #define MINILISPAPI __declspec(dllexport) and #define DDJVUAPI __declspec(dllexport) to the headers

That sounds wrong. Actually, we DON'T want to do this for static builds during the compilation process, which is harmless, OR when users are compiling their own code, which is harmful.

@darealshinji
Copy link
Contributor Author

When I built a pdf/djvu viewer and wanted to link it against the static library I got errors about unresolved import library symbols. But apparently the library can't be build at all without the DLL_EXPORT macro, so right now only a dll can be build.

# This file is part of MXE.
# See index.html for further information.

PKG             := djvulibre
$(PKG)_IGNORE   := 3.5.27
$(PKG)_SHORTVER := 3.5.25
$(PKG)_VERSION  := $($(PKG)_SHORTVER).3
$(PKG)_CHECKSUM := 898d7ed6dd2fa311a521baa95407a91b20a872d80c45e8245442d64f142cb1e0
$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_SHORTVER)
$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/djvu/DjVuLibre/$($(PKG)_SHORTVER)/$($(PKG)_FILE)
$(PKG)_DEPS     := gcc jpeg tiff zlib

define $(PKG)_UPDATE
    $(WGET) -q -O- 'http://sourceforge.net/projects/djvu/files/DjVuLibre/' | \
    $(SED) -n 's,.*/\([0-9][^A-Za-z"]*\)/".*,\1,p' | \
    head -1
endef

define $(PKG)_BUILD_SHARED
    cd '$(1)' && autoreconf -fi
    cd '$(1)' && ./configure $(MXE_CONFIGURE_OPTS) --disable-desktopfiles
    $(MAKE) -C '$(1)' -j '$(JOBS)'
    $(MAKE) -C '$(1)/libdjvu' -j 1 install-lib install-include install-pkgconfig

    '$(TARGET)-g++' \
        -W -Wall -Werror -pedantic \
        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
        `'$(TARGET)-pkg-config' --cflags --libs ddjvuapi`
endef

I still need to check if I can properly build/link the djvu viewer (qpdfview, if anyone wants to know) under the .shared mxe targets.

@darealshinji
Copy link
Contributor Author

The shared library builds and runs without problems on the i686-w64-mingw32.shared target.

@darealshinji
Copy link
Contributor Author

Yesterday I gave it another try and I really wasn't able to build a proper static library.
I've updated the Makefile with those new macros.

@starius
Copy link
Member

starius commented Jul 23, 2016

It fails here in automake with the following error:

configure.ac:44: error: version mismatch.  This is Automake 1.15,
configure.ac:44: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:44: comes from Automake 1.14.1.  You should recreate
configure.ac:44: aclocal.m4 with aclocal and run automake again.

Why did you replaced autoreconf -fi with automake?

@darealshinji
Copy link
Contributor Author

Why did you replaced autoreconf -fi with automake?

I didn't realize that. It's now fixed.

@starius
Copy link
Member

starius commented Jul 24, 2016

Next problem: s/$(TEST_FILE).c/$(TEST_FILE)/

@starius
Copy link
Member

starius commented Jul 24, 2016

After applying s/$(TEST_FILE).c/$(TEST_FILE)/ the build succeeded.
The list of files installed: https://gist.github.com/d866baba1a23870df9308615ea218e14

I applied the following patch:

diff --git a/src/djvulibre.mk b/src/djvulibre.mk
index 3e4f394..4caf6e1 100644
--- a/src/djvulibre.mk
+++ b/src/djvulibre.mk
@@ -22,10 +22,11 @@ define $(PKG)_BUILD_SHARED
     cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \
         $(MXE_CONFIGURE_OPTS) \
         --disable-desktopfiles
-    $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' install-strip
+    $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
+    $(MAKE) -C '$(BUILD_DIR)' -j 1 install-strip $(MXE_DISABLE_CRUFT)

     '$(TARGET)-g++' \
         -W -Wall -Werror -pedantic \
-        '$(TEST_FILE).c' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
+        '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \
         `'$(TARGET)-pkg-config' ddjvuapi --cflags --libs`
 endef

to prevent it from installing docs and tools.

(And to prevent installation with -j > 1.)

Now the list of files is as following:
https://gist.github.com/f728df76fdd000b40d10cba04ce392e0

Looks better, but it still installs shell scripts: any2djvu, djvudigital.

Could you apply my patches and prevent installation of these shell scripts?

@darealshinji
Copy link
Contributor Author

Could you apply my patches and prevent installation of these shell scripts?

Done.

@starius
Copy link
Member

starius commented Jul 24, 2016

Exclusion of shell scripts can be achieved without patching source:

diff --git a/src/djvulibre.mk b/src/djvulibre.mk
index 4caf6e1..5e3fc5b 100644
--- a/src/djvulibre.mk
+++ b/src/djvulibre.mk
@@ -23,7 +23,8 @@ define $(PKG)_BUILD_SHARED
         $(MXE_CONFIGURE_OPTS) \
         --disable-desktopfiles
     $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
-    $(MAKE) -C '$(BUILD_DIR)' -j 1 install-strip $(MXE_DISABLE_CRUFT)
+    $(MAKE) -C '$(BUILD_DIR)' -j 1 install-strip \
+        $(MXE_DISABLE_CRUFT) dist_bin_SCRIPTS=

     '$(TARGET)-g++' \
         -W -Wall -Werror -pedantic \

@darealshinji
Copy link
Contributor Author

Very convenient, I didn't know that.

@starius
Copy link
Member

starius commented Jul 26, 2016

List of files installed: https://gist.github.com/ea0a95023b6bfa8403f0e6611bf242ff

Looks good to me. Very well done!

@starius starius merged commit 22db053 into mxe:master Jul 26, 2016
@darealshinji darealshinji deleted the djvulibre branch July 26, 2016 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants