[FreeBSD-users-jp 96301] Re: FreeFem++ のインストール問題

Kouichi Hirabayashi kh @ mogami.com
2018年 8月 24日 (金) 02:06:53 UTC


FreeBSD-11.2 で FreeFem++ を gcc+gfortran で compile した場合
のライブラリ不整合の根本的対策として gcc-free で compile する方法を
考えてみました。

現時点の FreeBSD としては、前回の gcc で compile した libGLU.so.a
を作って static link する方法より、この方針のほうが利点が大きいと思い
ます。

以下、ports のメカニズムを使わずに compile する方法を書きますが、
shells/bash, ftp/wget, lang/perl5X, graphics/freeglut,
devel/flang は前もって ports から install しておいてください。

freefem++-3.61-1.tar.gz を展開したディレクトリで下記の手順でコンパ
イルします。

 1) freefem++-3.61-1.tar.gz を展開し、下記のパッチをあてる
    
--- src/femlib/CheckPtr.cpp.orig	2018-03-28 16:02:20.000000000 +0900
+++ src/femlib/CheckPtr.cpp	2018-08-23 11:24:23.000000000 +0900
@@ -27,6 +27,8 @@
  */
 #if __APPLE__
 #include <malloc/malloc.h>
+#elif __FreeBSD__
+#include <stdlib.h>
 #else
 #include <malloc.h>
 #endif
--- src/medit/Makefile.am.orig	2018-06-20 21:46:49.000000000 +0900
+++ src/medit/Makefile.am	2018-08-23 11:27:40.000000000 +0900
@@ -25,7 +25,7 @@
 
 ffmedit_DEPENDENCIES=picking.$(OBJEXT)
 picking.$(OBJEXT):picking.c
-	${CC} -c $< $(CNOFLAGS) -o $@ 
+	${CC} -c $< $(CNOFLAGS) $(CFLAGS) -o $@ 
 
 #pinking.no-optffmedit$(EXEEXT):picking.c
 #	rm picking.$(OBJEXT)
--- src/medit/Makefile.in.orig	2018-07-12 18:59:19.000000000 +0900
+++ src/medit/Makefile.in	2018-08-23 19:31:55.000000000 +0900
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -845,7 +845,7 @@
 compil.date: $(ffmedit_SOURCES)
 	echo "#define COMPIL " '"' `date` '(with ff++ $(VERSION))''"' > compil.date
 picking.$(OBJEXT):picking.c
-	${CC} -c $< $(CNOFLAGS) -o $@ 
+	${CC} -c $< $(CNOFLAGS) $(CFLAGS) -o $@ 
 
 #pinking.no-optffmedit$(EXEEXT):picking.c
 #	rm picking.$(OBJEXT)
--- download/blas/Makefile.am.orig	2018-03-28 16:02:20.000000000 +0900
+++ download/blas/Makefile.am	2018-08-23 18:05:26.000000000 +0900
@@ -109,7 +109,7 @@
 
 BLAS/fait:$(BLAS_TGZ)
 	mkdir -p ../include ../lib
-	pxerbla=`tar tf $(BLAS_TGZ) | grep xerbla.f`; \
+	pxerbla=`tar tf $(BLAS_TGZ) | grep _xerbla.f`; \
 	dirblas=`dirname $$pxerbla` ;\
 	case $$dirblas in \
 	BLAS) tar xvzf $(BLAS_TGZ) ;; \
--- download/blas/Makefile.in.orig	2018-07-12 18:59:19.000000000 +0900
+++ download/blas/Makefile.in	2018-08-23 19:31:54.000000000 +0900
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -4282,7 +4282,7 @@
 
 BLAS/fait:$(BLAS_TGZ)
 	mkdir -p ../include ../lib
-	pxerbla=`tar tf $(BLAS_TGZ) | grep xerbla.f`; \
+	pxerbla=`tar tf $(BLAS_TGZ) | grep _xerbla.f`; \
 	dirblas=`dirname $$pxerbla` ;\
 	case $$dirblas in \
 	BLAS) tar xvzf $(BLAS_TGZ) ;; \
--- download/fftw/Makefile.am.orig	2018-03-28 16:02:20.000000000 +0900
+++ download/fftw/Makefile.am	2018-08-24 07:39:31.000000000 +0900
@@ -17,7 +17,7 @@
 	$(MAKE) WHERE
 
 $(SRCDIR)/FAIT:$(SRCDIR)/FAIT-1
