eklausme / php-md4c

MD4C PHP extension: convert Markdown to HTML
MIT License
1 stars 1 forks source link

Linux build issues #7

Open cmb69 opened 4 hours ago

cmb69 commented 4 hours ago

I tried to build the extension on Linux (actually WSL 2 with Debian bookworm), but that failed because I don't have md4c-dev installed:

checking whether to enable MD4C support... yes, shared
checking for md4c headers... not found
configure: error: Please install md4c

Since md4c-dev is not readily available on Debian bookworm, I tried building with the bundled md4c, and changed config.md4 to:

dnl config.m4 for php-md4c extension

PHP_ARG_WITH(md4c, [whether to enable MD4C support],
[  --with-md4c[[=DIR]]       Enable MD4C support.
                          DIR is the path to MD4C install prefix])

if test "$PHP_MD4C" != "no"; then
    PHP_SUBST(MD4C_SHARED_LIBADD)
    AC_DEFINE(HAVE_MD4C, 1, [ ])
    PHP_NEW_EXTENSION(md4c, md4c.c, $ext_shared)
fi

Afterwards the build succeeded:

$ phpize
$ ./configure --with-md4c
$ make
$ make test

Now I thought that the build probably cannot succeed with a system md4c library, since it is already contained in md4c.c. So either you can completely drop support for building against a system md4c, or would need to put the md4c amalgamation in a separate file, and only use this if the system library is not available. I assume that distro maintainers prefer the latter (to be able to build against system libraries). Maybe @remicollet can clarify?

eklausme commented 3 hours ago

Sorry, I should have taken out any reference to header or libraries for building. That was the whole point of amalgamation, so there is no dependency. In particular Windows won't have MD4C installed.

Also, line 7:

if test "$PHP_YAML" != "no"; then

should use $PHP_MD4C instead.

cmb69 commented 3 hours ago

In particular Windows won't have MD4C installed.

Right, but that dependency could be made available on https://downloads.php.net/~windows/pecl/deps/, and could be put in the Windows builds of md4c like for other extensions (e.g. imagick), or built statically into php_md4c.dll.

eklausme commented 3 hours ago

I committed your proposed config.m4.

cmb69 commented 2 hours ago

Okay, might be best to have the library bundled for now, because it has not reached version 1.0, so some things might change.