====== Flexをソースからのインストール ======
===== 依存ライブラリ =====
* [[tools:libtool:インストール:インストール|GNU Libtool]]
* [[tools:m4:インストール:インストール|m4]]
* [[tools:autoconf:インストール:インストール|autoconf]]
* [[tools:gettext:インストール:インストール|gettext]]
* [[tools:automake:インストール:インストール|automake]]
* [[tools:bison:インストール:インストール|Bison]](任意)
* [[tools:help2man:インストール:インストール|GNU help2man]](任意)
* [[tools:texinfo:インストール:6.7|Texinfo]](任意)
* [[tools:gnu_indent:インストール:インストール|GNU Indent]](任意)
===== インストール手順 =====
$ wget https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
$ tar xvf flex-2.6.4.tar.gz
$ cd flex-2.6.4/
$ LIBTOOLIZE=/opt/libtool/2.4.6/bin/libtoolize \
PATH=/opt/automake/1.16.3/bin:/opt/gettext/0.21/bin:/opt/autoconf/2.69/bin:/opt/m4/1.4.18/bin:${PATH} \
./autogen.sh
$ ./configure \
PATH=/opt/indent/2.2.12/bin:/opt/texinfo/6.7/bin:/opt/help2man/1.47.16/bin:/opt/bison/3.7.4/bin:/opt/m4/1.4.18/bin:${PATH} \
--prefix=/opt/flex/2.6.4 \
CFLAGS='-g -O2 -D_GNU_SOURCE'
$ make
$ make install
===== 環境変数 =====
$ export PATH=/opt/flex/2.6.4/bin:${PATH}
$ export LD_LIBRARY_PATH=/opt/flex/2.6.4/lib:${LD_LIBRARY_PATH}
$ export C_INCLUDE_PATH=/opt/flex/2.6.4/include:${C_INCLUDE_PATH}
$ export CPLUS_INCLUDE_PATH=/opt/flex/2.6.4/include:${CPLUS_INCLUDE_PATH}
===== スクリプト =====
#!/bin/bash
#############################################################
inst_ver=2.6.4
inst_target=/opt/flex/${inst_ver}
arch_file="flex-"${inst_ver}".tar.gz"
target_web="https://github.com/westes/flex/releases/download/v2.6.4/"${arch_file}
working_dir=$(cd $(dirname $0); pwd)/flex-${inst_ver}
m4_path=/opt/m4/1.4.18/bin
libtool_path=/opt/libtool/2.4.6/bin/libtoolize
autoconf_path=/opt/autoconf/2.69/bin
gettext_path=/opt/gettext/0.21/bin
automake_path=/opt/automake/1.16.3/bin
bison_path=/opt/bison/3.7.4/bin
help2man_path=/opt/help2man/1.47.16/bin
texinfo_path=/opt/texinfo/6.7/bin
indent_path=/opt/indent/2.2.12/bin
#############################################################
if [ -d ${inst_target} ];
then
echo "${inst_target} is already exist"
exit 0
fi
if [ ! -d ${m4_path} ];
then
echo "m4 is not exist"
exit 1
fi
if [ ! -f ${libtool_path} ];
then
echo "libtool is not exist"
exit 1
fi
if [ ! -d ${autoconf_path} ];
then
echo "autoconf_path is not exist"
exit 1
fi
if [ ! -d ${gettext_path} ];
then
echo "gettext_path is not exist"
exit 1
fi
if [ ! -d ${automake_path} ];
then
echo "automake_path is not exist"
exit 1
fi
mkdir -p ${inst_target}
if [ $? -ne 0 ];
then
echo "You do not have write permission on "${inst_target}"."
echo "Scipt is aborted."
exit 1
fi
rm -rf ${arch_file} ${working_dir}
wget ${target_web}
if [ $? -ne 0 ];
then
echo "command is failed"
echo "wget ${target_web}"
exit 1
fi
mkdir ${working_dir}
tar xvf ${arch_file} -C ${working_dir} --strip-components 1
cd ${working_dir}
LIBTOOLIZE=${libtool_path} PATH=${automake_path}:${gettext_path}:${autoconf_path}:${m4_path:}${PATH} ./autogen.sh
./configure PATH=${indent_path}:${texinfo_path}:${help2man_path}:${bison_path}:${m4_path}:${PATH} --prefix=/opt/flex/2.6.4 CFLAGS='-g -O2 -D_GNU_SOURCE'
make
make install