Mac OS X LionでGNU Octave最新版を使いたい


http://nozawashinichi.sakura.ne.jp/fs/2009/07/octavemac-x11-or-aquaterm.html で解説されているビルド済みパッケージを使ってたんだけど、X11,AquaTerm,gnuplotに依存してるのがイマイチ

Octaveの最新版はOpenGLで（X11,AquaTerm,gnuplotを使わずに）描画できるらしいので是非使いたい

`brew install octave`

で行けばいいんだけど色々はまったので断片的ではあるがメモ

## 参考URL
- [Install Octave With Home Brew Under Mac OS X](https://www.nesono.com/node/356)

- [Octaveのインストール - Set the control for the heart of the sun](http://d.hatena.ne.jp/Askeladd/20111127)
GraphicsMagickまわりではまった時に

## 必要な依存パッケージを導入。

### libpng
libpng-1.2系 (libpng-1.2.50) をインストールした

### fltk
### GraphicsMagick
失敗した失敗した失敗した
Homebrewディレクトリでビルド
ar, ranlibがbrew版だとコケるとか

### qrupdate
### freetype, fontconfig
OSXに入ってるのを利用できる。CFLAGS等でパスを設定。

### CXSparse, SuiteSparse_config
- [CXSparse](http://www.cise.ufl.edu/research/sparse/CXSparse/)
- [SuiteSparse_config](http://www.cise.ufl.edu/research/sparse/SuiteSparse_config/) も必要

## octaveのビルド
Homebrewディレクトリで

### (1) patch -p1 < configure.diff

```configure.diff
--- octave-3.6.3/configure      2012-09-05 02:19:13.000000000 +0900
+++ octave-3.6.3-naoyat/configure       2012-11-17 17:48:11.000000000 +0900
@@ -36384,9 +36384,9 @@
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${LD-ld} accepts -framework OpenGL" >&5
 $as_echo_n "checking whether ${LD-ld} accepts -framework OpenGL... " >&6; }
-  if ${octave_cv_framework_OpenGL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
+#  if ${octave_cv_framework_OpenGL+:} false; then :
+#  $as_echo_n "(cached) " >&6
+#else
 
     XLDFLAGS="$LDFLAGS"
     LDFLAGS="$LDFLAGS -framework OpenGL"
@@ -36417,11 +36417,11 @@
   return 0;
 }
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
+#if ac_fn_cxx_try_link "$LINENO"; then :
   eval "octave_cv_framework_OpenGL=yes"
-else
-  eval "octave_cv_framework_OpenGL=no"
-fi
+#else
+#  eval "octave_cv_framework_OpenGL=no"
+#fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
     ac_ext=c
@@ -36432,7 +36432,7 @@
 
     LDFLAGS="$XLDFLAGS"
 
-fi
+#fi
 
   if test "$octave_cv_framework_OpenGL" = "yes"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -59573,20 +59573,20 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_set_keyboard_input_timeout" >&5
 $as_echo "$ac_cv_lib_readline_rl_set_keyboard_input_timeout" >&6; }
-if test "x$ac_cv_lib_readline_rl_set_keyboard_input_timeout" = xyes; then :
+#if test "x$ac_cv_lib_readline_rl_set_keyboard_input_timeout" = xyes; then :
 
       READLINE_LIBS="-lreadline"
 
 $as_echo "#define USE_READLINE 1" >>confdefs.h
 
 
-else
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: I need GNU Readline 4.2 or later" >&5
-$as_echo "$as_me: WARNING: I need GNU Readline 4.2 or later" >&2;}
-      as_fn_error $? "this is fatal unless you specify --disable-readline" "$LINENO" 5
-
-fi
+#else
+#
+#      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: I need GNU Readline 4.2 or later" >&5
+#$as_echo "$as_me: WARNING: I need GNU Readline 4.2 or later" >&2;}
+#      as_fn_error $? "this is fatal unless you specify --disable-readline" "$LINENO" 5
+#
+#fi
 
     LIBS="$save_LIBS"
   fi
```

### (2) ./configure

```do_configure.sh
FONTCONFIG_CFLAGS=-I/usr/local/opt/fontconfig/include FONTCONFIG_LIBS=-lfontconfig  HAVE_FRAMEWORK_OPENGL=1 CC=/usr/bin/gcc CXX=/usr/bin/g++ ./configure "--prefix=/usr/local/Cellar/octave/3.6.3" "--with-blas=-Wl,-framework -Wl,Accelerate" "--with-umfpack=-lumfpack -lsuitesparseconfig" "--without-framework-carbon" "--with-cxsparse-includedir=/usr/local/include" "--with-cxsparse-libdir=/usr/local/lib" "--with-ft-prefix=/usr/local/opt/freetype"
```

### (3) patch -p1 < Makefile.diff

TeX 環境のあるマシンならこれは不要。

```Makefile.diff
--- octave-3.6.3/Makefile	2012-11-17 22:31:59.000000000 +0900
+++ octave-3.6.3-naoyat/Makefile	2012-11-17 21:54:30.000000000 +0900
@@ -242,7 +242,8 @@
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+# DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
 am__remove_distdir = \
@@ -1659,7 +1660,8 @@
 	m4/lt~obsolete.m4
 
 # Subdirectories in which to run `make all'.
-SUBDIRS = libgnu libcruft liboctave src scripts doc examples test
+#SUBDIRS = libgnu libcruft liboctave src scripts doc examples test
+SUBDIRS = libgnu libcruft liboctave src scripts examples test
 BUILT_SOURCES = run-octave
 noinst_SCRIPTS = run-octave
 INFO_FILES = \
```

## 必要な設定

```/usr/local/Cellar/octave/3.6.3/share/octave/site/m/startup/octaverc
## System-wide startup file for Octave.
##
## This file should contain any commands that should be executed each
## time Octave starts for every user at this site.

graphics_toolkit ("fltk")
```

これでOpenGL経由の描画ができる！