From 55d3516e79de3866d49644f04bab18f945181fca Mon Sep 17 00:00:00 2001 From: pgen Date: Mon, 19 Dec 2016 00:25:43 +0100 Subject: Add code to detect the host system at compile time Compilation should now be successful on BSD system derivatives --- Makefile.in | 13 +++++++- configure | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 20 ++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 35f3ecf..f71b999 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,12 +76,15 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ bin_PROGRAMS = smenu$(EXEEXT) subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ $(srcdir)/config.h.in $(srcdir)/smenu.spec.in depcomp \ - $(dist_man_MANS) ChangeLog TODO install-sh missing + $(dist_man_MANS) ChangeLog TODO config.guess config.sub \ + install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -258,14 +261,22 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ +build = @build@ build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +host = @host@ host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ diff --git a/configure b/configure index 1901b81..5030518 100755 --- a/configure +++ b/configure @@ -625,6 +625,14 @@ ac_includes_default="\ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build LIBOBJS LN_S EGREP @@ -1328,6 +1336,10 @@ Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi @@ -4902,6 +4914,96 @@ fi done +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +# OS-specific tests +case "${host_os}" in +*freebsd*|*dragonfly*) + CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" + ;; + +*darwin*) + CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" + ;; + +*netbsd*) + CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" + ;; + +*openbsd*|*bitrig*) + CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" + ;; +esac + ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files smenu.spec" diff --git a/configure.ac b/configure.ac index 4ef5b33..61d1350 100644 --- a/configure.ac +++ b/configure.ac @@ -33,5 +33,25 @@ AC_TYPE_SIZE_T AC_FUNC_MALLOC AC_CHECK_FUNCS([mblen memset nl_langinfo pathconf regcomp setlocale strchr strdup strrchr]) +AC_CANONICAL_HOST +# OS-specific tests +case "${host_os}" in +*freebsd*|*dragonfly*) + CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" + ;; + +*darwin*) + CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" + ;; + +*netbsd*) + CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" + ;; + +*openbsd*|*bitrig*) + CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" + ;; +esac + AC_CONFIG_FILES([Makefile]) AC_OUTPUT([smenu.spec]) -- cgit v1.2.3