[freebsd] archive category

Install PHP 5.3.3 on Mac OS Leopard 10.5.8

My attempt at building and installing PHP 5.3.3 crashed and burned with the following error while building the MySQLi extension:

/bin/sh /Users/kelvin/phpsource/php-5.3.3/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/mysqli/ -I/Users/kelvin/phpsource/php-5.3.3/ext/mysqli/ -DPHP_ATOM_INC -I/Users/kelvin/phpsource/php-5.3.3/include -I/Users/kelvin/phpsource/php-5.3.3/main -I/Users/kelvin/phpsource/php-5.3.3 -I/Users/kelvin/phpsource/php-5.3.3/ext/date/lib -I/Users/kelvin/phpsource/php-5.3.3/ext/ereg/regex -I/usr/local/php5/include/libxml2 -I/usr/local/php5/include -I/opt/local/include -I/usr/local/php5/include/freetype2 -I/Users/kelvin/phpsource/php-5.3.3/ext/mbstring/oniguruma -I/Users/kelvin/phpsource/php-5.3.3/ext/mbstring/libmbfl -I/Users/kelvin/phpsource/php-5.3.3/ext/mbstring/libmbfl/mbfl -I/usr/local/mysql/include/mysql -I/Users/kelvin/phpsource/php-5.3.3/ext/sqlite3/libsqlite -I/usr/local/pgsql/include -I/Users/kelvin/phpsource/php-5.3.3/TSRM -I/Users/kelvin/phpsource/php-5.3.3/Zend  -no-cpp-precomp  -I/usr/local/php5/include -g -O2 -fvisibility=hidden  -c /Users/kelvin/phpsource/php-5.3.3/ext/mysqli/mysqli.c -o ext/mysqli/mysqli.lo 
 In file included from /Users/kelvin/phpsource/php-5.3.3/ext/mysqli/php_mysqli_structs.h:57,
                  from /Users/kelvin/phpsource/php-5.3.3/ext/mysqli/mysqli.c:33:
 /usr/local/mysql/include/mysql/my_global.h:895: error: duplicate ‘unsigned’
 /usr/local/mysql/include/mysql/my_global.h:895: warning: useless type name in empty declaration
 make: *** [ext/mysqli/mysqli.lo] Error 1
Trinity:~ kelvin$

According to the PHP bug tracker, the problem is a bug that affects Snow Leopard and FreeBSD as well. The fix is pretty simple, either you can build PHP from the head of the trunk from Subversion, or you can replace php-5.3.3/ext/mysqli/php_mysqli_structs.h with this patched version or you can just open one file (php-5.3.3/ext/mysqli/php_mysqli_structs.h) in your text editor and fix it yourself:

Trinity:~ kelvin$ sudo vim /Users/kelvin/phpsource/php-5.3.3/ext/mysqli/php_mysqli_structs.h

Go to line 59 and insert the following:

59
60
61
#if defined(ulong) && !defined(HAVE_ULONG)
#define HAVE_ULONG
#endif

The patched section of the file will then read as follows:

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
  The libmysql headers (a PITA) also define it and there will be an warning.
  Undef it and later we might need to define it again.
*/
#ifdef HAVE_MBRLEN
#undef HAVE_MBRLEN
#define WE_HAD_MBRLEN
#endif
#ifdef HAVE_MBSTATE_T
#undef HAVE_MBSTATE_T
#define WE_HAD_MBSTATE_T
#endif
 
#if defined(ulong) && !defined(HAVE_ULONG)
#define HAVE_ULONG
#endif
 
#include <my_global.h>
 
#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
#define HAVE_MBRLEN 1
#endif
 
#if !defined(HAVE_MBSTATE_T) && defined(WE_HAD_MBSTATE_T)
#define HAVE_MBSTATE_T 1
#endif

The rest of the build and install was uneventful after patching php_mysqli_structs.h.

Tags: , ,

Getting the Drives Right on Conky (FreeBSD 7)

I’m loading FreeBSD 7 onto my ancient Toshiba Satellite 2800; I plan to use it as a terminal for some servers. Conky displays system stats on my Fluxbox desktop.

I was having trouble getting the drive stats to show up. Here are my .conkyrc tags:

Disk usage: ${fs_used /usr }/${fs_size /usr } - ${fs_used_perc /usr }%
${fs_bar 3,200 /usr }

I wanted the stats on the /usr directory because it is mapped to the largest partition on the hard drive. Conky was displaying zero values like it couldn’t find anything. Trouble! Consider:

Mansfield# df -ah
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ad0s1a    496M    196M    260M    43%    /
devfs          1.0K    1.0K      0B   100%    /dev
/dev/ad0s1e    496M    110K    456M     0%    /tmp
/dev/ad0s1f     15G    4.3G    9.9G    30%    /usr
/dev/ad0s1d    1.2G     99M    1.0G     9%    /var
Mansfield# 

After much Googling and head scratching, I discovered that I had inserted an extra space behind the device specifier. Conky will not display anything if there is an extra character between the drive label and the end of the tag! So here is the fix.

Disk usage: ${fs_used /usr}/${fs_size /usr} - ${fs_used_perc /usr}%
${fs_bar 3,200 /usr}

Live and learn.

Conky running!

Conky running!

Tags: , , , , , ,