Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
     5         kx dnl #
     5         kx dnl # /usr/share/aclocal/dialog.m4
     5         kx dnl #
     5         kx dnl # Configure paths for dialog
     5         kx dnl # Andrew V.Kosteltsev
     5         kx 
     5         kx dnl ============================================================
     5         kx dnl
     5         kx dnl  Synopsis:
     5         kx dnl     AC_CHECK_DIALOG([MIN-VERSION [,                  # minimum dialog version, e.g. 1.3-20190211
     5         kx dnl                           DEFAULT-WITH-DIALOG [,     # default value for --with-dialog option
     5         kx dnl                           DEFAULT-WITH-DIALOG-TEST [,# default value for --with-dialog-test option
     5         kx dnl                           EXTEND-VARS [,                  # whether CFLAGS/LDFLAGS/etc are extended
     5         kx dnl                           ACTION-IF-FOUND [,              # action to perform if dialog was found
     5         kx dnl                           ACTION-IF-NOT-FOUND             # action to perform if dialog was not found
     5         kx dnl                          ]]]]]])
     5         kx dnl  Examples:
     5         kx dnl     AC_CHECK_DIALOG(1.3-20210621)
     5         kx dnl     AC_CHECK_DIALOG(1.3-20210621,,,no,CFLAGS="$CFLAGS -DHAVE_DIALOG $DIALOG_CFLAGS")
     5         kx dnl     AC_CHECK_DIALOG(1.3-20210621,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_DIALOG")
     5         kx dnl
     5         kx dnl
     5         kx dnl  If you have to change prefix returned by dialog-config script or change
     5         kx dnl  location of dialog-config, you may set environment variable DIALOG_CONFIG,
     5         kx dnl  for example:
     5         kx dnl
     5         kx dnl  # export DIALOG_CONFIG="dialog-config --prefix=/usr/local"
     5         kx dnl  # export DIALOG_CONFIG="/usr/bin/dialog-config --prefix=/usr/local"
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl  auxilliary macros
     5         kx dnl ============================================================
     5         kx AC_DEFUN([_AC_DIALOG_ERROR], [dnl
     5         kx AC_MSG_RESULT([*FAILED*])
     5         kx cat <<EOT | sed -e 's/^[[ 	]]*/ | /' -e 's/>>/  /' 1>&2
     5         kx $1
     5         kx EOT
     5         kx exit 1
     5         kx ])
     5         kx 
     5         kx AC_DEFUN([_AC_DIALOG_VERBOSE], [dnl
     5         kx if test ".$verbose" = .yes; then
     5         kx     AC_MSG_RESULT([  $1])
     5         kx fi
     5         kx ])
     5         kx 
     5         kx dnl ============================================================
     5         kx dnl  the user macro
     5         kx dnl ============================================================
     5         kx AC_DEFUN([AC_CHECK_DIALOG], [dnl
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl  prerequisites
     5         kx dnl ============================================================
     5         kx AC_REQUIRE([AC_PROG_CC])dnl
     5         kx AC_REQUIRE([AC_PROG_CPP])dnl
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl  set DIALOG_CONFIG variable
     5         kx dnl ============================================================
     5         kx if test -z "$DIALOG_CONFIG"; then
     5         kx   DIALOG_CONFIG='dialog-config'
     5         kx fi
     5         kx dnl
     5         kx DIALOG_CFLAGS=''
     5         kx DIALOG_LDFLAGS=''
     5         kx DIALOG_LIBS=''
     5         kx AC_SUBST(DIALOG_CFLAGS)
     5         kx AC_SUBST(DIALOG_LDFLAGS)
     5         kx AC_SUBST(DIALOG_LIBS)
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl  command line options
     5         kx dnl ============================================================
     5         kx _AC_DIALOG_VERBOSE([])
     5         kx AC_ARG_WITH(dialog,dnl
     5         kx [  --with-dialog[=ARG]       Build with dialog Library  (default=]ifelse([$2],,yes,$2)[)],dnl
     5         kx ,dnl
     5         kx with_dialog="ifelse([$2],,yes,$2)"
     5         kx )dnl
     5         kx AC_ARG_WITH(dialog-test,dnl
     5         kx [  --with-dialog-test      Perform dialog Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl
     5         kx ,dnl
     5         kx with_dialog_test="ifelse([$3],,yes,$3)"
     5         kx )dnl
     5         kx _AC_DIALOG_VERBOSE([+ Command Line Options:])
     5         kx _AC_DIALOG_VERBOSE([    o --with-dialog=$with_dialog])
     5         kx _AC_DIALOG_VERBOSE([    o --with-dialog-test=$with_dialog_test])
     5         kx dnl
     5         kx dnl ============================================================
     5         kx dnl  configuration
     5         kx dnl ============================================================
     5         kx if test ".$with_dialog" != .no; then
     5         kx     dialog_subdir=no
     5         kx     dialog_subdir_opts=''
     5         kx     case "$with_dialog" in
     5         kx         subdir:* )
     5         kx             dialog_subdir=yes
     5         kx             changequote(, )dnl
     5         kx             dialog_subdir_opts=`echo $with_dialog | sed -e 's/^subdir:[^ 	]*[ 	]*//'`
     5         kx             with_dialog=`echo $with_dialog | sed -e 's/^subdir:\([^ 	]*\).*$/\1/'`
     5         kx             changequote([, ])dnl
     5         kx             ;;
     5         kx     esac
     5         kx     dialog_version=""
     5         kx     dialog_location=""
     5         kx     dialog_type=""
     5         kx     dialog_cflags=""
     5         kx     dialog_ldflags=""
     5         kx     dialog_libs=""
     5         kx     if test ".$with_dialog" = .yes; then
     5         kx         #   via config script in $PATH
     5         kx         changequote(, )dnl
     5         kx         dialog_version=`($DIALOG_CONFIG --version) 2>/dev/null |\
     5         kx                       sed -e 's/^.*\([0-9]\.[0-9]*[-][0-9]*\).*$/\1/'`
     5         kx         changequote([, ])dnl
     5         kx         if test ".$dialog_version" != .; then
     5         kx             dialog_location=`$DIALOG_CONFIG --prefix`
     5         kx             dialog_type='installed'
     5         kx             dialog_cflags=`$DIALOG_CONFIG --cflags`
     5         kx             dialog_ldflags=`$DIALOG_CONFIG --ldflags`
     5         kx             dialog_libs=`$DIALOG_CONFIG --libs`
     5         kx         fi
     5         kx     elif test -d "$with_dialog"; then
     5         kx         with_dialog=`echo $with_dialog | sed -e 's;/*$;;'`
     5         kx         dialog_found=no
     5         kx         #   via config script under a specified directory
     5         kx         #   (a standard installation, but not a source tree)
     5         kx         if test ".$dialog_found" = .no; then
     5         kx             for _dir in $with_dialog/bin $with_dialog; do
     5         kx                 if test -f "$_dir/dialog-config"; then
     5         kx                     test -f "$_dir/dialog-config.in" && continue # dialog-config in source tree!
     5         kx                     changequote(, )dnl
     5         kx                     dialog_version=`($_dir/dialog-config --version) 2>/dev/null |\
     5         kx                                   sed -e 's/^.*\([0-9]\.[0-9]*[.][0-9]*\).*$/\1/'`
     5         kx                     changequote([, ])dnl
     5         kx                     if test ".$dialog_version" != .; then
     5         kx                         dialog_location=`$_dir/dialog-config --prefix`
     5         kx                         dialog_type="installed"
     5         kx                         dialog_cflags=`$_dir/dialog-config --cflags`
     5         kx                         dialog_ldflags=`$_dir/dialog-config --ldflags`
     5         kx                         dialog_libs=`$_dir/dialog-config --libs`
     5         kx                         dialog_found=yes
     5         kx                         break
     5         kx                     fi
     5         kx                 fi
     5         kx             done
     5         kx         fi
     5         kx     fi
     5         kx     _AC_DIALOG_VERBOSE([+ Determined Location:])
     5         kx     _AC_DIALOG_VERBOSE([    o path: $dialog_location])
     5         kx     _AC_DIALOG_VERBOSE([    o type: $dialog_type])
     5         kx     if test ".$dialog_version" = .; then
     5         kx         if test ".$with_dialog" != .yes; then
     5         kx              _AC_DIALOG_ERROR([dnl
     5         kx              Unable to locate dialog under $with_dialog.
     5         kx              Please specify the correct path to either a dialog installation tree
     5         kx              (use --with-dialog=DIR if you used --prefix=DIR for installing dialog in
     5         kx              the past).])
     5         kx         else
     5         kx              _AC_DIALOG_ERROR([dnl
     5         kx              Unable to locate dialog in any system-wide location (see \$PATH).
     5         kx              Please specify the correct path to either a dialog installation tree
     5         kx              (use --with-dialog=DIR if you used --prefix=DIR for installing dialog in
     5         kx              the past, or set the DIALOG_CONFIG environment variable to the full path
     5         kx              to dialog-config).])
     5         kx         fi
     5         kx     fi
     5         kx     dnl ========================================================
     5         kx     dnl  Check whether the found version is sufficiently new
     5         kx     dnl ========================================================
     5         kx     _req_version="ifelse([$1],,1.0.0,$1)"
     5         kx     for _var in dialog_version _req_version; do
     5         kx         eval "_val=\"\$${_var}\""
     5         kx         _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[.]]\)\([[0-9]]*\)/\1/'`
     5         kx         _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[.]]\)\([[0-9]]*\)/\2/'`
     5         kx         _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[.]]\)\([[0-9]]*\)/\4/'`
     5         kx         _hex=`echo dummy | awk '{ printf("%d%02d%02d", major, minor, micro); }' \
     5         kx               "major=$_major" "minor=$_minor" "micro=$_micro"`
     5         kx         eval "${_var}_hex=\"\$_hex\""
     5         kx     done
     5         kx     _AC_DIALOG_VERBOSE([+ Determined Versions:])
     5         kx     _AC_DIALOG_VERBOSE([    o existing: $dialog_version -> 0x$dialog_version_hex])
     5         kx     _AC_DIALOG_VERBOSE([    o required: $_req_version -> 0x$_req_version_hex])
     5         kx     _ok=0
     5         kx     if test ".$dialog_version_hex" != .; then
     5         kx         if test ".$_req_version_hex" != .; then
     5         kx             if test $dialog_version_hex -ge $_req_version_hex; then
     5         kx                 _ok=1
     5         kx             fi
     5         kx         fi
     5         kx     fi
     5         kx     if test ".$_ok" = .0; then
     5         kx         _AC_DIALOG_ERROR([dnl
     5         kx         Found dialog version $dialog_version, but required at least version $_req_version.
     5         kx         Upgrade dialog under $dialog_location to $_req_version or higher first, please.])
     5         kx     fi
     5         kx     dnl ========================================================
     5         kx     dnl  Perform dialog Sanity Compile Check
     5         kx     dnl ========================================================
     5         kx     if test ".$with_dialog_test" = .yes; then
     5         kx         _ac_save_CFLAGS="$CFLAGS"
     5         kx         _ac_save_LDFLAGS="$LDFLAGS"
     5         kx         _ac_save_LIBS="$LIBS"
     5         kx         CFLAGS="$CFLAGS $dialog_cflags"
     5         kx         LDFLAGS="$LDFLAGS $dialog_ldflags"
     5         kx         LIBS="$LIBS $dialog_libs"
     5         kx         _AC_DIALOG_VERBOSE([+ Test Build Environment:])
     5         kx         _AC_DIALOG_VERBOSE([    o CFLAGS="$CFLAGS"])
     5         kx         _AC_DIALOG_VERBOSE([    o LDFLAGS="$LDFLAGS"])
     5         kx         _AC_DIALOG_VERBOSE([    o LIBS="$LIBS"])
     5         kx         cross_compile=no
     5         kx         define([_code1], [
     5         kx #include <stdlib.h>
     5         kx #include <stdio.h>
     5         kx #include <strings.h>  /* index(3)    */
     5         kx 
     5         kx #include <dialog.h>
     5         kx #include <dlg_colors.h>
     5         kx #include <dlg_keys.h>
     5         kx         ])
     5         kx         define([_code2], [
     5         kx   int status = 0;
     5         kx 
     5         kx   bzero( (void *)&dialog_vars, sizeof(DIALOG_VARS) );
     5         kx 
     5         kx   init_dialog(stdin, stdout);
     5         kx 
     5         kx   dialog_vars.colors = 1;
     5         kx   dialog_vars.backtitle = "Test dialog Library";
     5         kx   dialog_vars.dlg_clear_screen = 1;
     5         kx   dialog_vars.sleep_secs = 1;
     5         kx 
     5         kx 
     5         kx   dlg_put_backtitle();
     5         kx 
     5         kx   /*************************************************
     5         kx     Ruler: 68 characters + 2 spaces left and right:
     5         kx 
     5         kx                            | ----handy-ruler----------------------------------------------------- | */
     5         kx   status = dialog_msgbox( " Dialog ==>libdialog<== [required] ",
     5         kx                           "\nPackage is installed and corect.\n",
     5         kx                           5, 72, 0 );
     5         kx 
     5         kx   if( dialog_vars.sleep_secs )
     5         kx     (void)napms(dialog_vars.sleep_secs * 1000);
     5         kx 
     5         kx   if( dialog_vars.dlg_clear_screen )
     5         kx   {
     5         kx     dlg_clear();
     5         kx     (void)refresh();
     5         kx   }
     5         kx   end_dialog();
     5         kx         ])
     5         kx         _AC_DIALOG_VERBOSE([+ Performing Sanity Checks:])
     5         kx         _AC_DIALOG_VERBOSE([    o pre-processor test])
     5         kx         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([_code1], [_code2])], [_ok=yes], [_ok=no])
     5         kx         if test ".$_ok" != .yes; then
     5         kx             _AC_DIALOG_ERROR([dnl
     5         kx             Found dialog $dialog_version under $dialog_location, but
     5         kx             was unable to perform a sanity pre-processor check. This means
     5         kx             the dialog header dialog.h was not found.
     5         kx             We used the following build environment:
     5         kx             >> CPP="$CPP"
     5         kx             See config.log for possibly more details.])
     5         kx         fi
     5         kx         _AC_DIALOG_VERBOSE([    o link check])
     5         kx         AC_LINK_IFELSE([AC_LANG_PROGRAM([_code1], [_code2])], [_ok=yes], [_ok=no])
     5         kx         if test ".$_ok" != .yes; then
     5         kx             _AC_DIALOG_ERROR([dnl
     5         kx             Found dialog $dialog_version under $dialog_location, but
     5         kx             was unable to perform a sanity linker check. This means
     5         kx             the dialog library libdialog.a was not found.
     5         kx             We used the following build environment:
     5         kx             >> CC="$CC"
     5         kx             >> CFLAGS="$CFLAGS"
     5         kx             >> LDFLAGS="$LDFLAGS"
     5         kx             >> LIBS="$LIBS"
     5         kx             See config.log for possibly more details.])
     5         kx         fi
     5         kx         _extendvars="ifelse([$4],,yes,$4)"
     5         kx         if test ".$_extendvars" != .yes; then
     5         kx             CFLAGS="$_ac_save_CFLAGS"
     5         kx             LDFLAGS="$_ac_save_LDFLAGS"
     5         kx             LIBS="$_ac_save_LIBS"
     5         kx         fi
     5         kx     else
     5         kx         _extendvars="ifelse([$4],,yes,$4)"
     5         kx         if test ".$_extendvars" = .yes; then
     5         kx             if test ".$dialog_subdir" = .yes; then
     5         kx                 CFLAGS="$CFLAGS $dialog_cflags"
     5         kx                 LDFLAGS="$LDFLAGS $dialog_ldflags"
     5         kx                 LIBS="$LIBS $dialog_libs"
     5         kx             fi
     5         kx         fi
     5         kx     fi
     5         kx     DIALOG_CFLAGS="$dialog_cflags"
     5         kx     DIALOG_LDFLAGS="$dialog_ldflags"
     5         kx     DIALOG_LIBS="$dialog_libs"
     5         kx     AC_SUBST(DIALOG_CFLAGS)
     5         kx     AC_SUBST(DIALOG_LDFLAGS)
     5         kx     AC_SUBST(DIALOG_LIBS)
     5         kx 
     5         kx     AC_SUBST(HAVE_DIALOG, [1])
     5         kx 
     5         kx     AC_CHECK_HEADERS(dialog.h dlg_colors.h dlg_keys.h)
     5         kx 
     5         kx     _AC_DIALOG_VERBOSE([+ Final Results:])
     5         kx     _AC_DIALOG_VERBOSE([    o DIALOG_CFLAGS="$DIALOG_CFLAGS"])
     5         kx     _AC_DIALOG_VERBOSE([    o DIALOG_LDFLAGS="$DIALOG_LDFLAGS"])
     5         kx     _AC_DIALOG_VERBOSE([    o DIALOG_LIBS="$DIALOG_LIBS"])
     5         kx fi
     5         kx if test ".$with_dialog" != .no; then
     5         kx     AC_MSG_CHECKING(for libdialog)
     5         kx     AC_MSG_RESULT([version $dialog_version, $dialog_type under $dialog_location])
     5         kx     ifelse([$5], , :, [$5])
     5         kx else
     5         kx     AC_MSG_CHECKING(for libdialog)
     5         kx     AC_MSG_RESULT([no])
     5         kx     ifelse([$6], , :, [$6])
     5         kx fi
     5         kx ])