DirectFB-1.0.1をFreeBSD7RでMake

Directfb: http://www.directfb.org/

directfb-1.0.1をFreeBSDでmakeしたのでそのメモ。手でmakeなんてひさびさだから思わずメモしてしまいました。

% ./configure --enable-x11      
% make

でconfigureとmake。Build Optionはこんな感じになった。

Build options:
  Version                   1.0.1
  Install prefix            /usr/local
  Build shared libs         yes
  Build static libs         no
  Module directory          ${exec_prefix}/lib/directfb-1.0-0
  CPPFLAGS                  -D_REENTRANT  -I/usr/local/include
  CFLAGS                    -O3 -ffast-math -pipe  -D_GNU_SOURCE
  -Werror-implicit-function-declaration
  LDFLAGS                    -L/usr/local/lib
  LIBS                      -lc_r

Misc options:
  Multi Application Core    no
  Fusion message size       1024
  Voodoo (network support)  no
  Debug supported           yes
  Debug enabled             no
  Trace support             no
  MMX support               yes
  SSE support               yes
  Network support           yes
  zlib compression          no
  sysfs support             no

Building Core Systems:
  Linux FBDev support       no
  X11 support               yes
  OSX support               no
  SDL support               yes
  VNC support               no

Building WM Modules:
  Default                   yes
  UniQuE                    no

Building Tests              no
Building Tools              yes

Building Image Providers:
  GIF                       yes
  JPEG                      yes
  MPEG2 I-Frame             yes
  PNG                       yes

Building Video Providers:
  GIF                       yes
  Video4Linux               no (v2: no)

Building Font implementations:
  FreeType2                 yes
  Default font              yes


で、

log.c: In function 'parse_host_addr':
log.c:266: error: 'EAI_ADDRFAMILY' undeclared (first use in this function)
log.c:266: error: (Each undeclared identifier is reported only once
log.c:266: error: for each function it appears in.)
log.c:267: error: 'EAI_NODATA' undeclared (first use in this function)
*** Error code 1

Stop in src/DirectFB-1.0.1/lib/direct.

と言われる。/usr/include/netdb.hを見ると、EAT_ADDRFAMILYとEAI_NODATAはobsoletedだそうで。代わりにどれを入れるか考えるのがめんどいので、全部消す。

--- log.c.orig  2008-05-14 16:53:31.158125717 +0900
+++ log.c       2008-05-14 16:56:55.005725227 +0900
@@ -263,11 +263,6 @@
                     D_ERROR( "Direct/Log: Port %s is unreachable!\n",
		     portstr );
                     return DFB_FAILURE;

-               case EAI_ADDRFAMILY:
-               case EAI_NODATA:
-                    D_ERROR( "Direct/Log: Host found, but has no address!\n" );
-                    return DFB_FAILURE;
-
                case EAI_MEMORY:
                     return D_OOM();

次。pthreadがないと言われる。

gcc -D_REENTRANT -I/usr/local/include -O3 -ffast-math -pipe -D_GNU_SOURCE -Werror-implicit-function-declaration -o .libs/dtestdtest-dtest.o 
-L/usr/local/lib ./.libs/libdirect.so -lz  -Wl,--rpath -Wl,/usr/local/lib 
./.libs/libdirect.so: undefined reference to `pthread_create'
*** Error code 1

Stop in src/DirectFB-1.0.1/lib/direct.

lib/direct/Makefileをいじる。

--- Makefile.orig       2008-05-14 17:01:43.409660591 +0900
+++ Makefile    2008-05-14 17:01:12.179205794 +0900
@@ -186,7 +186,7 @@
 LIBOBJS =
 LIBPNG = -lpng -lz -lm
 LIBPNG_CONFIG = /usr/local/bin/libpng-config
-LIBS = -lc_r
+LIBS = -lc_r -pthread
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LN_S = ln -s
 LTLIBOBJS =


次。

idirectfbsurface.c:35:20: error: alloca.h: No such file or directory
*** Error code 1

Stop in src/DirectFB-1.0.1/src/display.

alloca.hはFreeBSDにはないぞ。Webを見てみてると、消してる人がいるので消してみる。

--- idirectfbsurface.c.orig     2008-05-14 17:17:20.787571461 +0900
+++ idirectfbsurface.c  2008-05-14 17:17:27.504696168 +0900
@@ -32,7 +32,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <alloca.h>
+// #include <alloca.h>

 #include <math.h>

次。

conf.c: In function 'dfb_config_set':
conf.c:1073: error: 'ulong' undeclared (first use in this function)
conf.c:1073: error: (Each undeclared identifier is reported only once
conf.c:1073: error: for each function it appears in.)
conf.c:1073: error: expected ';' before 'phys'
conf.c:1075: error: 'phys' undeclared (first use in this function)
conf.c:1092: error: expected ';' before 'length'
conf.c:1094: error: 'length' undeclared (first use in this function)
conf.c:1111: error: expected ';' before 'phys'
conf.c:1130: error: expected ';' before 'length'
conf.c:1149: error: expected ';' before 'accel'
conf.c:1151: error: 'accel' undeclared (first use in this function)
*** Error code 1

Stop in src/DirectFB-1.0.1/src/misc.

ulongってないのよー。

--- conf.c.orig 2008-05-14 17:23:51.485780253 +0900
+++ conf.c      2008-05-14 17:23:28.710022420 +0900
@@ -1072,7 +1070,7 @@
      if (strcmp (name, "video-phys" ) == 0) {
           if (value) {
                char *error;
-               ulong phys;
+               u_long phys;

                phys = strtoul( value, &error, 16 );

@@ -1091,7 +1089,7 @@
      if (strcmp (name, "video-length" ) == 0) {
           if (value) {
                char *error;
-               ulong length;
+               u_long length;

                length = strtoul( value, &error, 10 );

@@ -1110,7 +1108,7 @@
      if (strcmp (name, "mmio-phys" ) == 0) {
           if (value) {
                char *error;
-               ulong phys;
+               u_long phys;

                phys = strtoul( value, &error, 16 );

@@ -1129,7 +1127,7 @@
      if (strcmp (name, "mmio-length" ) == 0) {
           if (value) {
                char *error;
-               ulong length;
+               u_long length;

                length = strtoul( value, &error, 10 );

@@ -1148,7 +1146,7 @@
      if (strcmp (name, "accelerator" ) == 0) {
           if (value) {
                char *error;
-               ulong accel;
+               u_long accel;

                accel = strtoul( value, &error, 10 );

次。またもやpthread。

../src/.libs/libdirectfb.so: undefined reference to `pthread_create'
*** Error code 1

Stop in src/DirectFB-1.0.1/tools.
*** Error code 1

tools/Makefileを書き換える。

--- Makefile.orig       2008-05-14 16:52:06.454739399 +0900
+++ Makefile    2008-05-14 17:25:53.792702043 +0900
@@ -231,7 +231,7 @@
 LIBOBJS =
 LIBPNG = -lpng -lz -lm
 LIBPNG_CONFIG = /usr/local/bin/libpng-config
-LIBS = -lc_r
+LIBS = -lc_r -pthread
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LN_S = ln -s
 LTLIBOBJS =

これでおしまい。

% sudo make install
% rehash
% directfb-config --version
1.0.1

軽く自作プログラムを動かしてみると、portsから入れた0.9.16より、体感できるほど速くなってる。ほほー。