Building MING as a shared library for PHP under MacOS X.

It is possible to build MING as a module, even if it isn’t very straight-forward.

Sadly, the latest alpha (0.3b2) is broken with PHP, so I’ve opted to just provide a diff against 0.3b1. The following ‘patch’ will enable the makefiles to build a MacOS X compatible bundle.

Note that 0.3b1 comes with a few objects prebuilt (oops, he didn’t clean very well). You’ll have to “make clean” before building.

The following commands below should get you a version of MING that works with Marc’s PHP.

%cd ming && patch -p1 << /wherever/you/saved/my/patch && make static && install -d /usr/local/lib && install -d /usr/local/include && sudo install -m 0644 libming.a /usr/local/lib/libming.a && ranlib /usr/local/lib/libming.a && install -m 0644 src/ming.h /usr/local/include && install -m 0644 mingpp.h /usr/local/include %cd php_ext && /usr/local/php/bin/phpize && CCFLAGS=”-lpng -lungif -ljpeg” ./configure—with-ming=/usr/local

Then you should be able to just ‘make install’ to have it work.

Here’s the patch:

diff -ur ming.orig/php_ext/Makefile ming/php_ext/Makefile—- ming.orig/php_ext/MakefileSat Nov 8 09:04:10 2003 +++ ming/php_ext/MakefileTue Jan 20 23:13:53 2004 @ -7,7 +7,7 @ CFILES = ming.c php_ming.so: ming.o ../libming.a -${CC} -shared -fPIC ming.o ../libming.a -o php_ming.so ${EXTRA_LIBS} +${CC} ming.o ../libming.a -lpng -ljpeg -lungif -bundle -flat_namespace -undefined suppress -o php_ming.so ${EXTRA_LIBS} ming.o: ${CFILES} ${CC} -fPIC ${DEFINES} -c ming.c -I. -I.. -I../src `php-config—includes` diff -ur ming.orig/src/Makefile ming/src/Makefile—- ming.orig/src/MakefileSat Nov 8 08:09:53 2003 +++ ming/src/MakefileTue Jan 20 23:12:06 2004 @ -36,7 +36,7 @ dynamic: ${OFILES} cd blocks && make cd actioncompiler && make -${CC} ${OFILES} ${COMPILEROFILES} ${LDFLAGS} blocks/*.o -shared -o libming.so +${CC} ${OFILES} ${COMPILEROFILES} ${LDFLAGS} blocks/*.o -lpng -ljpeg -lungif -bundle -flat_namespace -undefined suppress -o libming.so cp libming.so .. static: ${OFILES}