--- nono/configure.ac 2026/04/29 17:04:43 1.1.1.5 +++ nono/configure.ac 2026/04/29 17:04:53 1.1.1.8 @@ -7,6 +7,7 @@ AC_PREREQ([2.69]) AC_INIT([nono], [0.0], []) AC_CONFIG_SRCDIR(wx/wxapp.cpp) +AC_CONFIG_AUX_DIR([scripts]) # Checks for programs. AC_PROG_CXX @@ -14,6 +15,10 @@ AC_PROG_CC AC_PROG_INSTALL AC_C_BIGENDIAN +# OS +AC_CANONICAL_HOST +AC_SUBST([host_cpu]) + # コンパイラをチェック。今のところ clang/gcc のみ。 # (autoconf がやってる gcc かどうかのチェックは clang を検出できず使えない) AC_MSG_CHECKING(for compiler) @@ -29,12 +34,6 @@ else fi AC_SUBST([COMPILER]) -# アーキテクチャのチェック。 -AC_MSG_CHECKING(for architecture) -ARCH=`${CC} -v 2>&1 | awk '/Target:/ {print \$2}' | sed -e 's/-.*//'` -AC_MSG_RESULT([${ARCH}]) -AC_SUBST([ARCH]) - # C++ のバージョンをチェック CXX_STD=-std=c++14 AC_LANG_PUSH([C++]) @@ -61,7 +60,6 @@ AC_DEFUN([ADD_CC_WARN_IF],[ CFLAGS="${old_CFLAGS}" ]) ADD_CC_WARN_IF(-Wcast-qual) -ADD_CC_WARN_IF(-Wdisabled-macro-expansion) ADD_CC_WARN_IF(-Wextra-semi) ADD_CC_WARN_IF(-Wlogical-op) ADD_CC_WARN_IF(-Wmissing-prototypes) @@ -83,7 +81,6 @@ AC_DEFUN([ADD_CXX_WARN_IF],[ CXXFLAGS="${old_CXXFLAGS}" ]) ADD_CXX_WARN_IF(-Wcast-qual) -ADD_CXX_WARN_IF(-Wdisabled-macro-expansion) ADD_CXX_WARN_IF(-Wextra-semi) ADD_CXX_WARN_IF(-Winconsistent-missing-override) ADD_CXX_WARN_IF(-Winconsistent-missing-destructor-override) @@ -108,11 +105,14 @@ AC_CHECK_HEADERS([net/if_tap.h]) AC_CHECK_HEADERS([linux/if_tun.h]) # Linux で がなければここで停止したほうがいい -if test "$ac_cv_header_sys_event_h" != "yes" \ - -a "$ac_cv_header_kqueue_sys_event_h" != "yes"; then - AC_MSG_ERROR([*** kqueue is not found. - On Ubuntu, sudo apt install libkqueue-dev]) -fi +case "${host_os}" in + linux*) + if test "$ac_cv_header_kqueue_sys_event_h" != "yes"; then + AC_MSG_ERROR([*** kqueue is not found. +*** If you use Ubuntu, sudo apt install libkqueue-dev]) + fi + ;; +esac # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL @@ -373,25 +373,72 @@ AC_TRY_COMPILE( AC_DEFINE([HAVE_PTHREAD_SET_NAME_NP_th_name]), AC_MSG_RESULT([no])) -# Select host network driver. -AC_MSG_CHECKING(for suitable host network driver) -if test x"$ac_cv_header_net_if_tap_h" = xyes; then - netdriver=tap -elif test x"$ac_cv_header_linux_if_tun_h" = xyes; then - netdriver=tap -elif test x"$ac_cv_header_net_bpf_h" = xyes; then - netdriver=bpf +AC_MSG_CHECKING(for iconv const) +AC_TRY_COMPILE( + [ + #include + ], [ + const char **a; + iconv(0, a, 0, 0, 0); + ], + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_ICONV_CONST]), + AC_MSG_RESULT([no])) + +# +# Network +# +AC_MSG_CHECKING(for AF_PACKET) +AC_TRY_COMPILE( + [ + #include + ], [ + AF_PACKET; + ], + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_HOSTNET_AFPACKET]) + AC_SUBST([HOSTNET_AFPACKET], [yes]), + AC_MSG_RESULT([no])) + +AC_MSG_CHECKING(for tap(4)) +case "${host_os}" in + linux*) + if test x"$ac_cv_header_linux_if_tun_h" = xyes; then + netdriver_tap=yes + fi + ;; + openbsd*) + # OpenBSD has no but supports tap(4). + netdriver_tap=yes + ;; + *) + if test x"$ac_cv_header_net_if_tap_h" = xyes; then + netdriver_tap=yes + fi + ;; +esac +if test x"$netdriver_tap" = xyes; then + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_HOSTNET_TAP]) + AC_SUBST([HOSTNET_TAP], [yes]) +else + AC_MSG_RESULT([no]) +fi + +AC_MSG_CHECKING(for bpf(4)) +if test x"$ac_cv_header_net_bpf_h" = xyes; then + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_HOSTNET_BPF]) + AC_SUBST([HOSTNET_BPF], [yes]) else - netdriver=none + AC_MSG_RESULT([no]) fi -AC_MSG_RESULT([$netdriver]) -AC_SUBST([NETDRIVER], [$netdriver]) # libbsd on Linux AC_CHECK_LIB(c, getprogname, ,) AC_CHECK_LIB(bsd, getprogname, - AC_SUBST([LIBBSD_LIBS], [-lbsd]), - ) + LIBS="${LIBS} -lbsd" +) # なければ停止する AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [ @@ -405,24 +452,24 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( ])], # nothing to do on success , [AC_MSG_ERROR([*** getprogname is not found. - On Ubuntu, sudo apt install libbsd-dev]) +*** If you use Ubuntu, sudo apt install libbsd-dev]) ] ) # libedit (editline) if test x"$ac_cv_header_histedit_h" = xyes; then - AC_SUBST([LIBEDIT_LIBS], ["-ledit -ltermcap"]) + LIBS="${LIBS} -ledit -ltermcap" fi # libkqueue on Linux AC_CHECK_LIB(kqueue, kqueue, - AC_SUBST([LIBKQUEUE_LIBS], [-lkqueue]), - ) + LIBS="${LIBS} -lkqueue" +) AC_CHECK_LIB(z, gzclose, - AC_SUBST([LIBZ_LIBS], [-lz]), + LIBS="${LIBS} -lz", [AC_MSG_ERROR([*** zlib is not found. - On Ubuntu, sudo apt install zlib1g-dev])] +*** If use use Ubuntu, sudo apt install zlib1g-dev])] ) # wxWidgets @@ -437,7 +484,9 @@ for c in ${wxconfig_paths}; do fi done if test -z "$wxconfig"; then - AC_MSG_ERROR([*** wxWidgets-3.0 not found in ${wxconfig_paths}]) + AC_MSG_ERROR([*** wxWidgets-3.0 not found in ${wxconfig_paths} +*** If you use pkgsrc, install x11/wxGTK30. +*** If you use Ubuntu, sudo apt install libwxgtk3.0-gtk3-dev]) else AC_MSG_RESULT([$wxconfig]) @@ -448,15 +497,17 @@ else wxcppflags=`$wxconfig --cppflags` wxlibs=`$wxconfig --libs` - # XXX NetBSD の rpath。どうしたもんだかこれ - if test "`uname -s`" = "NetBSD"; then + case "${host_os}" in + netbsd*) + # rpath。どうしたもんだかこれ wxlibs=[`echo $wxlibs | sed -e 's/-L\([^ ]*\) /-L\1 -Wl,-R,\1 /'`] - fi + ;; - # XXX OSX の -framework AudioToolbox が指定されているとリンカがこけるorz - if test "`uname -s`" = "Darwin"; then + darwin*) + # XXX -framework AudioToolbox が指定されているとリンカがこけるorz wxlibs=[`echo $wxlibs | sed -e 's/-framework AudioToolbox//'`] - fi + ;; + esac AC_SUBST([WXWIDGETS_CPPFLAGS], [$wxcppflags]) AC_SUBST([WXWIDGETS_LIBS], [$wxlibs]) @@ -466,7 +517,8 @@ fi AC_CHECK_TOOL([MSGFMT], [msgfmt], [:]) if test $MSGFMT = [:]; then AC_MSG_ERROR([*** msgfmt not found. - On Ubuntu, sudo apt install gettext]) +*** If you use pkgsrc, install devel/gettext-tools. +*** If you use Ubuntu, sudo apt install gettext]) fi AC_CONFIG_FILES([Makefile.cfg