GNU M4のインストール

GNU M4をソースコードからインストールする。
GNU M4は汎用のマクロプロセッサーであり,GNU Autoconfに必須の依存関係である。
インストール手順
項目 | 説明 |
---|---|
配布元 | |
リポジトリー | m4.git – GNU M4 source repository |
手順 | HACKING – m4.git – GNU M4 source repository |
依存情報 | |
依存先 (必須) | Make (GNU Make) |
依存先 (任意) | |
依存元 |
Autoconf |
sh -eux <<-"EOT"
PKG=m4 VER=1.4.18 TAG=v$VER
LOCAL=~/.local J=$(grep -cs '^processor' /proc/cpuinfo || echo 2)
mkdir -p "$LOCAL/src"
cd "$LOCAL/src"
if command -v git >/dev/null; then
[ -e $PKG ] || git clone --depth 1 git://git.savannah.gnu.org/$PKG.git $PKG
cd $PKG
git fetch --depth 1 origin tag $TAG
git checkout -f $TAG
if [ -e .gitmodules ]; then
git submodule update --init --depth 1 --progress || (
cd $(git submodule status | awk '/^+/ {print $2; exit}')
git fetch --shallow-since 2016-12-31 && git checkout)
git submodule foreach git clean -dfX
fi
# [ -e configure.ac ] && autoreconf -is
./bootstrap
else
[ -e $PKG-$VER ] || wget https://ftp.gnu.org/gnu/$PKG/$PKG-$VER.tar.xz
tar -xf $PKG-$VER.*
cd $PKG-$VER
make -kj $J distclean clean || :
fi
./configure --prefix="$LOCAL/stow/$PKG-$VER"
make -j $J WERROR_CFLAGS=
make -j $J check
make -j $J install
cd "$LOCAL/stow"
echo $PKG-[0-9]* | xargs -n 1 stow --ignore=dir -D
stow --ignore=dir $PKG-$VER
EOT
日付 | バージョン | OS | 依存関係 |
---|---|---|---|
2019-03-21 | 1.4.18 | Ubuntu 18.04 | GNU Make 4.2.1, GCC 7.4.0, GNU M4 1.4.18 |
配布用ソースコード (tarファイル) からのインストールは問題ない。しかし,リポジトリーからのビルドは注意が必要なので解説する。
git submodule
./bootstrapの実行時に以下のエラーがでる。
bootstrap: running: git submodule update -- gnulib error: Server does not allow request for unadvertised object 52a5514ddf33782915338944596be28271285fe5 Fetched in submodule path 'gnulib', but it did not contain 52a5514ddf33782915338944596be28271285fe5. Direct fetching of that commit failed. bootstrap: running: gnulib/gnulib-tool --no-changelog --no-libtool --symlink --update gnulib/gnulib-tool: *** minimum supported autoconf version is 2.63. Try adding AC_PREREQ([2.63]) to your configure.ac. gnulib/gnulib-tool: *** Stop.
これは,bootstrap内で実行されるgit clone --depth 365
で必要なコミット (52a5514ddf33782915338944596be28271285fe5) の不足が原因だ。
これは2016-12-31のコミットだ。そこで,bootstrapの実行前に,以下のコマンドで2016-12-31までのコミットをダウンロードすることで対応した。
git submodule update --init --depth 1 --progress || (
cd $(git submodule status | awk '/^+/ {print $2; exit}')
git fetch --shallow-since 2016-12-31 && git checkout)
数が少ないと,make checkで以下のエラーが出るので注意する。
make[1]: Leaving directory '/home/senooken/.local/src/m4' + make -j 4 check GEN public-submodule-commit Stopping at 'gnulib'; script returned non-zero status. maint.mk: found non-public submodule commit make: *** [maint.mk:1393: public-submodule-commit] Error 1
make時のエラー
v1.4.18のmakeで以下のエラーが発生した。
In file included from freeze.c:24:0: freeze.c: In function 'reload_frozen_state': m4.h:147:27: error: this statement may fall through [-Werror=implicit-fallthrough=] #define M4ERROR(Arglist) (m4_error Arglist) ~^~~~~~~~~~~~~~~~~ freeze.c:302:11: note: in expansion of macro 'M4ERROR' M4ERROR ((EXIT_FAILURE, 0, "ill-formed frozen file"));
これは-Werrorにより警告がエラー扱いになっているために発生する。そこで,以下のようにmakeの引数で-Werrorを指定している変数WERROR_CFLAGS=
を上書きすることで対応する。
make -j $J WERROR_CFLAGS=