-	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP='gcc -E' CXXFLAGS="$(CXXFLAGS)"
+	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP="$(CXXCPP)" CXXFLAGS="$(CXXFLAGS)"
 	cd $(SRCDIR) && make
 	cd $(SRCDIR) && make install
 	touch $(SRCDIR)/FAIT
--- download/fftw/Makefile.in.orig	2018-08-23 19:31:54.000000000 +0900
+++ download/fftw/Makefile.in	2018-08-24 07:41:13.000000000 +0900
@@ -607,7 +607,7 @@
 	$(MAKE) WHERE
 
 $(SRCDIR)/FAIT:$(SRCDIR)/FAIT-1
-	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP='gcc -E' CXXFLAGS="$(CXXFLAGS)"
+	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP="$(CXXCPP)" CXXFLAGS="$(CXXFLAGS)"
 	cd $(SRCDIR) && make
 	cd $(SRCDIR) && make install
 	touch $(SRCDIR)/FAIT
--- download/fftw/Makefile.am.orig	2018-03-28 16:02:20.000000000 +0900
+++ download/fftw/Makefile.am	2018-08-24 07:39:31.000000000 +0900
@@ -17,7 +17,7 @@
 	$(MAKE) WHERE
 
 $(SRCDIR)/FAIT:$(SRCDIR)/FAIT-1
-	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP='gcc -E' CXXFLAGS="$(CXXFLAGS)"
+	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP="$(CXXCPP)" CXXFLAGS="$(CXXFLAGS)"
 	cd $(SRCDIR) && make
 	cd $(SRCDIR) && make install
 	touch $(SRCDIR)/FAIT
--- download/fftw/Makefile.in.orig	2018-08-23 19:31:54.000000000 +0900
+++ download/fftw/Makefile.in	2018-08-24 07:41:13.000000000 +0900
@@ -607,7 +607,7 @@
 	$(MAKE) WHERE
 
 $(SRCDIR)/FAIT:$(SRCDIR)/FAIT-1
-	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP='gcc -E' CXXFLAGS="$(CXXFLAGS)"
+	cd $(SRCDIR) && ./configure --disable-dependency-tracking  --disable-fortran  --prefix=`pwd`/../..  CXX="$(CXX)" CC="$(CC)"  CFLAGS="$(CFLAGS)" CPP="$(CXXCPP)" CXXFLAGS="$(CXXFLAGS)"
 	cd $(SRCDIR) && make
 	cd $(SRCDIR) && make install
 	touch $(SRCDIR)/FAIT
--
    patch をあてた後、下記を実行しておきます。

    $ autoreconf -i

  Makefile の patch は今まで表面化しなかった bug を考えて良いと思います。

 2) 環境を Linux に合わせる

    # ln -s /usr/local/bin/wget /usr/bin/wget
    # ln -s /usr/local/bin/perl /usr/bin/perl
    # ln -s /usr/local/bin/bash /bin/bash
    # mv /usr/bin/make /usr/bin/make.bsd
    # ln -s /usr/local/bin/gmake /usr/bin/make

   この部分は wget, perl, bash を絶対 PATH で指定している
   build/download, build/cleancrlf, build/ff-md5,
   build/links2files, build/orgindex, download/getall,
   examples++-load/ff-pkg-download.in などを FreeBSD 用に書き換えて
   も良いと思いますが、最終的に ports メカニズムで解決でしょうか。gmake を
   使う部分は compile 時点で gmake への link を ~/bin にでも置いて、
   PATH 変数で一時的に /usr/bin より先に見付けるようにしても良いと思います。

 3) freefem++-3.61-1 を compile する

   $ ./configure --enable-download -without-mpi CC=clang CXX=clang++ FC=flang \
	CXXCPP="flang -E" \
	F77=flang -with-glut="-lglut -lGLU -lGL" \
	CFLAGS="-I/usr/local/include -Wno-comment" \
	CXXFLAGS="-I/usr/local/include -DHAVE_DRAND48"
   $ make		# やりなおす場合は make clean 実行後

 4) install する

   # cd freefem++-3.61-1
   # make install
   # make clean		# 動作確認後

 5) 環境を BSD に戻す

   # rm /usr/bin/wget /usr/bin/perl /bin/bash
   # rm /usr/bin/make
   # ln -s /usr/local/bin/make.bsd /usr/bin/make


注意 - flang が存在しない古い FreeBSD では使えませんが、fc2 を
使うとか Intel の compiler で対応できるかもしれません。

平林 浩一


freebsd-users-jp メーリングリストの案内