From 896bc2d17313f32a968efb09917cc3eb2b4e3ed8 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 6 Jan 2018 18:31:15 -0800 Subject: Split local helper macros into separate m4's ... which are then picked up via aclocal. Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index 225009c..d456d1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated files configure autom4te.cache +aclocal.m4 config.log config.status /Makefile diff --git a/bootstrap b/bootstrap index a71a2b0..25453de 100755 --- a/bootstrap +++ b/bootstrap @@ -738,7 +738,7 @@ gen_selection menu debug "Debug facilities" gen_selection menu comp_tools "Companion tools" gen_selection menu comp_libs "Companion libraries" -msg "*** Running autoconf" -autoconf -Wall --force +msg "*** Running autoreconf" +autoreconf -Wall --force msg "*** Done!" diff --git a/configure.ac b/configure.ac index 8ae98bf..97d7607 100644 --- a/configure.ac +++ b/configure.ac @@ -2,122 +2,17 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.67]) + +# FIXME Temporary hack until the next release (we'll switch to plain numeric tags then) +# TBD need to quote sed expression AC_INIT( [crosstool-NG], [m4_esyscmd_s([git describe --always --dirty])], - [crossgcc@sourceware.org]) + [crossgcc@sourceware.org], + [crosstool-ng], + [http://crosstool-ng.org]) AC_CONFIG_AUX_DIR([scripts]) - -#-------------------------------------------------------------------- -# A few helper macros - -# ACX_WITH_DEPRECATED(PROG, VAR) -# Declare a deprecated --with option: instead of --with-PROG=xxx, must use VAR=xxx -AC_DEFUN( - [ACX_WITH_DEPRECATED], - [AC_ARG_WITH([$1], - [AS_HELP_STRING([--with-$1=PATH], - [Deprecated; use $2=PATH instead])], - [AC_MSG_ERROR([--with-$1=$withval deprecated; use $2=$withval instead])]) - ]) - -# Check for required tool -AC_DEFUN( - [ACX_CHECK_TOOL_REQ], - [AC_CHECK_TOOLS([$1], [$2]) - AS_IF( - [test -z "$$1"], - [AC_MSG_ERROR([missing required tool: $2])]) - ]) - -# Check for required tool, set variable to full pathname -AC_DEFUN( - [ACX_PATH_TOOL_REQ], - [ACX_WITH_DEPRECATED([$3], [$1]) - AC_ARG_VAR([$1], [Specify the full path to GNU $3]) - ACX_CHECK_TOOL_REQ([$1], [$2]) - AS_CASE( - [$$1], - [/*],, - [?*],[AC_MSG_CHECKING([for absolute path to $$1]) - $1=$(which $$1) - AC_MSG_RESULT([$$1])])]) - -# Check for required program -AC_DEFUN( - [ACX_CHECK_PROGS_REQ], - [AC_CHECK_PROGS([$1], [$2]) - AS_IF( - [test -z "$$1"], - [AC_MSG_ERROR([missing required tool: $2])]) - ]) - -# Check for path to required program -AC_DEFUN( - [ACX_PATH_PROGS_REQ], - [AC_PATH_PROGS([$1], [$2]) - AS_IF( - [test -z "$$1"], - [AC_MSG_ERROR([missing required tool: $2])]) - ]) - -# Set the kconfig option -AC_DEFUN( - [ACX_SET_KCONFIG_OPTION], - [AS_IF( - [test -n "$$1"], - [AC_SUBST([KCONFIG_$1], ["def_bool y"])], - [AC_SUBST([KCONFIG_$1], ["bool"])])]) - -# Check if a given program is available with a particular version. -# ACX_PROG_VERSION(VAR, HELP, PROG, SRCH, VERSION_CHECK[, CONFIG_OPT]) -# Search for PROG under possible names of SRCH. Allow user overrides in variable -# VAR; display HELP message. Try to find a version that satisfies VERSION_CHECK -# regexp; if that is achieved, set CONFIG_OPT in the kconfig. Otherwise, settle -# for any version found. -# Sets acx_version_VAR_ok to ':' if the version met the criterion, or false otherwise. -AC_DEFUN( - [ACX_PROG_VERSION], - [AS_IF([test -z "$EGREP"], - [AC_MSG_ERROR([This macro can only be used after checking for EGREP])]) - ACX_WITH_DEPRECATED([$3], [$1]) - AC_ARG_VAR([$1], [Specify the full path to $2]) - acx_version_$1_ok=false - AC_CACHE_CHECK([for $3], [ac_cv_path_$1], - [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4], - [[ver=`$ac_path_$1 --version 2>/dev/null| $EGREP $5` - test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1 - test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: acx_version_$1_ok=:]])]) - AS_IF([test -n "$1"], - [[ver=`$ac_path_$1 --version 2>/dev/null| $EGREP $5` - test -n "$ver" && acx_version_$1_ok=:]]) - AC_MSG_CHECKING([for $2]) - AS_IF([$acx_version_$1_ok], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - AC_SUBST([$1], [$ac_cv_path_$1]) - AS_IF([test -n "$6"], - [AS_IF([$acx_version_$1_ok], [$6=y], [$6=]) - ACX_SET_KCONFIG_OPTION([$6])]) - ]) - -# Same as above, but make it a fatal error if the tool is not found at all -# (i.e. "require any version, prefer version X or newer") -AC_DEFUN( - [ACX_PROG_VERSION_REQ_ANY], - [ACX_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6]) - AS_IF([test -z "$$1"], - [AC_MSG_ERROR([Required tool not found: $3])]) - ]) - -# Same, but also require the version check to pass -# (i.e. "require version X or newer") -AC_DEFUN( - [ACX_PROG_VERSION_REQ_STRICT], - [ACX_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6]) - AS_IF([test -z "$$1" || ! $acx_version_$1_ok], - [AC_MSG_ERROR([Required tool not found: $2])]) - ]) +AC_CONFIG_MACRO_DIR([m4]) # Check if install(1) supports --strip-program=... AC_DEFUN( @@ -144,8 +39,7 @@ AC_ARG_ENABLE( [do not install, and use current directory])]) AC_SUBST([enable_local], [${enable_local:-no}]) -# FIXME: I don't know why we have this. Will remove after the next -# release. +# FIXME: I don't know why we have this. Will remove after the 1.24 release. AC_ARG_ENABLE( [shared], [AS_HELP_STRING( @@ -157,7 +51,6 @@ AC_ARG_ENABLE( [--enable-static], [build static libraries (deprecated, ignored)])]) -#--------------------------------------------------------------------- # Check for --build and --host... AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -168,27 +61,27 @@ AS_IF([test -n "$target_alias"], # Allow program name tranformation (--program-{prefix,suffix,transform-name}) AC_ARG_PROGRAM -#--------------------------------------------------------------------- -# Initial checks that are usually done first (I don't know why, that's -# just what I seem to experience...) -#--------------------------------------------------------------------- -ACX_WITH_DEPRECATED([install], [INSTALL]) +AC_PROG_MKDIR_P + +CTNG_WITH_DEPRECATED([install], [INSTALL]) AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install]) AC_PROG_INSTALL ACX_INSTALL_STRIP_PROGRAM -ACX_WITH_DEPRECATED([grep], [GREP]) +CTNG_WITH_DEPRECATED([grep], [GREP]) AC_ARG_VAR([GREP], [Specify the full path to GNU grep]) # This is not a typo! Prefer GNU grep on macOS if it is installed. -ACX_PATH_TOOL_REQ([GREP], [ggrep grep], [grep]) -ACX_PATH_TOOL_REQ([EGREP], [gegrep egrep], [egrep]) +CTNG_PATH_TOOL_REQ([GREP], [ggrep grep], [grep]) +CTNG_PATH_TOOL_REQ([EGREP], [gegrep egrep], [egrep]) AC_PROG_GREP AC_PROG_EGREP + +# FIXME: ct-ng assumes this in many places... AS_IF([test "$EGREP" != "$GREP -E"], [AC_MSG_ERROR([egrep is not $GREP -E])]) -ACX_PROG_VERSION_REQ_STRICT([SED], +CTNG_PROG_VERSION_REQ_STRICT([SED], [GNU sed >= 4.0], [sed], [gsed sed], @@ -203,9 +96,11 @@ AC_PROG_LN_S # Modern GCC/GDB releases require C++ support in the compiler AC_PROG_CC AC_PROG_CXX +AC_PROG_CPP +AC_PROG_LEX +AC_PROG_YACC AS_IF([test -z "$CC" -o -z "$CXX"], [AC_MSG_ERROR([no suitable compiler found])]) -AC_PROG_CPP #--------------------------------------------------------------------- # Check to see if the compiler can link statically @@ -218,82 +113,58 @@ AS_IF([test $static_test -eq 0], [test $static_test -ne 0], [static_link= AC_MSG_RESULT([no])]) -ACX_SET_KCONFIG_OPTION([static_link]) +CTNG_SET_KCONFIG_OPTION([static_link]) AC_PROG_RANLIB -ACX_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy]) -ACX_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump]) -ACX_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf]) -ACX_PATH_TOOL_REQ([GPERF], [gperf], [gperf]) - -ACX_CHECK_PROGS_REQ([bison], [bison]) -ACX_CHECK_PROGS_REQ([flex], [flex]) -ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo]) -ACX_CHECK_PROGS_REQ([cut], [cut]) -ACX_CHECK_PROGS_REQ([readlink], [readlink]) -ACX_CHECK_PROGS_REQ([tar], [tar]) -ACX_CHECK_PROGS_REQ([gzip], [gzip]) -ACX_CHECK_PROGS_REQ([bzip2], [bzip2]) -ACX_CHECK_PROGS_REQ([xz], [xz]) -ACX_CHECK_PROGS_REQ([help2man], [help2man]) +CTNG_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy]) +CTNG_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump]) +CTNG_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf]) +CTNG_PATH_TOOL_REQ([GPERF], [gperf], [gperf]) + +CTNG_CHECK_PROGS_REQ([bison], [bison]) +CTNG_CHECK_PROGS_REQ([flex], [flex]) +CTNG_CHECK_PROGS_REQ([makeinfo], [makeinfo]) +CTNG_CHECK_PROGS_REQ([cut], [cut]) +CTNG_CHECK_PROGS_REQ([readlink], [readlink]) +CTNG_CHECK_PROGS_REQ([tar], [tar]) +CTNG_CHECK_PROGS_REQ([gzip], [gzip]) +CTNG_CHECK_PROGS_REQ([bzip2], [bzip2]) +CTNG_CHECK_PROGS_REQ([xz], [xz]) +CTNG_CHECK_PROGS_REQ([help2man], [help2man]) # Not a fatal failure even if we have neither - the tarballs may # be provided in a local directory. AC_CHECK_PROGS([wget], [wget]) -ACX_SET_KCONFIG_OPTION([wget]) +CTNG_SET_KCONFIG_OPTION([wget]) AC_SUBST([wget]) AC_CHECK_PROGS([curl], [curl]) -ACX_SET_KCONFIG_OPTION([curl]) +CTNG_SET_KCONFIG_OPTION([curl]) AC_SUBST([curl]) -ACX_CHECK_PROGS_REQ([stat], [stat]) -AC_CACHE_CHECK([whether stat takes GNU or BSD format], - [acx_cv_stat_flavor], - [touch conftest - chmod 642 conftest - attr_bsd=`stat -f '%Lp' conftest 2>/dev/null` - attr_gnu=`stat -c '%a' conftest 2>/dev/null` - rm -f conftest - AS_IF([test "$attr_bsd" = "642"], - [acx_cv_stat_flavor=BSD], - [test "$attr_gnu" = "642"], - [acx_cv_stat_flavor=GNU], - [AC_MSG_ERROR([cannot determine stat(1) format option])])]) - +# TBD move the checks/setting kconfig into [IF-BSD] and [IF-GNU] arguments to CTNG_PROG_STAT +# TBD modify CTNG_SET_KCONFIG_OPTION to take an optional argument to which it should be set +CTNG_PROG_STAT # FIXME: support SET_KCONFIG_OPTION with string values? But then # again, these checks may be moved into ct-ng script. test "$acx_cv_stat_flavor" = "BSD" && stat_flavor_BSD=y -ACX_SET_KCONFIG_OPTION([stat_flavor_BSD]) +CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD]) test "$acx_cv_stat_flavor" = "GNU" && stat_flavor_GNU=y -ACX_SET_KCONFIG_OPTION([stat_flavor_GNU]) +CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU]) -#Find out how to count CPUs -AC_CACHE_CHECK([whether to use getconf or sysctl to count CPUs], - [acx_cv_cpu_count], - [getconf _NPROCESSORS_ONLN >/dev/null 2>&1 && \ - acx_cv_cpu_count="getconf _NPROCESSORS_ONLN" - sysctl -n hw.ncpu >/dev/null 2>&1 && \ - acx_cv_cpu_count="sysctl -n hw.ncpu"]) -AC_SUBST(CPU_COUNT, "$acx_cv_cpu_count") +CTNG_CPU_COUNT -#-------------------------------------------------------------------- -# Still boring, but remember the path, now... -#-------------------------------------------------------------------- -ACX_PATH_TOOL_REQ([PATCH], [gpatch patch], [patch]) +CTNG_PATH_TOOL_REQ([PATCH], [gpatch patch], [patch]) -#-------------------------------------------------------------------- -# And a bunch of less boring tests... -#-------------------------------------------------------------------- # We need a bash that is >= 3.1 -ACX_PROG_VERSION_REQ_STRICT([BASH_SHELL], +CTNG_PROG_VERSION_REQ_STRICT([BASH_SHELL], [GNU bash >= 3.1], [bash], [bash], ['^GNU bash, version (3\.[1-9]|4)']) # We need a awk that *is* GNU awk -ACX_PROG_VERSION_REQ_STRICT([AWK], +CTNG_PROG_VERSION_REQ_STRICT([AWK], [GNU awk], [awk], [gawk awk], @@ -306,7 +177,7 @@ ACX_PROG_VERSION_REQ_STRICT([AWK], # build/install crosstool-ng itself. #---------------------------------------- # Check for GNU make (want 3.81 or above, but will accept as long as any make is found) -ACX_PROG_VERSION_REQ_ANY([MAKE], +CTNG_PROG_VERSION_REQ_ANY([MAKE], [GNU make >= 3.81], [make], [gmake make], @@ -314,85 +185,64 @@ ACX_PROG_VERSION_REQ_ANY([MAKE], [make_3_81_or_newer]) # Check other companion tools that we may or may not build -ACX_PROG_VERSION([LIBTOOL], +CTNG_PROG_VERSION([LIBTOOL], [GNU libtool >= 2.4], [libtool], [glibtool libtool], ['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'], [libtool_2_4_or_newer]) -ACX_PROG_VERSION([LIBTOOLIZE], +CTNG_PROG_VERSION([LIBTOOLIZE], [GNU libtoolize >= 2.4], [libtoolize], [glibtoolize libtoolize], ['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'], [libtoolize_2_4_or_newer]) -ACX_PROG_VERSION([AUTOCONF], +CTNG_PROG_VERSION([AUTOCONF], [GNU autoconf >= 2.65], [autoconf], [autoconf], ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[5-9])'], [autoconf_2_63_or_newer]) -ACX_PROG_VERSION([AUTORECONF], +CTNG_PROG_VERSION([AUTORECONF], [GNU autoreconf >= 2.63], [autoreconf], [autoreconf], ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[3-9])'], [autoreconf_2_63_or_newer]) -ACX_PROG_VERSION([AUTOMAKE], +CTNG_PROG_VERSION([AUTOMAKE], [GNU automake >= 1.15], [automake], [automake], ['\(GNU automake\) ([2-9]\.|1\.[2-9][0-9]|1\.1[5-9])'], [automake_1_15_or_newer]) -ACX_PROG_VERSION([M4], +CTNG_PROG_VERSION([M4], [GNU m4 >= 1.4.12], [m4], [gm4 m4], ['\(GNU M4\) ([2-9]\.|1\.[5-9]|1\.[1-4][0-9]|1\.4\.[2-9][0-9]|1\.4\.1[2-9])'], [gnu_m4_1_4_12_or_newer]) -#---------------------------------------- -# Gperf 3.1 started generating functions with size_t rather than unsigned int -AC_MSG_CHECKING([for the type used in gperf declarations]) -echo "#include " > conftest.gperf.c -echo "const char * in_word_set(const char *, GPERF_LEN_TYPE);" >> conftest.gperf.c -echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c -AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1], - [AC_MSG_RESULT([size_t]) - GPERF_LEN_TYPE='size_t'], - [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1], - [AC_MSG_RESULT([unsigned int]) - GPERF_LEN_TYPE='unsigned int'], - [AC_MSG_ERROR([unable to determine gperf len type])]) -rm -f conftest.gperf.c -AC_SUBST([GPERF_LEN_TYPE]) +CTNG_PROG_GPERF -#-------------------------------------------------------------------- -# Boring again... But still a bit of work to do... -#-------------------------------------------------------------------- AC_SUBST([kconfig_options]) -#---------------------------------------- AC_CHECK_PROGS([cvs], [cvs]) -ACX_SET_KCONFIG_OPTION([cvs]) +CTNG_SET_KCONFIG_OPTION([cvs]) -#---------------------------------------- AC_CHECK_PROGS([svn], [svn]) -ACX_SET_KCONFIG_OPTION([svn]) +CTNG_SET_KCONFIG_OPTION([svn]) AC_CHECK_PROGS([git], [git]) -ACX_SET_KCONFIG_OPTION([git]) +CTNG_SET_KCONFIG_OPTION([git]) AC_CHECK_PROGS([DPKG_BUILDFLAGS], [dpkg-buildflags]) -#-------------------------------------------------------------------- -# Now, for some fun... -#-------------------------------------------------------------------- +# FIXME why checking if not using the result? We don't provide replacemant malloc/alloca/... AC_C_INLINE AC_HEADER_STDC AC_FUNC_MALLOC @@ -417,7 +267,6 @@ AC_SEARCH_LIBS(bindtextdomain, intl, [test "$ac_res" = "none required" || INTL_L LIBS=$SAVE_LIBS AC_SUBST([INTL_LIBS]) -#---------------------------------------- # Check for ncurses, for the kconfig frontends AC_SUBST([ac_ct_curses_hdr]) AC_CHECK_HEADERS( @@ -437,9 +286,6 @@ AC_SEARCH_LIBS( [tgetent], [termcap tinfo ncursesw ncurses curses]) -#-------------------------------------------------------------------- -# Lastly, take care of crosstool-NG internal values -#-------------------------------------------------------------------- # Hey! We need the date! :-) DATE_FMT="%Y%m%d" if test "x$SOURCE_DATE_EPOCH" = "x"; then @@ -449,23 +295,10 @@ else fi AC_SUBST([DATE]) -# Decorate the version string if needed +# Decorate the version string per user-supplied version.sh, if any AS_IF( [test -f version.sh -a -x version.sh], - [V=$(./version.sh "${PACKAGE_VERSION}")]) -AS_IF( - [test -n "${V}"], - [PACKAGE_VERSION="${V}"], - [AS_CASE( - [${PACKAGE_VERSION}], - [git|*+git], - [rev_id="$( git rev-parse --short HEAD )" - git diff-index --quiet HEAD || rev_id="${rev_id}-dirty" - PACKAGE_VERSION="${PACKAGE_VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}" - ])]) -# Arrange to have no / in the directory name, no need to create an -# arbitrarily deep directory structure -[PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"] + [PACKAGE_VERSION=$(./version.sh "${PACKAGE_VERSION}")]) # Handle the local case AC_SUBST([sublibdir]) @@ -485,8 +318,10 @@ AS_IF( [sublibdir="/\${VERSION}" subdocdir="/\${VERSION}"]) -#-------------------------------------------------------------------- -# Finally, generate the output file(s) -#-------------------------------------------------------------------- -AC_CONFIG_FILES([Makefile kconfig/Makefile config/configure.in]) +AC_CONFIG_FILES([ + Makefile + kconfig/Makefile + config/configure.in +]) + AC_OUTPUT diff --git a/m4/README b/m4/README new file mode 100644 index 0000000..a572d61 --- /dev/null +++ b/m4/README @@ -0,0 +1,7 @@ +These autoconf helper macros come from various sources: + +- ax_*.m4: autoconf-archive, version 2017.09.28 (copied) +- pkg.m4: pkg-config, version 0.29.2 (run configure, then copy) +- gettext.m4, iconv.m4, intlmacosx.m4, nls.m4: gettext 0.19.8 +- ctng_*.m4: obviously, implemented anew +- po.m4: a local dummy stub for gettext's version diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 new file mode 100644 index 0000000..17c3eab --- /dev/null +++ b/m4/ax_require_defined.m4 @@ -0,0 +1,37 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_DEFINED(MACRO) +# +# DESCRIPTION +# +# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have +# been defined and thus are available for use. This avoids random issues +# where a macro isn't expanded. Instead the configure script emits a +# non-fatal: +# +# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found +# +# It's like AC_REQUIRE except it doesn't expand the required macro. +# +# Here's an example: +# +# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) +# +# LICENSE +# +# Copyright (c) 2014 Mike Frysinger +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_REQUIRE_DEFINED], [dnl + m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) +])dnl AX_REQUIRE_DEFINED diff --git a/m4/ctng_cpu_count.m4 b/m4/ctng_cpu_count.m4 new file mode 100644 index 0000000..4ea50d8 --- /dev/null +++ b/m4/ctng_cpu_count.m4 @@ -0,0 +1,10 @@ +# Find out how to count CPUs +AC_DEFUN([CTNG_CPU_COUNT], + [AC_CACHE_CHECK([whether to use getconf or sysctl to count CPUs], + [acx_cv_cpu_count], + [getconf _NPROCESSORS_ONLN >/dev/null 2>&1 && \ + acx_cv_cpu_count="getconf _NPROCESSORS_ONLN" + sysctl -n hw.ncpu >/dev/null 2>&1 && \ + acx_cv_cpu_count="sysctl -n hw.ncpu"]) + AC_SUBST(CPU_COUNT, "$acx_cv_cpu_count") + ]) diff --git a/m4/ctng_gperf.m4 b/m4/ctng_gperf.m4 new file mode 100644 index 0000000..0ec1a0e --- /dev/null +++ b/m4/ctng_gperf.m4 @@ -0,0 +1,23 @@ +# Check for GNU perf location and the type it uses in the prototypes +# FIXME: remove AC_SUBST after switching to using autoheader +AC_DEFUN([CTNG_PROG_GPERF], + [AX_REQUIRE_DEFINED([CTNG_CHECK_TOOL_REQ]) + CTNG_CHECK_TOOL_REQ([GPERF], [gperf], [gperf]) + # Gperf 3.1 started generating functions with size_t rather than unsigned int + AC_MSG_CHECKING([for the type used in gperf declarations]) + cat > conftest.gperf.c <<_ASEOF +#include " +const char * in_word_set(const char *, GPERF_LEN_TYPE); +_ASEOF + echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c + AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1], + [AC_MSG_RESULT([size_t]) + GPERF_LEN_TYPE='size_t'], + [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1], + [AC_MSG_RESULT([unsigned int]) + GPERF_LEN_TYPE='unsigned int'], + [AC_MSG_ERROR([unable to determine gperf len type])]) + rm -f conftest.gperf.c + AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], $GPERF_LEN_TYPE, [String length type used by gperf]) + AC_SUBST([GPERF_LEN_TYPE]) +]) diff --git a/m4/ctng_prog.m4 b/m4/ctng_prog.m4 new file mode 100644 index 0000000..ebbe333 --- /dev/null +++ b/m4/ctng_prog.m4 @@ -0,0 +1,36 @@ +# Several convenience wrappers for checking the programs + +# Check for required tool +AC_DEFUN([CTNG_CHECK_TOOL_REQ], + [AC_CHECK_TOOLS([$1], [$2]) + AS_IF( + [test -z "$$1"], + [AC_MSG_ERROR([missing required tool: $2])]) + ]) + +# Check for required tool, set variable to full pathname +AC_DEFUN([CTNG_PATH_TOOL_REQ], + [AC_ARG_VAR([$1], [Specify the full path to GNU $3]) + CTNG_CHECK_TOOL_REQ([$1], [$2]) + AS_CASE( + [$$1], + [/*],, + [?*],[AC_MSG_CHECKING([for absolute path to $$1]) + $1=$(which $$1) + AC_MSG_RESULT([$$1])])]) + +# Check for required program +AC_DEFUN([CTNG_CHECK_PROGS_REQ], + [AC_CHECK_PROGS([$1], [$2]) + AS_IF( + [test -z "$$1"], + [AC_MSG_ERROR([missing required tool: $2])]) + ]) + +# Check for path to required program +AC_DEFUN([CTNG_PATH_PROGS_REQ], + [AC_PATH_PROGS([$1], [$2]) + AS_IF( + [test -z "$$1"], + [AC_MSG_ERROR([missing required tool: $2])]) + ]) diff --git a/m4/ctng_prog_stat.m4 b/m4/ctng_prog_stat.m4 new file mode 100644 index 0000000..f7de93e --- /dev/null +++ b/m4/ctng_prog_stat.m4 @@ -0,0 +1,18 @@ +# Check that stat(1) is present and determine the syntax for the format +# string (BSD or GNU). +AC_DEFUN([CTNG_PROG_STAT], + [AX_REQUIRE_DEFINED([CTNG_CHECK_PROGS_REQ]) + CTNG_CHECK_PROGS_REQ([stat], [stat]) + AC_CACHE_CHECK([whether stat takes GNU or BSD format], + [acx_cv_stat_flavor], + [touch conftest + chmod 642 conftest + attr_bsd=$(stat -f '%Lp' conftest 2>/dev/null) + attr_gnu=$(stat -c '%a' conftest 2>/dev/null) + rm -f conftest + AS_IF([test "$attr_bsd" = "642"], + [acx_cv_stat_flavor=BSD], + [test "$attr_gnu" = "642"], + [acx_cv_stat_flavor=GNU], + [AC_MSG_ERROR([cannot determine stat(1) format option])])]) + ]) diff --git a/m4/ctng_set_kconfig_option.m4 b/m4/ctng_set_kconfig_option.m4 new file mode 100644 index 0000000..9fae320 --- /dev/null +++ b/m4/ctng_set_kconfig_option.m4 @@ -0,0 +1,7 @@ +# Set the kconfig option. +AC_DEFUN([CTNG_SET_KCONFIG_OPTION], + [AS_IF( + [test -n "$$1"], + [AC_SUBST([KCONFIG_$1], ["def_bool y"])], + [AC_SUBST([KCONFIG_$1], ["bool"])]) + ]) diff --git a/m4/ctng_version_check.m4 b/m4/ctng_version_check.m4 new file mode 100644 index 0000000..472194b --- /dev/null +++ b/m4/ctng_version_check.m4 @@ -0,0 +1,47 @@ +# Check if a given program is available with a particular version. +# CTNG_PROG_VERSION(VAR, HELP, PROG, SRCH, VERSION_CHECK[, CONFIG_OPT]) +# Search for PROG under possible names of SRCH. Allow user overrides in variable +# VAR; display HELP message. Try to find a version that satisfies VERSION_CHECK +# regexp; if that is achieved, set CONFIG_OPT in the kconfig. Otherwise, settle +# for any version found. +# Sets acx_version_VAR_ok to ':' if the version met the criterion, or false otherwise. +AC_DEFUN([CTNG_PROG_VERSION], + [AS_IF([test -z "$EGREP"], + [AC_MSG_ERROR([This macro can only be used after checking for EGREP])]) + CTNG_WITH_DEPRECATED([$3], [$1]) + AC_ARG_VAR([$1], [Specify the full path to $2]) + acx_version_$1_ok=false + AC_CACHE_CHECK([for $3], [ac_cv_path_$1], + [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4], + [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5) + test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1 + test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: acx_version_$1_ok=:]])]) + AS_IF([test -n "$1"], + [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5) + test -n "$ver" && acx_version_$1_ok=:]]) + AC_MSG_CHECKING([for $2]) + AS_IF([$acx_version_$1_ok], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + AC_SUBST([$1], [$ac_cv_path_$1]) + AS_IF([test -n "$6"], + [AS_IF([$acx_version_$1_ok], [$6=y], [$6=]) + CTNG_SET_KCONFIG_OPTION([$6])]) + ]) + +# Same as above, but make it a fatal error if the tool is not found at all +# (i.e. "require any version, prefer version X or newer") +AC_DEFUN([CTNG_PROG_VERSION_REQ_ANY], + [CTNG_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6]) + AS_IF([test -z "$$1"], + [AC_MSG_ERROR([Required tool not found: $3])]) + ]) + +# Same, but also require the version check to pass +# (i.e. "require version X or newer") +AC_DEFUN([CTNG_PROG_VERSION_REQ_STRICT], + [CTNG_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6]) + AS_IF([test -z "$$1" || ! $acx_version_$1_ok], + [AC_MSG_ERROR([Required tool not found: $2])]) + ]) + diff --git a/m4/ctng_with_deprecated.m4 b/m4/ctng_with_deprecated.m4 new file mode 100644 index 0000000..976bc3f --- /dev/null +++ b/m4/ctng_with_deprecated.m4 @@ -0,0 +1,10 @@ +# FIXME retire after 1.24 +# +# CTNG_WITH_DEPRECATED(PROG, VAR) +# Declare a deprecated --with option: instead of --with-PROG=xxx, must use VAR=xxx +AC_DEFUN([CTNG_WITH_DEPRECATED], + [AC_ARG_WITH([$1], + [AS_HELP_STRING([--with-$1=PATH], + [Deprecated; use $2=PATH instead])], + [AC_MSG_ERROR([--with-$1=$withval deprecated; use $2=$withval instead])]) + ]) -- cgit v0.10.2-6-g49f6 From 0bcb67fa52b1318b098366fa44955f528999f4db Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 6 Jan 2018 23:16:33 -0800 Subject: Use autoconfig-archve/automake tests Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index d456d1e..bea75da 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ configure autom4te.cache aclocal.m4 +config.h* config.log config.status /Makefile diff --git a/configure.ac b/configure.ac index 97d7607..4889439 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,7 @@ AS_IF([test -n "$target_alias"], AC_ARG_PROGRAM AC_PROG_MKDIR_P +AC_PROG_LN_S CTNG_WITH_DEPRECATED([install], [INSTALL]) AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install]) @@ -88,11 +89,8 @@ CTNG_PROG_VERSION_REQ_STRICT([SED], ['GNU sed[^0-9]* [4-9]\.']) AC_ARG_VAR([SED], [Specify the full path to GNU sed]) -AC_PROG_LN_S +AC_CONFIG_HEADERS([config.h]) -#-------------------------------------------------------------------- -# A bunch of boring tests... -#-------------------------------------------------------------------- # Modern GCC/GDB releases require C++ support in the compiler AC_PROG_CC AC_PROG_CXX @@ -102,7 +100,6 @@ AC_PROG_YACC AS_IF([test -z "$CC" -o -z "$CXX"], [AC_MSG_ERROR([no suitable compiler found])]) -#--------------------------------------------------------------------- # Check to see if the compiler can link statically AC_MSG_CHECKING([if $CC can static link]) echo "int main() {}" | ${CC} -static -o /dev/null -xc - > /dev/null 2>&1 @@ -249,50 +246,56 @@ AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_ALLOCA -#---------------------------------------- -# Check for gettext and libintl for the kconfig frontends -AC_SUBST([gettext]) -AC_CHECK_HEADERS( - [libintl.h], - [ac_ct_gettext_hdr=$ac_header; break]) -AS_IF( - [test -n "$ac_ct_gettext_hdr"], - [AC_CHECK_DECL( - [gettext], - [gettext=y],, - [AC_INCLUDES_DEFAULT() - #include <$ac_ct_gettext_hdr>])]) -SAVE_LIBS=$LIBS -AC_SEARCH_LIBS(bindtextdomain, intl, [test "$ac_res" = "none required" || INTL_LIBS="${ac_res}"]) -LIBS=$SAVE_LIBS -AC_SUBST([INTL_LIBS]) - -# Check for ncurses, for the kconfig frontends -AC_SUBST([ac_ct_curses_hdr]) -AC_CHECK_HEADERS( - [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h], - [ac_ct_curses_hdr=$ac_header; break]) -AS_IF( - [test -z "$ac_ct_curses_hdr"], - [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])]) -AC_SEARCH_LIBS( - [initscr], - [ncursesw ncurses curses], - [ac_ct_curses_lib_found=yes; break]) -AS_IF( - [test -z "$ac_ct_curses_lib_found"], - [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])]) -AC_SEARCH_LIBS( - [tgetent], - [termcap tinfo ncursesw ncurses curses]) - -# Hey! We need the date! :-) -DATE_FMT="%Y%m%d" -if test "x$SOURCE_DATE_EPOCH" = "x"; then - DATE=$(date "+$DATE_FMT") -else - DATE="$(date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u "+$DATE_FMT")" -fi +AM_GNU_GETTEXT([external]) + +# For now, curses are needed to build kconfig. We may support a command-line +# only configuration without curses later. For now, fail in configure but +# consider it ok in config.h. +AX_WITH_CURSES +AS_IF([test "x$ax_cv_curses" != "xyes" ], [AC_MSG_ERROR([curses library not found])]) +AX_WITH_CURSES_PANEL +AS_IF([test "x$ax_cv_panel" != "xyes" ], [AC_MSG_ERROR([panel library not found])]) +AX_WITH_CURSES_MENU +AS_IF([test "x$ax_cv_menu" != "xyes" ], [AC_MSG_ERROR([menu library not found])]) + +AH_BOTTOM([ +/* Select the correct curses/menu/panel headers */ +#if defined HAVE_NCURSESW_CURSES_H +# define CURSES_LOC +#elif defined HAVE_NCURSESW_H +# define CURSES_LOC +#elif defined HAVE_NCURSES_CURSES_H +# define CURSES_LOC +#elif defined HAVE_NCURSES_H +# define CURSES_LOC +#elif defined HAVE_CURSES_H +# define CURSES_LOC +#else +# /* not an error - maybe a configuration didn't need curses */ +#endif + +#if defined HAVE_NCURSESW_PANEL_H +# define PANEL_LOC +#elif defined HAVE_NCURSES_PANEL_H +# define PANEL_LOC +#elif defined HAVE_PANEL_H +# define PANEL_LOC +#else +# /* not an error */ +#endif + +#if defined HAVE_NCURSESW_MENU_H +# define MENU_LOC +#elif defined HAVE_NCURSES_MENU_H +# define MENU_LOC +#elif defined HAVE_MENU_H +# define MENU_LOC +#else +# /* not an error */ +#endif +]) + +AX_BUILD_DATE_EPOCH(DATE, [%c]) AC_SUBST([DATE]) # Decorate the version string per user-supplied version.sh, if any diff --git a/kconfig/Makefile.in b/kconfig/Makefile.in index 7e18b6e..630ac14 100644 --- a/kconfig/Makefile.in +++ b/kconfig/Makefile.in @@ -11,8 +11,9 @@ all: $(PROGS) @true # Just be silent, you fscking son of a fscking beach... # Build flags -CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" -LDFLAGS = $(INTL_LIBS) +CFLAGS = --include @top_builddir@/config.h -DCONFIG_=\"CT_\" \ + @CFLAGS@ @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ @LIBINTL@ ifneq (@DPKG_BUILDFLAGS@,) CFLAGS += $(shell @DPKG_BUILDFLAGS@ --get CPPFLAGS) \ @@ -21,45 +22,41 @@ LDFLAGS += $(shell @DPKG_BUILDFLAGS@ --get LDFLAGS) endif # Compiler flags to use gettext -ifeq ($(gettext),) -INTL_CFLAGS = -Wno-format-security -DKBUILD_NO_NLS +ifneq (@USE_NLS@,yes) +CFLAGS += -Wno-format-security -DKBUILD_NO_NLS endif -# Compiler and linker flags to use ncurses -NCURSES_CFLAGS = -DCURSES_LOC="\"$(curses_hdr)\"" -NCURSES_LDFLAGS = $(LIBS) - # Common source files COMMON_SRC = zconf.tab.c COMMON_OBJ = $(patsubst %.c,%.o,$(COMMON_SRC)) COMMON_DEP = $(patsubst %.o,%.dep,$(COMMON_OBJ)) -$(COMMON_OBJ) $(COMMON_DEP): CFLAGS += $(INTL_CFLAGS) -I. +$(COMMON_OBJ) $(COMMON_DEP): CFLAGS += -I. # lxdialog source files LX_SRC = $(sort $(wildcard lxdialog/*.c)) LX_OBJ = $(patsubst %.c,%.o,$(LX_SRC)) LX_DEP = $(patsubst %.o,%.dep,$(LX_OBJ)) -$(LX_OBJ) $(LX_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS) +$(LX_OBJ) $(LX_DEP): CFLAGS += @CURSES_CFLAGS@ # What's needed to build 'conf' conf_SRC = conf.c conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC)) conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ)) -$(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS) +$(conf_OBJ) $(conf_DEP): CFLAGS += # What's needed to build 'mconf' mconf_SRC = mconf.c mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC)) mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC)) -$(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS) -mconf: LDFLAGS += $(NCURSES_LDFLAGS) +$(mconf_OBJ) $(mconf_DEP): CFLAGS += @CURSES_CFLAGS@ +mconf: LDFLAGS += @CURSES_LIBS@ # What's needed to build 'nconf' nconf_SRC = nconf.c nconf.gui.c nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC)) nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC)) -$(nconf_OBJ) $(nconf_DEP): CFLAGS += $(INTL_CFLAGS) -I/usr/include/ncurses -nconf: LDFLAGS += -lmenu -lpanel $(LIBS) +$(nconf_OBJ) $(nconf_DEP): CFLAGS += +nconf: LDFLAGS += @MENU_LIBS@ @PANEL_LIBS@ @CURSES_LIBS@ # These are generated files: ALL_OBJS = $(sort $(COMMON_OBJ) $(LX_OBJ) $(conf_OBJ) $(mconf_OBJ) $(nconf_OBJ)) diff --git a/m4/ax_build_date_epoch.m4 b/m4/ax_build_date_epoch.m4 new file mode 100644 index 0000000..dbecb06 --- /dev/null +++ b/m4/ax_build_date_epoch.m4 @@ -0,0 +1,70 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_build_date_epoch.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BUILD_DATE_EPOCH(VARIABLE[, FORMAT[, ACTION-IF-FAIL]]) +# +# DESCRIPTION +# +# Sets VARIABLE to a string representing the current time. It is +# formatted according to FORMAT if specified, otherwise it is formatted as +# the number of seconds (excluding leap seconds) since the UNIX epoch (01 +# Jan 1970 00:00:00 UTC). +# +# If the SOURCE_DATE_EPOCH environment variable is set, it uses the value +# of that variable instead of the current time. See +# https://reproducible-builds.org/specs/source-date-epoch). If +# SOURCE_DATE_EPOCH is set but cannot be properly interpreted as a UNIX +# timestamp, then execute ACTION-IF-FAIL if specified, otherwise error. +# +# VARIABLE is AC_SUBST-ed. +# +# LICENSE +# +# Copyright (c) 2016 Eric Bavier +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_BUILD_DATE_EPOCH], +[dnl +AC_MSG_CHECKING([for build time]) +ax_date_fmt="m4_default($2,%s)" +AS_IF([test x"$SOURCE_DATE_EPOCH" = x], + [$1=`date "+$ax_date_fmt"`], + [ax_build_date=`date -u -d "@$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null \ + || date -u -r "$SOURCE_DATE_EPOCH" "+$ax_date_fmt" 2>/dev/null` + AS_IF([test x"$ax_build_date" = x], + [m4_ifval([$3], + [$3], + [AC_MSG_ERROR([malformed SOURCE_DATE_EPOCH])])], + [$1=$ax_build_date])]) +AC_MSG_RESULT([$$1]) +])dnl AX_BUILD_DATE_EPOCH diff --git a/m4/ax_with_curses.m4 b/m4/ax_with_curses.m4 new file mode 100644 index 0000000..dcdc129 --- /dev/null +++ b/m4/ax_with_curses.m4 @@ -0,0 +1,582 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_with_curses.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_CURSES +# +# DESCRIPTION +# +# This macro checks whether a SysV or X/Open-compatible Curses library is +# present, along with the associated header file. The NcursesW +# (wide-character) library is searched for first, followed by Ncurses, +# then the system-default plain Curses. The first library found is the +# one returned. Finding libraries will first be attempted by using +# pkg-config, and should the pkg-config files not be available, will +# fallback to combinations of known flags itself. +# +# The following options are understood: --with-ncursesw, --with-ncurses, +# --without-ncursesw, --without-ncurses. The "--with" options force the +# macro to use that particular library, terminating with an error if not +# found. The "--without" options simply skip the check for that library. +# The effect on the search pattern is: +# +# (no options) - NcursesW, Ncurses, Curses +# --with-ncurses --with-ncursesw - NcursesW only [*] +# --without-ncurses --with-ncursesw - NcursesW only [*] +# --with-ncursesw - NcursesW only [*] +# --with-ncurses --without-ncursesw - Ncurses only [*] +# --with-ncurses - NcursesW, Ncurses [**] +# --without-ncurses --without-ncursesw - Curses only +# --without-ncursesw - Ncurses, Curses +# --without-ncurses - NcursesW, Curses +# +# [*] If the library is not found, abort the configure script. +# +# [**] If the second library (Ncurses) is not found, abort configure. +# +# The following preprocessor symbols may be defined by this macro if the +# appropriate conditions are met: +# +# HAVE_CURSES - if any SysV or X/Open Curses library found +# HAVE_CURSES_ENHANCED - if library supports X/Open Enhanced functions +# HAVE_CURSES_COLOR - if library supports color (enhanced functions) +# HAVE_CURSES_OBSOLETE - if library supports certain obsolete features +# HAVE_NCURSESW - if NcursesW (wide char) library is to be used +# HAVE_NCURSES - if the Ncurses library is to be used +# +# HAVE_CURSES_H - if is present and should be used +# HAVE_NCURSESW_H - if should be used +# HAVE_NCURSES_H - if should be used +# HAVE_NCURSESW_CURSES_H - if should be used +# HAVE_NCURSES_CURSES_H - if should be used +# +# (These preprocessor symbols are discussed later in this document.) +# +# The following output variables are defined by this macro; they are +# precious and may be overridden on the ./configure command line: +# +# CURSES_LIBS - library to add to xxx_LDADD +# CURSES_CFLAGS - include paths to add to xxx_CPPFLAGS +# +# In previous versions of this macro, the flags CURSES_LIB and +# CURSES_CPPFLAGS were defined. These have been renamed, in keeping with +# AX_WITH_CURSES's close bigger brother, PKG_CHECK_MODULES, which should +# eventually supersede the use of AX_WITH_CURSES. Neither the library +# listed in CURSES_LIBS, nor the flags in CURSES_CFLAGS are added to LIBS, +# respectively CPPFLAGS, by default. You need to add both to the +# appropriate xxx_LDADD/xxx_CPPFLAGS line in your Makefile.am. For +# example: +# +# prog_LDADD = @CURSES_LIBS@ +# prog_CPPFLAGS = @CURSES_CFLAGS@ +# +# If CURSES_LIBS is set on the configure command line (such as by running +# "./configure CURSES_LIBS=-lmycurses"), then the only header searched for +# is . If the user needs to specify an alternative path for a +# library (such as for a non-standard NcurseW), the user should use the +# LDFLAGS variable. +# +# The following shell variables may be defined by this macro: +# +# ax_cv_curses - set to "yes" if any Curses library found +# ax_cv_curses_enhanced - set to "yes" if Enhanced functions present +# ax_cv_curses_color - set to "yes" if color functions present +# ax_cv_curses_obsolete - set to "yes" if obsolete features present +# +# ax_cv_ncursesw - set to "yes" if NcursesW library found +# ax_cv_ncurses - set to "yes" if Ncurses library found +# ax_cv_plaincurses - set to "yes" if plain Curses library found +# ax_cv_curses_which - set to "ncursesw", "ncurses", "plaincurses" or "no" +# +# These variables can be used in your configure.ac to determine the level +# of support you need from the Curses library. For example, if you must +# have either Ncurses or NcursesW, you could include: +# +# AX_WITH_CURSES +# if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then +# AC_MSG_ERROR([requires either NcursesW or Ncurses library]) +# fi +# +# If any Curses library will do (but one must be present and must support +# color), you could use: +# +# AX_WITH_CURSES +# if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then +# AC_MSG_ERROR([requires an X/Open-compatible Curses library with color]) +# fi +# +# Certain preprocessor symbols and shell variables defined by this macro +# can be used to determine various features of the Curses library. In +# particular, HAVE_CURSES and ax_cv_curses are defined if the Curses +# library found conforms to the traditional SysV and/or X/Open Base Curses +# definition. Any working Curses library conforms to this level. +# +# HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the +# library supports the X/Open Enhanced Curses definition. In particular, +# the wide-character types attr_t, cchar_t and wint_t, the functions +# wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES +# are checked. The Ncurses library does NOT conform to this definition, +# although NcursesW does. +# +# HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library +# supports color functions and macros such as COLOR_PAIR, A_COLOR, +# COLOR_WHITE, COLOR_RED and init_pair(). These are NOT part of the +# X/Open Base Curses definition, but are part of the Enhanced set of +# functions. The Ncurses library DOES support these functions, as does +# NcursesW. +# +# HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the +# library supports certain features present in SysV and BSD Curses but not +# defined in the X/Open definition. In particular, the functions +# getattrs(), getcurx() and getmaxx() are checked. +# +# To use the HAVE_xxx_H preprocessor symbols, insert the following into +# your system.h (or equivalent) header file: +# +# #if defined HAVE_NCURSESW_CURSES_H +# # include +# #elif defined HAVE_NCURSESW_H +# # include +# #elif defined HAVE_NCURSES_CURSES_H +# # include +# #elif defined HAVE_NCURSES_H +# # include +# #elif defined HAVE_CURSES_H +# # include +# #else +# # error "SysV or X/Open-compatible Curses header file required" +# #endif +# +# For previous users of this macro: you should not need to change anything +# in your configure.ac or Makefile.am, as the previous (serial 10) +# semantics are still valid. However, you should update your system.h (or +# equivalent) header file to the fragment shown above. You are encouraged +# also to make use of the extended functionality provided by this version +# of AX_WITH_CURSES, as well as in the additional macros +# AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM. +# +# LICENSE +# +# Copyright (c) 2009 Mark Pulford +# Copyright (c) 2009 Damian Pietras +# Copyright (c) 2012 Reuben Thomas +# Copyright (c) 2011 John Zaitseff +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 18 + +# internal function to factorize common code that is used by both ncurses +# and ncursesw +AC_DEFUN([_FIND_CURSES_FLAGS], [ + AC_MSG_CHECKING([for $1 via pkg-config]) + + AX_REQUIRE_DEFINED([PKG_CHECK_EXISTS]) + _PKG_CONFIG([_ax_cv_$1_libs], [libs], [$1]) + _PKG_CONFIG([_ax_cv_$1_cppflags], [cflags], [$1]) + + AS_IF([test "x$pkg_failed" = "xyes" || test "x$pkg_failed" = "xuntried"],[ + AC_MSG_RESULT([no]) + # No suitable .pc file found, have to find flags via fallback + AC_CACHE_CHECK([for $1 via fallback], [ax_cv_$1], [ + AS_ECHO() + pkg_cv__ax_cv_$1_libs="-l$1" + pkg_cv__ax_cv_$1_cppflags="-D_GNU_SOURCE $CURSES_CFLAGS" + LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs" + CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags" + + AC_MSG_CHECKING([for initscr() with $pkg_cv__ax_cv_$1_libs]) + AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])], + [ + AC_MSG_RESULT([yes]) + AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs]) + AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[ + ax_cv_$1=yes + ],[ + AC_MSG_RESULT([no]) + m4_if( + [$1],[ncursesw],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfow"], + [$1],[ncurses],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfo"] + ) + LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs" + + AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs]) + AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[ + ax_cv_$1=yes + ],[ + ax_cv_$1=no + ]) + ]) + ],[ + ax_cv_$1=no + ]) + ]) + ],[ + AC_MSG_RESULT([yes]) + # Found .pc file, using its information + LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs" + CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags" + ax_cv_$1=yes + ]) +]) + +AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES]) +AC_DEFUN([AX_WITH_CURSES], [ + AC_ARG_VAR([CURSES_LIBS], [linker library for Curses, e.g. -lcurses]) + AC_ARG_VAR([CURSES_CFLAGS], [preprocessor flags for Curses, e.g. -I/usr/include/ncursesw]) + AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses], + [force the use of Ncurses or NcursesW])], + [], [with_ncurses=check]) + AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw], + [do not use NcursesW (wide character support)])], + [], [with_ncursesw=check]) + + ax_saved_LIBS=$LIBS + ax_saved_CPPFLAGS=$CPPFLAGS + + AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes], + [ax_with_plaincurses=no], [ax_with_plaincurses=check]) + + ax_cv_curses_which=no + + # Test for NcursesW + AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncursesw" != xno], [ + _FIND_CURSES_FLAGS([ncursesw]) + + AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [ + AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library]) + ]) + + AS_IF([test "x$ax_cv_ncursesw" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=ncursesw + CURSES_LIBS="$pkg_cv__ax_cv_ncursesw_libs" + CURSES_CFLAGS="$pkg_cv__ax_cv_ncursesw_cppflags" + AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncursesw_curses_h=yes], + [ax_cv_header_ncursesw_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncursesw_h=yes], + [ax_cv_header_ncursesw_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSESW_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncurses_h_with_ncursesw=yes], + [ax_cv_header_ncurses_h_with_ncursesw=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if is present]) + ]) + + AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xno && test "x$ax_cv_header_ncursesw_h" = xno && test "x$ax_cv_header_ncurses_h_with_ncursesw" = xno], [ + AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h]) + ]) + ]) + ]) + unset pkg_cv__ax_cv_ncursesw_libs + unset pkg_cv__ax_cv_ncursesw_cppflags + + # Test for Ncurses + AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [ + _FIND_CURSES_FLAGS([ncurses]) + + AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [ + AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library]) + ]) + + AS_IF([test "x$ax_cv_ncurses" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=ncurses + CURSES_LIBS="$pkg_cv__ax_cv_ncurses_libs" + CURSES_CFLAGS="$pkg_cv__ax_cv_ncurses_cppflags" + AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_header_ncurses_curses_h=yes], + [ax_cv_header_ncurses_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [ + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_header_ncurses_h=yes], + [ax_cv_header_ncurses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [ + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if is present]) + ]) + + AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [ + AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h]) + ]) + ]) + ]) + unset pkg_cv__ax_cv_ncurses_libs + unset pkg_cv__ax_cv_ncurses_cppflags + + # Test for plain Curses (or if CURSES_LIBS was set by user) + AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [ + AS_IF([test "x$CURSES_LIBS" != x], [ + LIBS="$ax_saved_LIBS $CURSES_LIBS" + ], [ + LIBS="$ax_saved_LIBS -lcurses" + ]) + + AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [ + AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])], + [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no]) + ]) + + AS_IF([test "x$ax_cv_plaincurses" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=plaincurses + AS_IF([test "x$CURSES_LIBS" = x], [ + CURSES_LIBS="-lcurses" + ]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + # Check for base conformance (and header file) + + AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + initscr(); + ]])], + [ax_cv_header_curses_h=yes], + [ax_cv_header_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_curses_h" = xyes], [ + AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if is present]) + + # Check for X/Open Enhanced conformance + + AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + @%:@ifndef _XOPEN_CURSES + @%:@error "this Curses library is not enhanced" + "this Curses library is not enhanced" + @%:@endif + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_plaincurses_enhanced=yes], + [ax_cv_plaincurses_enhanced=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + ]) + + # Check for color functions + + AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_plaincurses_color=yes], + [ax_cv_plaincurses_color=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [ + ax_cv_curses_color=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + ]) + + # Check for obsolete functions + + AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + ]])], + [ax_cv_plaincurses_obsolete=yes], + [ax_cv_plaincurses_obsolete=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [ + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + ]) + ]) + + AS_IF([test "x$ax_cv_header_curses_h" = xno], [ + AC_MSG_WARN([could not find a working curses.h]) + ]) + ]) + ]) + + AS_IF([test "x$ax_cv_curses" != xyes], [ax_cv_curses=no]) + AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no]) + AS_IF([test "x$ax_cv_curses_color" != xyes], [ax_cv_curses_color=no]) + AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no]) + + LIBS=$ax_saved_LIBS + CPPFLAGS=$ax_saved_CPPFLAGS + + unset ax_saved_LIBS + unset ax_saved_CPPFLAGS +])dnl diff --git a/m4/ax_with_curses_extra.m4 b/m4/ax_with_curses_extra.m4 new file mode 100644 index 0000000..7056d68 --- /dev/null +++ b/m4/ax_with_curses_extra.m4 @@ -0,0 +1,245 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_with_curses_extra.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_CURSES_PANEL +# AX_WITH_CURSES_MENU +# AX_WITH_CURSES_FORM +# +# DESCRIPTION +# +# These macros try to find additional libraries that often come with +# SysV-compatible Curses. In particular, the Panel, Menu and Form +# libraries are searched, along with their header files. These macros +# depend on AX_WITH_CURSES. +# +# The following preprocessor symbols may be defined by these macros: +# +# By AX_WITH_CURSES_PANEL: +# +# HAVE_PANEL - if the Panel library is present +# HAVE_PANEL_H - if is present and should be used +# HAVE_NCURSES_PANEL_H - if should be used +# HAVE_NCURSESW_PANEL_H - if should be used +# +# By AX_WITH_CURSES_MENU: +# +# HAVE_MENU - if the Menu library is present +# HAVE_MENU_H - if is present and should be used +# HAVE_NCURSES_MENU_H - if should be used +# HAVE_NCURSESW_MENU_H - if should be used +# +# By AX_WITH_CURSES_FORM: +# +# HAVE_FORM - if the Form library is present +# HAVE_FORM_H - if is present and should be used +# HAVE_NCURSES_FORM_H - if should be used +# HAVE_NCURSESW_FORM_H - if should be used +# +# The following output variables may be defined by these macros; these are +# precious and may be overridden on the ./configure command line: +# +# PANEL_LIBS - library to add to xxx_LDADD before CURSES_LIBS +# MENU_LIBS - library to add to xxx_LDADD before CURSES_LIBS +# FORM_LIBS - library to add to xxx_LDADD before CURSES_LIBS +# +# In previous versions of this macro, the flags PANEL_LIB, MENU_LIB and +# FORM_LIB were defined. These have been renamed, in keeping with the +# variable scheme of PKG_CHECK_MODULES, which should eventually supersede +# the use of AX_WITH_CURSES and AX_WITH_CURSES_* macros. These libraries +# are NOT added to LIBS by default. You need to add them to the +# appropriate xxx_LDADD line in your Makefile.am in front of the +# equivalent CURSES_LIBS incantation. For example: +# +# prog_LDADD = @PANEL_LIBS@ @CURSES_LIBS@ +# +# If one of the xxx_LIBS variables is set on the configure command line +# (such as by running "./configure PANEL_LIBS=-lmypanel"), then the header +# file searched must NOT contain a subpath. In this case, in other words, +# only would be searched for. The user may use the CPPFLAGS +# precious variable to override the standard #include search path. +# +# The following shell variables may be defined by these macros: +# +# ax_cv_panel - set to "yes" if Panels library is present +# ax_cv_menu - set to "yes" if Menu library is present +# ax_cv_form - set to "yes" if Form library is present +# +# These variables can be used in your configure.ac to determine whether a +# library you require is actually present. For example: +# +# AX_WITH_CURSES +# if test "x$ax_cv_curses" != xyes; then +# AC_MSG_ERROR([requires a SysV or X/Open-compatible Curses library]) +# fi +# AX_WITH_CURSES_PANEL +# if test "x$ax_cv_panel" != xyes; then +# AC_MSG_ERROR([requires the Curses Panel library]) +# fi +# +# To use the HAVE_xxx_H preprocessor symbols, insert the following into +# your system.h (or equivalent) header file: +# +# For AX_WITH_CURSES_PANEL: +# +# #if defined HAVE_NCURSESW_PANEL_H +# # include +# #elif defined HAVE_NCURSES_PANEL_H +# # include +# #elif defined HAVE_PANEL_H +# # include +# #else +# # error "SysV-compatible Curses Panel header file required" +# #endif +# +# For AX_WITH_CURSES_MENU: +# +# #if defined HAVE_NCURSESW_MENU_H +# # include +# #elif defined HAVE_NCURSES_MENU_H +# # include +# #elif defined HAVE_MENU_H +# # include +# #else +# # error "SysV-compatible Curses Menu header file required" +# #endif +# +# For AX_WITH_CURSES_FORM: +# +# #if defined HAVE_NCURSESW_FORM_H +# # include +# #elif defined HAVE_NCURSES_FORM_H +# # include +# #elif defined HAVE_FORM_H +# # include +# #else +# # error "SysV-compatible Curses Form header file required" +# #endif +# +# LICENSE +# +# Copyright (c) 2011 John Zaitseff +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AC_DEFUN([_AX_WITH_CURSES_CHECKEXTRA], [ + dnl Parameter 1 is the variable name component, using uppercase letters only + dnl Parameter 2 is the printable library name + dnl Parameter 3 is the C code to try compiling and linking + dnl Parameter 4 is the header filename + dnl Parameter 5 is the library command line + + AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var], [HAVE_$1])dnl + AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var], [ax_cv_[]m4_tolower($1)])dnl + AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var], [ax_cv_header_$4])dnl + AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [HAVE_[]m4_toupper($4)])dnl + + ax_saved_LIBS=$LIBS + ax_saved_CPPFLAGS=$CPPFLAGS + + AC_CACHE_CHECK([for Curses $2 library with $4], [_AX_WITH_CURSES_CHECKEXTRA_header_var], [ + LIBS="$ax_saved_LIBS $5 $CURSES_LIBS" + CPPFLAGS="$ax_saved_CPPFLAGS $CURSES_CFLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include <$4> + ]], [$3])], + [_AX_WITH_CURSES_CHECKEXTRA_header_var=yes], + [_AX_WITH_CURSES_CHECKEXTRA_header_var=no]) + ]) + AS_IF([test "x$[]_AX_WITH_CURSES_CHECKEXTRA_header_var" = xyes], [ + _AX_WITH_CURSES_CHECKEXTRA_cv_var=yes + AS_LITERAL_IF([$5], [$1_LIBS="$5"]) + AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_var], [1], [Define to 1 if the Curses $2 library is present]) + AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [1], [Define to 1 if <$4> is present]) + ], [ + AS_IF([test "x$[]_AX_WITH_CURSES_CHECKEXTRA_cv_var" = xyes], [], + [_AX_WITH_CURSES_CHECKEXTRA_cv_var=no]) + ]) + + LIBS=$ax_saved_LIBS + CPPFLAGS=$ax_saved_CPPFLAGS + unset ax_saved_LIBS + unset ax_saved_CPPFLAGS + + AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var])dnl + AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var])dnl + AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var])dnl + AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var])dnl +])dnl + +AC_DEFUN([_AX_WITH_CURSES_EXTRA], [ + dnl Parameter 1 is the variable name component, using uppercase letters only + dnl Parameter 2 is the printable library name + dnl Parameter 3 is the C code to try compiling and linking + dnl Parameter 4 is the header filename component + dnl Parameter 5 is the NCursesW library command line + dnl Parameter 6 is the NCurses library command line + dnl Parameter 7 is the plain Curses library command line + + AC_REQUIRE([AX_WITH_CURSES]) + AC_ARG_VAR([$1_LIBS], [linker library for Curses $2, e.g. $7]) + + AS_IF([test "x$[]$1_LIBS" != x], [ + _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$[]$1_LIBS]) + ], [ + AS_IF([test "x$ax_cv_curses_which" = xncursesw], [ + _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncursesw/$4], [$5]) + ], [test "x$ax_cv_curses_which" = xncurses], [ + _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$6]) + AS_IF([test x$[]ax_cv_[]m4_tolower($1) != "xyes"], [ + _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncurses/$4], [$6]) + ]) + ], [test "x$ax_cv_curses_which" = xplaincurses], [ + _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$7]) + ]) + ]) +])dnl + +AC_DEFUN([AX_WITH_CURSES_PANEL], [ + _AX_WITH_CURSES_EXTRA([PANEL], [Panel], [[ + WINDOW *win = newwin(0, 0, 0, 0); + PANEL *pan = new_panel(win); + ]], [panel.h], [-lpanelw], [-lpanel], [-lpanel]) +])dnl + +AC_DEFUN([AX_WITH_CURSES_MENU], [ + _AX_WITH_CURSES_EXTRA([MENU], [Menu], [[ + ITEM **mi; + MENU *m = new_menu(mi); + ]], [menu.h], [-lmenuw], [-lmenu], [-lmenu]) +])dnl + +AC_DEFUN([AX_WITH_CURSES_FORM], [ + _AX_WITH_CURSES_EXTRA([FORM], [Form], [[ + FIELD **ff; + FORM *f = new_form(ff); + ]], [form.h], [-lformw], [-lform], [-lform]) +])dnl diff --git a/m4/ctng_gperf.m4 b/m4/ctng_gperf.m4 index 0ec1a0e..3873028 100644 --- a/m4/ctng_gperf.m4 +++ b/m4/ctng_gperf.m4 @@ -1,5 +1,4 @@ # Check for GNU perf location and the type it uses in the prototypes -# FIXME: remove AC_SUBST after switching to using autoheader AC_DEFUN([CTNG_PROG_GPERF], [AX_REQUIRE_DEFINED([CTNG_CHECK_TOOL_REQ]) CTNG_CHECK_TOOL_REQ([GPERF], [gperf], [gperf]) @@ -19,5 +18,4 @@ _ASEOF [AC_MSG_ERROR([unable to determine gperf len type])]) rm -f conftest.gperf.c AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], $GPERF_LEN_TYPE, [String length type used by gperf]) - AC_SUBST([GPERF_LEN_TYPE]) ]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 new file mode 100644 index 0000000..eef5073 --- /dev/null +++ b/m4/gettext.m4 @@ -0,0 +1,420 @@ +# gettext.m4 serial 68 (gettext-0.19.8) +dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2006, 2008-2010. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value '$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], + [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define([gt_included_intl], + ifelse([$1], [external], + ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), + [yes])) + define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) + gt_NEEDS_INIT + AM_GNU_GETTEXT_NEED([$2]) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. + gt_INTL_MACOSX + + dnl Set USE_NLS. + AC_REQUIRE([AM_NLS]) + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl Add a version number to the cache macros. + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH([included-gettext], + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings; +#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) +#else +#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 +#endif +$gt_revision_test_code + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION + ]])], + [eval "$gt_func_gnugettext_libc=yes"], + [eval "$gt_func_gnugettext_libc=no"])]) + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + [$gt_func_gnugettext_libintl], + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); +#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) +#else +#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 +#endif +$gt_revision_test_code + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION + ]])], + [eval "$gt_func_gnugettext_libintl=yes"], + [eval "$gt_func_gnugettext_libintl=no"]) + dnl Now see whether libintl exists and depends on libiconv. + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); +#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) +#else +#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 +#endif +$gt_revision_test_code + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION + ]])], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + CATOBJEXT= + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Some extra flags are needed during linking. + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE([ENABLE_NLS], [1], + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE([HAVE_GETTEXT], [1], + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE([HAVE_DCGETTEXT], [1], + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST([BUILD_INCLUDED_LIBINTL]) + AC_SUBST([USE_INCLUDED_LIBINTL]) + AC_SUBST([CATOBJEXT]) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST([DATADIRNAME]) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST([INSTOBJEXT]) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST([GENCAT]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLOBJS= + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST([INTLOBJS]) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST([INTLLIBS]) + + dnl Make all documented variables known to autoconf. + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + AC_SUBST([POSUB]) +]) + + +dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. +m4_define([gt_NEEDS_INIT], +[ + m4_divert_text([DEFAULTS], [gt_needs=]) + m4_define([gt_NEEDS_INIT], []) +]) + + +dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) +AC_DEFUN([AM_GNU_GETTEXT_NEED], +[ + m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) + + +dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) diff --git a/m4/iconv.m4 b/m4/iconv.m4 new file mode 100644 index 0000000..aa159c5 --- /dev/null +++ b/m4/iconv.m4 @@ -0,0 +1,271 @@ +# iconv.m4 serial 19 (gettext-0.18.2) +dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, + dnl Solaris 10. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + am_cv_func_iconv_works=no + for ac_iconv_const in '' 'const'; do + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include + +#ifndef ICONV_CONST +# define ICONV_CONST $ac_iconv_const +#endif + ]], + [[int result = 0; + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 1; + iconv_close (cd_utf8_to_88591); + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\263"; + char buf[10]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + result |= 2; + iconv_close (cd_ascii_to_88591); + } + } + /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + ICONV_CONST char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) + result |= 4; + iconv_close (cd_88591_to_utf8); + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + ICONV_CONST char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + result |= 8; + iconv_close (cd_88591_to_utf8); + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + result |= 16; + return result; +]])], + [am_cv_func_iconv_works=yes], , + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + test "$am_cv_func_iconv_works" = no || break + done + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [m4_ifdef([gl_00GNULIB], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])])) +gl_iconv_AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif + ]], + [[]])], + [am_cv_proto_iconv_arg1=""], + [am_cv_proto_iconv_arg1="const"]) + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + dnl Also substitute ICONV_CONST in the gnulib generated . + m4_ifdef([gl_ICONV_H_DEFAULTS], + [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) + if test -n "$am_cv_proto_iconv_arg1"; then + ICONV_CONST="const" + fi + ]) + fi +]) diff --git a/m4/intlmacosx.m4 b/m4/intlmacosx.m4 new file mode 100644 index 0000000..aca924c --- /dev/null +++ b/m4/intlmacosx.m4 @@ -0,0 +1,56 @@ +# intlmacosx.m4 serial 5 (gettext-0.18.2) +dnl Copyright (C) 2004-2014, 2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Checks for special options needed on Mac OS X. +dnl Defines INTL_MACOSX_LIBS. +AC_DEFUN([gt_INTL_MACOSX], +[ + dnl Check for API introduced in Mac OS X 10.2. + AC_CACHE_CHECK([for CFPreferencesCopyAppValue], + [gt_cv_func_CFPreferencesCopyAppValue], + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[CFPreferencesCopyAppValue(NULL, NULL)]])], + [gt_cv_func_CFPreferencesCopyAppValue=yes], + [gt_cv_func_CFPreferencesCopyAppValue=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], + [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) + fi + dnl Check for API introduced in Mac OS X 10.3. + AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[CFLocaleCopyCurrent();]])], + [gt_cv_func_CFLocaleCopyCurrent=yes], + [gt_cv_func_CFLocaleCopyCurrent=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], + [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([INTL_MACOSX_LIBS]) +]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 new file mode 100644 index 0000000..6209de6 --- /dev/null +++ b/m4/lib-ld.m4 @@ -0,0 +1,119 @@ +# lib-ld.m4 serial 6 +dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid +dnl collision with libtool.m4. + +dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 /dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` + while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL([acl_cv_path_LD], +[if test -z "$LD"; then + acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$acl_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. + m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl Autoconf >= 2.61 supports dots in --with options. + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH(P_A_C_K[-prefix], +[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib + --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([P_A_C_K]) + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 new file mode 100644 index 0000000..6851031 --- /dev/null +++ b/m4/lib-prefix.m4 @@ -0,0 +1,224 @@ +# lib-prefix.m4 serial 7 (gettext-0.18) +dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_EGREP_CPP([sixtyfour bits], [ +#ifdef _LP64 +sixtyfour bits +#endif + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) + ]) + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" +]) diff --git a/m4/nls.m4 b/m4/nls.m4 new file mode 100644 index 0000000..afdb9ca --- /dev/null +++ b/m4/nls.m4 @@ -0,0 +1,32 @@ +# nls.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016 Free Software +dnl Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ([2.50]) + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE([nls], + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT([$USE_NLS]) + AC_SUBST([USE_NLS]) +]) diff --git a/m4/pkg.m4 b/m4/pkg.m4 new file mode 100644 index 0000000..13a8890 --- /dev/null +++ b/m4/pkg.m4 @@ -0,0 +1,275 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $2]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR diff --git a/m4/po.m4 b/m4/po.m4 new file mode 100644 index 0000000..f205061 --- /dev/null +++ b/m4/po.m4 @@ -0,0 +1,6 @@ +# po.m4 serial 24 +dnl Dummy version of po.m4 from gettext. Crosstool-NG currently doesn't have +dnl any localications for kconfig (and if we decide to, we'd need much more than +dnl that). So ignore PO_SUBDIRS and any possible dependencies the real po.m4 would +dnl have pulled in. +AC_DEFUN([AM_PO_SUBDIRS], []) diff --git a/m4/progtest.m4 b/m4/progtest.m4 new file mode 100644 index 0000000..9ace7c3 --- /dev/null +++ b/m4/progtest.m4 @@ -0,0 +1,91 @@ +# progtest.m4 serial 7 (gettext-0.18.2) +dnl Copyright (C) 1996-2003, 2005, 2008-2016 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +AC_PREREQ([2.50]) + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL([ac_cv_path_$1], +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$][$1]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST([$1])dnl +]) diff --git a/scripts/config.rpath b/scripts/config.rpath new file mode 100644 index 0000000..1b83ae0 --- /dev/null +++ b/scripts/config.rpath @@ -0,0 +1,2 @@ +# Dummy file for gettext dependencies +: -- cgit v0.10.2-6-g49f6 From 1ce2eab963a004ba352a5cea800e2765a7c6affd Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 7 Jan 2018 23:44:19 -0800 Subject: Simplify the macro for checking stat flavor a bit Signed-off-by: Alexey Neyman diff --git a/configure.ac b/configure.ac index 4889439..8fa0e33 100644 --- a/configure.ac +++ b/configure.ac @@ -139,15 +139,13 @@ AC_CHECK_PROGS([curl], [curl]) CTNG_SET_KCONFIG_OPTION([curl]) AC_SUBST([curl]) -# TBD move the checks/setting kconfig into [IF-BSD] and [IF-GNU] arguments to CTNG_PROG_STAT -# TBD modify CTNG_SET_KCONFIG_OPTION to take an optional argument to which it should be set -CTNG_PROG_STAT -# FIXME: support SET_KCONFIG_OPTION with string values? But then -# again, these checks may be moved into ct-ng script. -test "$acx_cv_stat_flavor" = "BSD" && stat_flavor_BSD=y -CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD]) -test "$acx_cv_stat_flavor" = "GNU" && stat_flavor_GNU=y -CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU]) +CTNG_PROG_STAT( + [CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU], [y]) + CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD]) + ], + [CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD], [y]) + CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU]) + ]) CTNG_CPU_COUNT diff --git a/m4/ctng_prog_stat.m4 b/m4/ctng_prog_stat.m4 index f7de93e..5db3469 100644 --- a/m4/ctng_prog_stat.m4 +++ b/m4/ctng_prog_stat.m4 @@ -1,5 +1,7 @@ # Check that stat(1) is present and determine the syntax for the format -# string (BSD or GNU). +# string (BSD or GNU). Defines ac_cv_stat_flavor to either GNU or BSD; +# and evaluates either IF-GNU or IF-BSD expression. +# CTNG_PROG_STAT([IF-GNU], [IF-BSD]) AC_DEFUN([CTNG_PROG_STAT], [AX_REQUIRE_DEFINED([CTNG_CHECK_PROGS_REQ]) CTNG_CHECK_PROGS_REQ([stat], [stat]) @@ -11,8 +13,12 @@ AC_DEFUN([CTNG_PROG_STAT], attr_gnu=$(stat -c '%a' conftest 2>/dev/null) rm -f conftest AS_IF([test "$attr_bsd" = "642"], - [acx_cv_stat_flavor=BSD], + [acx_cv_stat_flavor=BSD + $2 + ], [test "$attr_gnu" = "642"], - [acx_cv_stat_flavor=GNU], + [acx_cv_stat_flavor=GNU + $1 + ], [AC_MSG_ERROR([cannot determine stat(1) format option])])]) ]) diff --git a/m4/ctng_set_kconfig_option.m4 b/m4/ctng_set_kconfig_option.m4 index 9fae320..2c2968c 100644 --- a/m4/ctng_set_kconfig_option.m4 +++ b/m4/ctng_set_kconfig_option.m4 @@ -1,7 +1,7 @@ # Set the kconfig option. AC_DEFUN([CTNG_SET_KCONFIG_OPTION], [AS_IF( - [test -n "$$1"], + [test -n "$$1" -o "$2" = "y"], [AC_SUBST([KCONFIG_$1], ["def_bool y"])], [AC_SUBST([KCONFIG_$1], ["bool"])]) ]) -- cgit v0.10.2-6-g49f6 From d401afbddaae56093cce388e62f7ba4d9d68a327 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 5 Oct 2017 00:09:22 -0700 Subject: Get rid of sub{lib,doc}dir They don't make sense - using same ct-ng won't work with different versions, so they cannot coexist in the same prefix. Also localize other configure variables so that their usage is easier to track. Signed-off-by: Alexey Neyman diff --git a/Makefile.in b/Makefile.in index 2ac93ac..121df11 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,11 +57,11 @@ export PACKAGE_TARNAME := @PACKAGE_TARNAME@ export VERSION := @PACKAGE_VERSION@ export prefix := @prefix@ export exec_prefix := @exec_prefix@ +export datarootdir := @datarootdir@ export bindir := @bindir@ -export libdir := @libdir@@sublibdir@ -export docdir := @docdir@@subdocdir@ +export libdir := @libdir@ +export docdir := @docdir@ export mandir := @mandir@ -export datarootdir := @datarootdir@ export install := @INSTALL@ export bash := @BASH_SHELL@ export awk := @AWK@ @@ -77,16 +77,6 @@ export objdump := @OBJDUMP@ export readelf := @READELF@ export patch := @PATCH@ export gperf := @GPERF@ -export gperf_len_type := @GPERF_LEN_TYPE@ -export CC := @CC@ -export CPP := @CPP@ -export CPPFLAGS := @CPPFLAGS@ -export CFLAGS := @CFLAGS@ -export LDFLAGS := @LDFLAGS@ -export LIBS := @LIBS@ -export INTL_LIBS := @INTL_LIBS@ -export curses_hdr := @ac_ct_curses_hdr@ -export gettext := @gettext@ export CPU_COUNT := @CPU_COUNT@ ############################################################################### diff --git a/configure.ac b/configure.ac index 8fa0e33..72198d1 100644 --- a/configure.ac +++ b/configure.ac @@ -301,9 +301,11 @@ AS_IF( [test -f version.sh -a -x version.sh], [PACKAGE_VERSION=$(./version.sh "${PACKAGE_VERSION}")]) +# We are not installing dynamic libraries that need to be found by dynamic linker. +# Install into a subdirectory. +libdir=${libdir}/${PACKAGE_TARNAME} + # Handle the local case -AC_SUBST([sublibdir]) -AC_SUBST([subdocdir]) AS_IF( [test "x$enable_local" = "xyes"], [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set]) @@ -311,13 +313,9 @@ AS_IF( exec_prefix="$prefix" bindir="$prefix" libdir="$prefix" - sublibdir="" docdir="$prefix""/docs" - subdocdir="" datarootdir="$prefix" - mandir="$docdir"], - [sublibdir="/\${VERSION}" - subdocdir="/\${VERSION}"]) + mandir="$docdir"]) AC_CONFIG_FILES([ Makefile diff --git a/ct-ng.in b/ct-ng.in index a61637b..a8ad09d 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -90,7 +90,11 @@ help-distrib:: help-env:: @echo - @echo 'Environment variables (see @@CT_DOCDIR@@/0 - Table of content.txt):' + @if [ -r "@@CT_DOCDIR@@/manual/4_Building.md" ]; then \ + echo 'Environment variables (see @@CT_DOCDIR@@/0 - Table of content.txt):'; \ + else \ + echo 'Environment variables (see http://crosstool-ng.github.io/docs/build/)'; \ + fi help-tail:: @echo diff --git a/kconfig/Makefile.in b/kconfig/Makefile.in index 630ac14..26a4404 100644 --- a/kconfig/Makefile.in +++ b/kconfig/Makefile.in @@ -2,6 +2,18 @@ # Hmmm! Cheesy build! # Or: where I can unveil my make-fu... :-] +install = @INSTALL@ +sed = @SED@ +gperf = @GPERF@ +gperf_len_type = @GPERF_LEN_TYPE@ +gettext = @gettext@ +curses_hdr = @ac_ct_curses_hdr@ +CC = @CC@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +INTL_LIBS = @INTL_LIBS@ + __silent = $(if $(V),,@printf ' %-7s %s\n' '$1' '$(if $2,$2,$(strip $<))' && ) __silent_rm = $(call __silent,RM,$1)rm -f $1 @@ -103,10 +115,10 @@ conf: $(COMMON_OBJ) $(conf_OBJ) install: $(patsubst %,install-%,$(PROGS)) install-kconfig.mk $(patsubst %,install-%,$(PROGS)): install-%: % - $(call __silent,INSTALL,$<)install -m 0755 $< $(DESTDIR)/$< + $(call __silent,INSTALL,$<)$(install) -m 0755 $< $(DESTDIR)/$< install-kconfig.mk: kconfig.mk - $(call __silent,INSTALL,$<)install -m 0644 $< $(DESTDIR)/$< + $(call __silent,INSTALL,$<)$(install) -m 0644 $< $(DESTDIR)/$< #----------------------------------------------------------- # Cleaning up the mess... -- cgit v0.10.2-6-g49f6 From 576dcc3fee5b949cbf439fd95ab642dfcfe51a74 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 8 Jan 2018 17:06:30 -0800 Subject: Remove special handling of dpkg-buildflags Instead, just honor CFLAGS/CPPFLAGS/LDFLAGS as they're passed down from configure. This brings the build process in compliance with the recommended practices. Signed-off-by: Alexey Neyman diff --git a/configure.ac b/configure.ac index 72198d1..7913aa0 100644 --- a/configure.ac +++ b/configure.ac @@ -235,8 +235,6 @@ CTNG_SET_KCONFIG_OPTION([svn]) AC_CHECK_PROGS([git], [git]) CTNG_SET_KCONFIG_OPTION([git]) -AC_CHECK_PROGS([DPKG_BUILDFLAGS], [dpkg-buildflags]) - # FIXME why checking if not using the result? We don't provide replacemant malloc/alloca/... AC_C_INLINE AC_HEADER_STDC diff --git a/kconfig/Makefile.in b/kconfig/Makefile.in index 26a4404..71157d6 100644 --- a/kconfig/Makefile.in +++ b/kconfig/Makefile.in @@ -5,15 +5,10 @@ install = @INSTALL@ sed = @SED@ gperf = @GPERF@ -gperf_len_type = @GPERF_LEN_TYPE@ -gettext = @gettext@ -curses_hdr = @ac_ct_curses_hdr@ CC = @CC@ -CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -INTL_LIBS = @INTL_LIBS@ +V=1 __silent = $(if $(V),,@printf ' %-7s %s\n' '$1' '$(if $2,$2,$(strip $<))' && ) __silent_rm = $(call __silent,RM,$1)rm -f $1 @@ -27,12 +22,6 @@ CFLAGS = --include @top_builddir@/config.h -DCONFIG_=\"CT_\" \ @CFLAGS@ @CPPFLAGS@ LDFLAGS = @LDFLAGS@ @LIBINTL@ -ifneq (@DPKG_BUILDFLAGS@,) -CFLAGS += $(shell @DPKG_BUILDFLAGS@ --get CPPFLAGS) \ - $(shell @DPKG_BUILDFLAGS@ --get CFLAGS) -LDFLAGS += $(shell @DPKG_BUILDFLAGS@ --get LDFLAGS) -endif - # Compiler flags to use gettext ifneq (@USE_NLS@,yes) CFLAGS += -Wno-format-security -DKBUILD_NO_NLS -- cgit v0.10.2-6-g49f6 From 9238b587210c53ba51dd665ffb9ff3e13456880f Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 4 Feb 2018 23:39:01 -0800 Subject: WIP: autotoolization Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index bea75da..d8a8f32 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ config.h* config.log config.status /Makefile +/Makefile.in *ct-ng* !ct-ng.comp !ct-ng.in diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..8e25898 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,4 @@ +## Process this file with automake to produce Makefile.in +## vim: set noet : + +SUBDIRS = kconfig diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index 121df11..0000000 --- a/Makefile.in +++ /dev/null @@ -1,354 +0,0 @@ -# Makefile.in for building crosstool-NG -# This file serves as source for the ./configure operation - -# This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS -# to set additional flags in the current Makfile ( see: -# http://savannah.gnu.org/bugs/?20501 ), although the make manual says it -# should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion ) -# so we have to work it around by calling ourselves back if needed - -# So why do we need not to use the built rules and variables? Because we -# need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in -# and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite -# nor a command associated, and that built-in implicit rule takes precedence -# over our non-built-in implicit rule '%: %.in', below. - -# CT_MAKEFLAGS will be used later, below... - -# Do not print directories as we descend into them -ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),) -CT_MAKEFLAGS += --no-print-directory -endif - -# Use neither builtin rules, nor builtin variables -# Note: dual test, because if -R and -r are given on the command line -# (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding -# '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' ) -# Further: quad test because the flags 'rR' and '-rR' can be reordered. -ifeq ($(filter Rr,$(MAKEFLAGS)),) -ifeq ($(filter -Rr,$(MAKEFLAGS)),) -ifeq ($(filter rR,$(MAKEFLAGS)),) -ifeq ($(filter -rR,$(MAKEFLAGS)),) -CT_MAKEFLAGS += -Rr -endif # No -rR -endif # No rR -endif # No -Rr -endif # No Rr - -# Helper: print abbreviation of the command by default, or full command -# if doing 'make V=1'. -__silent = $(if $(V),,@printf ' %-7s %s\n' '$1' '$(if $2,$2,$(strip $<))' && ) -__silent_rm = $(call __silent,RM,$1)rm -f $1 -__silent_rmdir = $(call __silent,RMDIR,$1)rm -rf $1 - -# Remove any suffix rules -.SUFFIXES: - -all: configure Makefile build - -############################################################################### -# Configuration variables - -# Stuff found by ./configure -export DATE := @DATE@ -export LOCAL := @enable_local@ -export PROG_SED := @program_transform_name@ -export PACKAGE_TARNAME := @PACKAGE_TARNAME@ -export VERSION := @PACKAGE_VERSION@ -export prefix := @prefix@ -export exec_prefix := @exec_prefix@ -export datarootdir := @datarootdir@ -export bindir := @bindir@ -export libdir := @libdir@ -export docdir := @docdir@ -export mandir := @mandir@ -export install := @INSTALL@ -export bash := @BASH_SHELL@ -export awk := @AWK@ -export grep := @GREP@ -export make := @MAKE@ -export sed := @SED@ -export wget := @wget@ -export curl := @curl@ -export libtool := @LIBTOOL@ -export libtoolize := @LIBTOOLIZE@ -export objcopy := @OBJCOPY@ -export objdump := @OBJDUMP@ -export readelf := @READELF@ -export patch := @PATCH@ -export gperf := @GPERF@ -export CPU_COUNT := @CPU_COUNT@ - -############################################################################### -# Non-configure variables -MAN_SECTION := 1 -MAN_SUBDIR := /man$(MAN_SECTION) - -PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' ) - -############################################################################### -# Sanity checks - -# Check if Makefile is up to date: -Makefile: Makefile.in - @echo "$< changed: you must re-run './configure'" - @false - -configure: configure.ac - @echo "$< changed: you must re-run './bootstrap'" - @false - -# If installing with DESTDIR, check it's an absolute path -ifneq ($(strip $(DESTDIR)),) - ifneq ($(DESTDIR),$(abspath /$(DESTDIR))) - $(error DESTDIR is not an absolute PATH: '$(DESTDIR)') - endif -endif - -############################################################################### -# Global make rules - -# If any extra MAKEFLAGS were added, re-run ourselves -# See top of file for an explanation of why this is needed... -ifneq ($(strip $(CT_MAKEFLAGS)),) - -# Somehow, the new auto-completion for make in the recent distributions -# trigger a behavior where our Makefile calls itself recursively, in a -# never-ending loop (except on lack of ressources, swap, PIDs...) -# Avoid this situation by cutting the recursion short at the first -# level. -# This has the side effect of only showing the real targets, and hiding our -# internal ones. :-) -ifneq ($(MAKELEVEL),0) -$(error Recursion detected, bailing out...) -endif - -MAKEFLAGS += $(CT_MAKEFLAGS) -build install clean distclean mrproper uninstall: - @$(MAKE) $@ - -else -# There were no additional MAKEFLAGS to add, do the job - -TARGETS := bin lib lib-kconfig doc man - -build: $(patsubst %,build-%,$(TARGETS)) - -install: build real-install - -clean: $(patsubst %,clean-%,$(TARGETS)) - -distclean: clean - $(call __silent_rm,Makefile kconfig/Makefile config/configure.in) - -mrproper: distclean - $(call __silent_rmdir,autom4te.cache config/gen config/versions) - $(call __silent_rm,config.log config.status configure) - -uninstall: real-uninstall - -############################################################################### -# Specific make rules - -#-------------------------------------- -# Build rules - -build-bin: $(PROG_NAME) \ - scripts/scripts.mk \ - scripts/crosstool-NG.sh \ - scripts/saveSample.sh - -build-lib: paths.mk \ - paths.sh - -build-lib-kconfig: - $(call __silent,ENTER,kconfig)$(MAKE) -C kconfig - $(call __silent,LEAVE,kconfig): - -build-doc: - -build-man: docs/$(PROG_NAME).1.gz - -docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1 - $(call __silent,GZIP)gzip -c9n $< >$@ - -define sed_it - $(call __silent,SED,$@)$(sed) -r \ - -e 's,@@CT_BINDIR@@,$(bindir),g;' \ - -e 's,@@CT_LIBDIR@@,$(libdir),g;' \ - -e 's,@@CT_DOCDIR@@,$(docdir),g;' \ - -e 's,@@CT_MANDIR@@,$(mandir),g;' \ - -e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \ - -e 's,@@CT_VERSION@@,$(VERSION),g;' \ - -e 's,@@CT_DATE@@,$(DATE),g;' \ - -e 's,@@CT_make@@,$(make),g;' \ - -e 's,@@CT_bash@@,$(bash),g;' \ - -e 's,@@CT_awk@@,$(awk),g;' \ - -e 's,@@CT_wget@@,$(wget),g;' \ - -e 's,@@CT_curl@@,$(curl),g;' \ - -e 's,@@CT_cpucount@@,$(CPU_COUNT),g;' \ - $< >$@ -endef - -docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile - $(call sed_it) - -$(PROG_NAME): ct-ng.in Makefile - $(call sed_it) - $(call __silent,CHMOD,$@)chmod 755 $@ - -%: %.in Makefile - $(call sed_it) - -__paths_vars = install bash awk grep make sed libtool \ - libtoolize objcopy objdump readelf patch gperf - -# We create a script fragment that is parseable from inside a Makefile, -# and one from inside a shell script. -paths.mk: FORCE - $(call __silent,GEN,$@){ $(foreach w,$(__paths_vars),$(if $($w),echo 'export $w=$(subst ','\'',$($w))';)) :; } >$@ - -paths.sh: FORCE - $(call __silent,GEN,$@){ $(foreach w,$(__paths_vars),$(if $($w),echo 'export $w="$(subst ','\'',$($w))"';)) :; } >$@ - -FORCE: - -#-------------------------------------- -# Clean rules - -clean-bin: - $(call __silent_rm,$(PROG_NAME)) - $(call __silent_rm,scripts/scripts.mk) - $(call __silent_rm,scripts/crosstool-NG.sh) - $(call __silent_rm,scripts/saveSample.sh) - -clean-lib: - $(call __silent_rm,paths.mk paths.sh) - -clean-lib-kconfig: - $(call __silent,ENTER,kconfig)$(MAKE) -C kconfig clean - $(call __silent,LEAVE,kconfig): - -clean-doc: - -clean-man: - $(call __silent_rm,docs/$(PROG_NAME).1) - $(call __silent_rm,docs/$(PROG_NAME).1.gz) - -#-------------------------------------- -# Check for --local setup - -ifeq ($(strip $(LOCAL)),yes) - -real-install: - @true - -real-uninstall: - @true - -else - -#-------------------------------------- -# Install rules - -real-install: $(patsubst %,install-%,$(TARGETS)) install-post - -install-bin: $(DESTDIR)$(bindir) - $(call __silent,INST,$(PROG_NAME))$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)" - -# If one is hacking crosstool-NG, the patch set might change between any two -# installations of the same VERSION, thus the patches must be removed prior -# to being installed. It is the responsibility of the user to call uninstall -# first, if (s)he deems it necessary -install-lib: $(DESTDIR)$(libdir) \ - install-lib-main \ - install-lib-samples - -LIB_SUB_DIR := config contrib packages scripts -$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): install-lib-%-copy: $(DESTDIR)$(libdir) - $(call __silent,INSTDIR,$*)tar cf - --exclude='*.sh.in' --exclude='*.in.in' --exclude=.gitignore $* \ - |(cd "$(DESTDIR)$(libdir)"; tar xf -) - -# Dependency-only by default. -$(patsubst %,install-lib-%,$(LIB_SUB_DIR)): install-lib-%: install-lib-%-copy - -install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR)) - $(call __silent,INST,steps.mk)$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)" - $(call __silent,INST,paths.mk)$(install) -m 644 paths.mk "$(DESTDIR)$(libdir)" - $(call __silent,INST,paths.sh)$(install) -m 644 paths.sh "$(DESTDIR)$(libdir)" - -# Samples need a little love: -# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR -install-lib-samples: $(DESTDIR)$(libdir) install-lib-main - $(call __silent,INSTDIR,samples)for samp_dir in samples/*/; do \ - mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \ - $(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \ - -e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \ - $${samp_dir}/crosstool.config \ - >"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \ - $(install) -m 644 "$${samp_dir}/reported.by" \ - "$(DESTDIR)$(libdir)/$${samp_dir}"; \ - for libc_cfg in "$${samp_dir}/"*libc*.config; do \ - [ -f "$${libc_cfg}" ] || continue; \ - $(install) -m 644 "$${libc_cfg}" \ - "$(DESTDIR)$(libdir)/$${samp_dir}"; \ - done; \ - [ -e "$${samp_dir}/broken" ] && \ - $(install) -m 644 "$${samp_dir}/broken" \ - "$(DESTDIR)$(libdir)/$${samp_dir}/" || :; \ - done - @$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk" - -install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main - $(call __silent,MKDIR,$@)$(install) -m 755 -d "$(DESTDIR)$(libdir)/kconfig" - $(call __silent,ENTER,kconfig)$(MAKE) -C kconfig install \ - DESTDIR=$(DESTDIR)$(libdir)/kconfig - $(call __silent,LEAVE,kconfig): - -install-doc: install-doc-$(if $(wildcard docs/MANUAL_ONLINE),message,real) - -install-doc-message: - @echo "********************************************************************" - @echo " You are building from a development version that does not include" - @echo " the documentation. Refer to the manual online at:" - @echo " http://crosstool-ng.github.io/docs" - @echo "********************************************************************" - -install-doc-real: $(DESTDIR)$(docdir) - $(call __silent,INST,docs)for doc_file in docs/manual/*.md; do \ - $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \ - done - -install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR) - $(call __silent,INST,$(PROG_NAME).1.gz)$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)" - -$(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)): - $(call __silent,MKDIR,$@)$(install) -m 755 -d "$@" - -install-post: - @echo - @echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into" - @echo "your bash completion directory (usually /etc/bash_completion.d)" - -#-------------------------------------- -# Uninstall rules - -real-uninstall: $(patsubst %,uninstall-%,$(filter-out lib-kconfig,$(TARGETS))) - -uninstall-bin: - $(call __silent_rm,$(DESTDIR)$(bindir)/$(PROG_NAME)) - -uninstall-lib: - $(call __silent_rmdir,$(DESTDIR)$(libdir)) - -uninstall-doc: - $(call __silent_rmdir,$(DESTDIR)$(docdir)) - -uninstall-man: - $(call __silent_rm,$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz) - -endif # Not --local - -endif # No extra MAKEFLAGS were added - -.PHONY: build $(patsubst %,build-%,$(TARGETS)) install diff --git a/config/comp_tools/autoconf.in b/config/comp_tools/autoconf.in index b84d587..1232782 100644 --- a/config/comp_tools/autoconf.in +++ b/config/comp_tools/autoconf.in @@ -1,5 +1,5 @@ # Autoconf -## default y if !CONFIGURE_has_autoconf_2_63_or_newer -## default y if !CONFIGURE_has_autoreconf_2_63_or_newer +## default y if !CONFIGURE_has_autoconf_2_65_or_newer +## default y if !CONFIGURE_has_autoreconf_2_65_or_newer ## help Autoconf diff --git a/config/configure.in.in b/config/configure.in.in index 3560336..c8003a0 100644 --- a/config/configure.in.in +++ b/config/configure.in.in @@ -24,11 +24,11 @@ config CONFIGURE_has_libtool_2_4_or_newer config CONFIGURE_has_libtoolize_2_4_or_newer @KCONFIG_libtoolize_2_4_or_newer@ -config CONFIGURE_has_autoconf_2_63_or_newer - @KCONFIG_autoconf_2_63_or_newer@ +config CONFIGURE_has_autoconf_2_65_or_newer + @KCONFIG_autoconf_2_65_or_newer@ -config CONFIGURE_has_autoreconf_2_63_or_newer - @KCONFIG_autoreconf_2_63_or_newer@ +config CONFIGURE_has_autoreconf_2_65_or_newer + @KCONFIG_autoreconf_2_65_or_newer@ config CONFIGURE_has_automake_1_15_or_newer @KCONFIG_automake_1_15_or_newer@ diff --git a/configure.ac b/configure.ac index 7913aa0..e3ca4ae 100644 --- a/configure.ac +++ b/configure.ac @@ -7,28 +7,15 @@ AC_PREREQ([2.67]) # TBD need to quote sed expression AC_INIT( [crosstool-NG], - [m4_esyscmd_s([git describe --always --dirty])], + [m4_esyscmd_s([git describe --always --dirty | sed s,^crosstool-ng-,,])], [crossgcc@sourceware.org], [crosstool-ng], [http://crosstool-ng.org]) AC_CONFIG_AUX_DIR([scripts]) AC_CONFIG_MACRO_DIR([m4]) -# Check if install(1) supports --strip-program=... -AC_DEFUN( - [ACX_INSTALL_STRIP_PROGRAM], - [touch conftest - mkdir conftest.dir - AC_MSG_CHECKING([if install takes --strip-program option]) - AS_IF([$INSTALL --strip-program=true -s conftest conftest.dir/conftest 2>/dev/null], - [install_with_strip_program=y - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - ACX_SET_KCONFIG_OPTION([install_with_strip_program]) - rm -rf conftest.dir - rm -f conftest - ]) - +# TBD try to use gnu strictness? Just add the missing files? +AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2]) #-------------------------------------------------------------------- # Allow dummy --{en,dis}able-{static,shared} @@ -51,6 +38,21 @@ AC_ARG_ENABLE( [--enable-static], [build static libraries (deprecated, ignored)])]) +# Check if install(1) supports --strip-program=... +AC_DEFUN( + [ACX_INSTALL_STRIP_PROGRAM], + [touch conftest + mkdir conftest.dir + AC_MSG_CHECKING([if install takes --strip-program option]) + AS_IF([$INSTALL --strip-program=true -s conftest conftest.dir/conftest 2>/dev/null], + [install_with_strip_program=y + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + ACX_SET_KCONFIG_OPTION([install_with_strip_program]) + rm -rf conftest.dir + rm -f conftest + ]) + # Check for --build and --host... AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -179,7 +181,7 @@ CTNG_PROG_VERSION_REQ_ANY([MAKE], ['^GNU Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)'], [make_3_81_or_newer]) -# Check other companion tools that we may or may not build +# Check other companion tools that we may or may not build. CTNG_PROG_VERSION([LIBTOOL], [GNU libtool >= 2.4], [libtool], @@ -199,14 +201,14 @@ CTNG_PROG_VERSION([AUTOCONF], [autoconf], [autoconf], ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[5-9])'], - [autoconf_2_63_or_newer]) + [autoconf_2_65_or_newer]) CTNG_PROG_VERSION([AUTORECONF], [GNU autoreconf >= 2.63], [autoreconf], [autoreconf], - ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[3-9])'], - [autoreconf_2_63_or_newer]) + ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[5-9])'], + [autoreconf_2_65_or_newer]) CTNG_PROG_VERSION([AUTOMAKE], [GNU automake >= 1.15], @@ -243,6 +245,7 @@ AC_FUNC_REALLOC AC_FUNC_ALLOCA AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.19.8]) # For now, curses are needed to build kconfig. We may support a command-line # only configuration without curses later. For now, fail in configure but diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am new file mode 100644 index 0000000..dfb8617 --- /dev/null +++ b/kconfig/Makefile.am @@ -0,0 +1,33 @@ +## Process this file with automake to produce Makefile.in +## vim: set noet : + +## TBD install into lib/crosstool-ng/kconfig? +## TBD turn off program renaming for these? Or account for it in ct-ng script? +pkglibexec_PROGRAMS = conf + +AM_LFLAGS = -L -Pzconf +AM_YFLAGS = -l -b zconf -p zconf + +BUILT_SOURCES = zconf.c zconf.lex.c + +AM_CPPFLAGS = -include config.h -DCONFIG_=\"CT_\" +conf_SOURCES = conf.c zconf.c + +# automake's support for yacc/lex/gperf is too idiosyncratic. It doesn't +# support a common pattern of including lex-generated file into yacc, nor does +# it support using a different base name for the generated C files. +YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) +AM_V_YACC = $(am__v_YACC_@AM_V@) +am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@) +am__v_YACC_0 = @echo " YACC " $@; + +LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS) +AM_V_LEX = $(am__v_LEX_@AM_V@) +am__v_LEX_ = $(am__v_LEX_@AM_DEFAULT_V@) +am__v_LEX_0 = @echo " LEX " $@; + +zconf.c: zconf.y + $(AM_V_YACC)$(YACCCOMPILE) -o$@ $< + +zconf.lex.c: zconf.l + $(AM_V_LEX)$(LEXCOMPILE) -o$@ $< diff --git a/kconfig/Makefile.in b/kconfig/Makefile.in deleted file mode 100644 index 71157d6..0000000 --- a/kconfig/Makefile.in +++ /dev/null @@ -1,118 +0,0 @@ -#----------------------------------------------------------- -# Hmmm! Cheesy build! -# Or: where I can unveil my make-fu... :-] - -install = @INSTALL@ -sed = @SED@ -gperf = @GPERF@ -CC = @CC@ -LIBS = @LIBS@ - -V=1 -__silent = $(if $(V),,@printf ' %-7s %s\n' '$1' '$(if $2,$2,$(strip $<))' && ) -__silent_rm = $(call __silent,RM,$1)rm -f $1 - -PROGS = conf mconf nconf - -all: $(PROGS) - @true # Just be silent, you fscking son of a fscking beach... - -# Build flags -CFLAGS = --include @top_builddir@/config.h -DCONFIG_=\"CT_\" \ - @CFLAGS@ @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ @LIBINTL@ - -# Compiler flags to use gettext -ifneq (@USE_NLS@,yes) -CFLAGS += -Wno-format-security -DKBUILD_NO_NLS -endif - -# Common source files -COMMON_SRC = zconf.tab.c -COMMON_OBJ = $(patsubst %.c,%.o,$(COMMON_SRC)) -COMMON_DEP = $(patsubst %.o,%.dep,$(COMMON_OBJ)) -$(COMMON_OBJ) $(COMMON_DEP): CFLAGS += -I. - -# lxdialog source files -LX_SRC = $(sort $(wildcard lxdialog/*.c)) -LX_OBJ = $(patsubst %.c,%.o,$(LX_SRC)) -LX_DEP = $(patsubst %.o,%.dep,$(LX_OBJ)) -$(LX_OBJ) $(LX_DEP): CFLAGS += @CURSES_CFLAGS@ - -# What's needed to build 'conf' -conf_SRC = conf.c -conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC)) -conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ)) -$(conf_OBJ) $(conf_DEP): CFLAGS += - -# What's needed to build 'mconf' -mconf_SRC = mconf.c -mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC)) -mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC)) -$(mconf_OBJ) $(mconf_DEP): CFLAGS += @CURSES_CFLAGS@ -mconf: LDFLAGS += @CURSES_LIBS@ - -# What's needed to build 'nconf' -nconf_SRC = nconf.c nconf.gui.c -nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC)) -nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC)) -$(nconf_OBJ) $(nconf_DEP): CFLAGS += -nconf: LDFLAGS += @MENU_LIBS@ @PANEL_LIBS@ @CURSES_LIBS@ - -# These are generated files: -ALL_OBJS = $(sort $(COMMON_OBJ) $(LX_OBJ) $(conf_OBJ) $(mconf_OBJ) $(nconf_OBJ)) -ALL_DEPS = $(sort $(COMMON_DEP) $(LX_DEP) $(conf_DEP) $(mconf_DEP) $(nconf_DEP)) - -# Cheesy auto-dependencies -DEPS = $(COMMON_DEP) -DEPS += $(conf_DEP) -DEPS += $(mconf_DEP) $(LX_DEP) -DEPS += $(nconf_DEP) --include $(DEPS) - -# Build the dependency for C files -%.dep: %.c - $(call __silent,DEP,$@)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@ - -# Generate the grammar parser -zconf.tab.o: zconf.tab.c zconf.lex.c -zconf.tab.dep: zconf.tab.c zconf.lex.c - -.PRECIOUS: zconf.tab.c -zconf.tab.c: zconf.y - $(call __silent,BISON)bison -l -b zconf -p zconf $< - -zconf.lex.c: zconf.l - $(call __silent,LEX)flex -L -Pzconf -o$@ $< - -# Build C files -%.o: %.c - $(call __silent,CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< - -# Actual link -mconf: $(COMMON_OBJ) $(LX_OBJ) $(mconf_OBJ) - $(call __silent,LD,$@)$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) - -nconf: $(COMMON_OBJ) $(nconf_OBJ) - $(call __silent,LD,$@)$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) - -conf: $(COMMON_OBJ) $(conf_OBJ) - $(call __silent,LD,$@)$(CC) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS) - -#----------------------------------------------------------- -# Installation -install: $(patsubst %,install-%,$(PROGS)) install-kconfig.mk - -$(patsubst %,install-%,$(PROGS)): install-%: % - $(call __silent,INSTALL,$<)$(install) -m 0755 $< $(DESTDIR)/$< - -install-kconfig.mk: kconfig.mk - $(call __silent,INSTALL,$<)$(install) -m 0644 $< $(DESTDIR)/$< - -#----------------------------------------------------------- -# Cleaning up the mess... - -clean: - $(call __silent,RM,objs)rm -f $(ALL_OBJS) $(ALL_DEPS) - $(call __silent_rm,$(PROGS)) - $(call __silent_rm,zconf.tab.c zconf.lex.c lex.backup) diff --git a/m4/ctng_version_check.m4 b/m4/ctng_version_check.m4 index 472194b..703661b 100644 --- a/m4/ctng_version_check.m4 +++ b/m4/ctng_version_check.m4 @@ -4,28 +4,28 @@ # VAR; display HELP message. Try to find a version that satisfies VERSION_CHECK # regexp; if that is achieved, set CONFIG_OPT in the kconfig. Otherwise, settle # for any version found. -# Sets acx_version_VAR_ok to ':' if the version met the criterion, or false otherwise. +# Sets ctng_version_VAR_ok to ':' if the version met the criterion, or false otherwise. AC_DEFUN([CTNG_PROG_VERSION], [AS_IF([test -z "$EGREP"], [AC_MSG_ERROR([This macro can only be used after checking for EGREP])]) CTNG_WITH_DEPRECATED([$3], [$1]) AC_ARG_VAR([$1], [Specify the full path to $2]) - acx_version_$1_ok=false + ctng_version_$1_ok=false AC_CACHE_CHECK([for $3], [ac_cv_path_$1], [AC_PATH_PROGS_FEATURE_CHECK([$1], [$4], [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5) test -z "$ac_cv_path_$1" && ac_cv_path_$1=$ac_path_$1 - test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: acx_version_$1_ok=:]])]) - AS_IF([test -n "$1"], - [[ver=$($ac_path_$1 --version 2>/dev/null| $EGREP $5) - test -n "$ver" && acx_version_$1_ok=:]]) + test -n "$ver" && ac_cv_path_$1="$ac_path_$1" ac_path_$1_found=: ctng_version_$1_ok=:]])]) + AS_IF([test -n "$$1"], + [[ver=$($ac_cv_path_$1 --version 2>/dev/null| $EGREP $5) + test -n "$ver" && ctng_version_$1_ok=:]]) AC_MSG_CHECKING([for $2]) - AS_IF([$acx_version_$1_ok], + AS_IF([$ctng_version_$1_ok], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) AC_SUBST([$1], [$ac_cv_path_$1]) AS_IF([test -n "$6"], - [AS_IF([$acx_version_$1_ok], [$6=y], [$6=]) + [AS_IF([$ctng_version_$1_ok], [$6=y], [$6=]) CTNG_SET_KCONFIG_OPTION([$6])]) ]) @@ -41,7 +41,7 @@ AC_DEFUN([CTNG_PROG_VERSION_REQ_ANY], # (i.e. "require version X or newer") AC_DEFUN([CTNG_PROG_VERSION_REQ_STRICT], [CTNG_PROG_VERSION([$1], [$2], [$3], [$4], [$5], [$6]) - AS_IF([test -z "$$1" || ! $acx_version_$1_ok], + AS_IF([test -z "$$1" || ! $ctng_version_$1_ok], [AC_MSG_ERROR([Required tool not found: $2])]) ]) diff --git a/scripts/compile b/scripts/compile new file mode 100755 index 0000000..a85b723 --- /dev/null +++ b/scripts/compile @@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/depcomp b/scripts/depcomp new file mode 100755 index 0000000..fc98710 --- /dev/null +++ b/scripts/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2013-05-30.07; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/install-sh b/scripts/install-sh index 6781b98..59990a1 100755 --- a/scripts/install-sh +++ b/scripts/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,25 +35,21 @@ scriptversion=2009-04-28.21; # UTC # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,17 +64,6 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. @@ -97,7 +82,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -137,42 +122,57 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -186,6 +186,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -194,13 +198,26 @@ if test $# -eq 0; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -211,16 +228,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -228,9 +245,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for 'test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,51 +269,20 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi @@ -307,74 +293,81 @@ do if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -384,53 +377,51 @@ do # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - -*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -465,15 +456,12 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -486,24 +474,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 diff --git a/scripts/ltmain.sh b/scripts/ltmain.sh new file mode 100644 index 0000000..fb43c68 --- /dev/null +++ b/scripts/ltmain.sh @@ -0,0 +1,4 @@ +# Dummy: crosstool-NG currently does not use libtool itself, it just checks +# its presense/version for the build time... Should be checked at the 'ct-ng build' +# time as well then. +: diff --git a/scripts/missing b/scripts/missing new file mode 100755 index 0000000..f62bbae --- /dev/null +++ b/scripts/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2013-10-28.13; # UTC + +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/ylwrap b/scripts/ylwrap new file mode 120000 index 0000000..efe1e02 --- /dev/null +++ b/scripts/ylwrap @@ -0,0 +1 @@ +/usr/share/automake-1.15/ylwrap \ No newline at end of file -- cgit v0.10.2-6-g49f6 From 7655fc2a3c64fce46517d4a2af047d4c6e663f50 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 4 Feb 2018 23:58:06 -0800 Subject: Cleanup after rebase on master: gperf detection macros no longer needed, gperf is not used anymore. Signed-off-by: Alexey Neyman diff --git a/configure.ac b/configure.ac index e3ca4ae..e7feec5 100644 --- a/configure.ac +++ b/configure.ac @@ -118,7 +118,6 @@ AC_PROG_RANLIB CTNG_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy]) CTNG_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump]) CTNG_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf]) -CTNG_PATH_TOOL_REQ([GPERF], [gperf], [gperf]) CTNG_CHECK_PROGS_REQ([bison], [bison]) CTNG_CHECK_PROGS_REQ([flex], [flex]) @@ -224,8 +223,6 @@ CTNG_PROG_VERSION([M4], ['\(GNU M4\) ([2-9]\.|1\.[5-9]|1\.[1-4][0-9]|1\.4\.[2-9][0-9]|1\.4\.1[2-9])'], [gnu_m4_1_4_12_or_newer]) -CTNG_PROG_GPERF - AC_SUBST([kconfig_options]) AC_CHECK_PROGS([cvs], [cvs]) diff --git a/m4/ctng_gperf.m4 b/m4/ctng_gperf.m4 deleted file mode 100644 index 3873028..0000000 --- a/m4/ctng_gperf.m4 +++ /dev/null @@ -1,21 +0,0 @@ -# Check for GNU perf location and the type it uses in the prototypes -AC_DEFUN([CTNG_PROG_GPERF], - [AX_REQUIRE_DEFINED([CTNG_CHECK_TOOL_REQ]) - CTNG_CHECK_TOOL_REQ([GPERF], [gperf], [gperf]) - # Gperf 3.1 started generating functions with size_t rather than unsigned int - AC_MSG_CHECKING([for the type used in gperf declarations]) - cat > conftest.gperf.c <<_ASEOF -#include " -const char * in_word_set(const char *, GPERF_LEN_TYPE); -_ASEOF - echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c - AS_IF([${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1], - [AC_MSG_RESULT([size_t]) - GPERF_LEN_TYPE='size_t'], - [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1], - [AC_MSG_RESULT([unsigned int]) - GPERF_LEN_TYPE='unsigned int'], - [AC_MSG_ERROR([unable to determine gperf len type])]) - rm -f conftest.gperf.c - AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], $GPERF_LEN_TYPE, [String length type used by gperf]) -]) -- cgit v0.10.2-6-g49f6 From 66821508f4064904995189f4b46652eb6257b1ea Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Feb 2018 10:37:18 -0800 Subject: Fix install --strip-program check after merge Also, fix the use of AC_CACHE_CHECK in stat format checker. Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index d8a8f32..292a4f5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ aclocal.m4 config.h* config.log config.status -/Makefile -/Makefile.in +Makefile +Makefile.in *ct-ng* !ct-ng.comp !ct-ng.in diff --git a/configure.ac b/configure.ac index e7feec5..02f91e0 100644 --- a/configure.ac +++ b/configure.ac @@ -38,21 +38,6 @@ AC_ARG_ENABLE( [--enable-static], [build static libraries (deprecated, ignored)])]) -# Check if install(1) supports --strip-program=... -AC_DEFUN( - [ACX_INSTALL_STRIP_PROGRAM], - [touch conftest - mkdir conftest.dir - AC_MSG_CHECKING([if install takes --strip-program option]) - AS_IF([$INSTALL --strip-program=true -s conftest conftest.dir/conftest 2>/dev/null], - [install_with_strip_program=y - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - ACX_SET_KCONFIG_OPTION([install_with_strip_program]) - rm -rf conftest.dir - rm -f conftest - ]) - # Check for --build and --host... AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -66,10 +51,7 @@ AC_ARG_PROGRAM AC_PROG_MKDIR_P AC_PROG_LN_S -CTNG_WITH_DEPRECATED([install], [INSTALL]) -AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install]) -AC_PROG_INSTALL -ACX_INSTALL_STRIP_PROGRAM +CTNG_PROG_INSTALL CTNG_WITH_DEPRECATED([grep], [GREP]) AC_ARG_VAR([GREP], [Specify the full path to GNU grep]) @@ -140,13 +122,7 @@ AC_CHECK_PROGS([curl], [curl]) CTNG_SET_KCONFIG_OPTION([curl]) AC_SUBST([curl]) -CTNG_PROG_STAT( - [CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU], [y]) - CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD]) - ], - [CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD], [y]) - CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU]) - ]) +CTNG_PROG_STAT CTNG_CPU_COUNT diff --git a/m4/ctng_cpu_count.m4 b/m4/ctng_cpu_count.m4 index 4ea50d8..c10ae8b 100644 --- a/m4/ctng_cpu_count.m4 +++ b/m4/ctng_cpu_count.m4 @@ -1,10 +1,10 @@ # Find out how to count CPUs AC_DEFUN([CTNG_CPU_COUNT], [AC_CACHE_CHECK([whether to use getconf or sysctl to count CPUs], - [acx_cv_cpu_count], + [ctng_cv_cpu_count], [getconf _NPROCESSORS_ONLN >/dev/null 2>&1 && \ - acx_cv_cpu_count="getconf _NPROCESSORS_ONLN" + ctng_cv_cpu_count="getconf _NPROCESSORS_ONLN" sysctl -n hw.ncpu >/dev/null 2>&1 && \ - acx_cv_cpu_count="sysctl -n hw.ncpu"]) - AC_SUBST(CPU_COUNT, "$acx_cv_cpu_count") + ctng_cv_cpu_count="sysctl -n hw.ncpu"]) + AC_SUBST(CPU_COUNT, "$ctng_cv_cpu_count") ]) diff --git a/m4/ctng_prog_install.m4 b/m4/ctng_prog_install.m4 new file mode 100644 index 0000000..61cd358 --- /dev/null +++ b/m4/ctng_prog_install.m4 @@ -0,0 +1,26 @@ +# Additional checks for install(1) + +# Check if install(1) supports --strip-program=... +AC_DEFUN( + [CTNG_INSTALL_STRIP_PROGRAM], + [AC_CACHE_CHECK([whether install takes --strip-program option], + [ctng_cv_install_with_strip_program], + [touch conftest + mkdir conftest.dir + AS_IF([$INSTALL --strip-program=true -s conftest conftest.dir/conftest 2>/dev/null], + [ctng_cv_install_with_strip_program=yes], + [ctng_cv_install_with_strip_program=no]) + rm -rf conftest.dir + rm -f conftest + ]) + AS_IF([test "$ctng_cv_install_with_strip_program" = yes], [$1], [$2]) + ]) + +AC_DEFUN([CTNG_PROG_INSTALL], + [CTNG_WITH_DEPRECATED([install], [INSTALL]) + AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install]) + AC_PROG_INSTALL + CTNG_INSTALL_STRIP_PROGRAM( + [CTNG_SET_KCONFIG_OPTION([install_with_strip_program], [y])], + [CTNG_SET_KCONFIG_OPTION([install_with_strip_program])]) + ]) diff --git a/m4/ctng_prog_stat.m4 b/m4/ctng_prog_stat.m4 index 5db3469..6bee076 100644 --- a/m4/ctng_prog_stat.m4 +++ b/m4/ctng_prog_stat.m4 @@ -2,23 +2,30 @@ # string (BSD or GNU). Defines ac_cv_stat_flavor to either GNU or BSD; # and evaluates either IF-GNU or IF-BSD expression. # CTNG_PROG_STAT([IF-GNU], [IF-BSD]) -AC_DEFUN([CTNG_PROG_STAT], - [AX_REQUIRE_DEFINED([CTNG_CHECK_PROGS_REQ]) - CTNG_CHECK_PROGS_REQ([stat], [stat]) - AC_CACHE_CHECK([whether stat takes GNU or BSD format], - [acx_cv_stat_flavor], +AC_DEFUN([CTNG_PROG_STAT_FORMAT], + [AC_CACHE_CHECK([whether stat takes GNU or BSD format], + [ctng_cv_stat_flavor], [touch conftest chmod 642 conftest attr_bsd=$(stat -f '%Lp' conftest 2>/dev/null) attr_gnu=$(stat -c '%a' conftest 2>/dev/null) rm -f conftest AS_IF([test "$attr_bsd" = "642"], - [acx_cv_stat_flavor=BSD - $2 - ], + [ctng_cv_stat_flavor=BSD], [test "$attr_gnu" = "642"], - [acx_cv_stat_flavor=GNU - $1 - ], - [AC_MSG_ERROR([cannot determine stat(1) format option])])]) + [ctng_cv_stat_flavor=GNU], + [ctng_cv_stat_flavor=unknown])]) + AS_IF([test "$ctng_cv_stat_flavor" = "GNU" ], [$1], + [test "$ctng_cv_stat_flavor" = "BSD" ], [$2], + [AC_MSG_ERROR([cannot determine stat(1) format option])]) + ]) + +AC_DEFUN([CTNG_PROG_STAT], + [AX_REQUIRE_DEFINED([CTNG_CHECK_PROGS_REQ]) + CTNG_CHECK_PROGS_REQ([stat], [stat]) + CTNG_PROG_STAT_FORMAT( + [CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU], [y]) + CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD])], + [CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD], [y]) + CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU])]) ]) -- cgit v0.10.2-6-g49f6 From 9a4e17cf9b0e27a9af49da932db96ccb19aeb1f7 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Feb 2018 12:59:26 -0800 Subject: Add nconf build Signed-off-by: Alexey Neyman diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am index dfb8617..66df802 100644 --- a/kconfig/Makefile.am +++ b/kconfig/Makefile.am @@ -3,7 +3,7 @@ ## TBD install into lib/crosstool-ng/kconfig? ## TBD turn off program renaming for these? Or account for it in ct-ng script? -pkglibexec_PROGRAMS = conf +pkglibexec_PROGRAMS = conf nconf AM_LFLAGS = -L -Pzconf AM_YFLAGS = -l -b zconf -p zconf @@ -11,8 +11,13 @@ AM_YFLAGS = -l -b zconf -p zconf BUILT_SOURCES = zconf.c zconf.lex.c AM_CPPFLAGS = -include config.h -DCONFIG_=\"CT_\" + conf_SOURCES = conf.c zconf.c +nconf_SOURCES = nconf.c nconf.gui.c zconf.c +nconf_CFLAGS = $(CURSES_CFLAGS) +nconf_LDADD = $(MENU_LIBS) $(PANEL_LIBS) $(CURSES_LIBS) + # automake's support for yacc/lex/gperf is too idiosyncratic. It doesn't # support a common pattern of including lex-generated file into yacc, nor does # it support using a different base name for the generated C files. -- cgit v0.10.2-6-g49f6 From d9d4d090265b56dc158b9ffa7a875d0a68f9c57f Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Feb 2018 18:24:27 -0800 Subject: Enable mconf build Signed-off-by: Alexey Neyman diff --git a/configure.ac b/configure.ac index 02f91e0..bd7ccb4 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ AC_CONFIG_AUX_DIR([scripts]) AC_CONFIG_MACRO_DIR([m4]) # TBD try to use gnu strictness? Just add the missing files? -AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2 subdir-objects]) #-------------------------------------------------------------------- # Allow dummy --{en,dis}able-{static,shared} diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am index 66df802..1b4a06c 100644 --- a/kconfig/Makefile.am +++ b/kconfig/Makefile.am @@ -1,9 +1,8 @@ -## Process this file with automake to produce Makefile.in ## vim: set noet : ## TBD install into lib/crosstool-ng/kconfig? ## TBD turn off program renaming for these? Or account for it in ct-ng script? -pkglibexec_PROGRAMS = conf nconf +pkglibexec_PROGRAMS = conf nconf mconf AM_LFLAGS = -L -Pzconf AM_YFLAGS = -l -b zconf -p zconf @@ -18,6 +17,11 @@ nconf_SOURCES = nconf.c nconf.gui.c zconf.c nconf_CFLAGS = $(CURSES_CFLAGS) nconf_LDADD = $(MENU_LIBS) $(PANEL_LIBS) $(CURSES_LIBS) +mconf_SOURCES = mconf.c zconf.c lxdialog/checklist.c lxdialog/inputbox.c \ + lxdialog/menubox.c lxdialog/textbox.c lxdialog/util.c \ + lxdialog/yesno.c +mconf_LDADD = $(CURSES_LIBS) + # automake's support for yacc/lex/gperf is too idiosyncratic. It doesn't # support a common pattern of including lex-generated file into yacc, nor does # it support using a different base name for the generated C files. -- cgit v0.10.2-6-g49f6 From dbe3877285549d1cdc549826673cdf8f07cf154c Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 21 Feb 2018 23:34:58 -0800 Subject: Install ct-ng Also, move kconfig.mk into the main driver - we'd want kconfig to be a sub-package so there's no sense in writing the installation framework for the ct-ng-specific fragment in an otherwise independent directory. Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 8e25898..37996f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,3 +2,17 @@ ## vim: set noet : SUBDIRS = kconfig + +bin_SCRIPTS = ct-ng +CLEANFILES = $(bin_SCRIPTS) +EXTRA_DIST = ct-ng.in bootstrap + +do_subst = ( @SED@ \ + -e 's,[@]bindir[@],$(bindir),g' \ + -e 's,[@]libdir[@],$(libdir),g' \ + -e 's,[@]docdir[@],$(docdir),g' \ + -e 's,[@]mandir[@],$(mandir),g' \ + | $(SHELL) config.status --file=- ) + +ct-ng: ct-ng.in + $(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv $@-t $@ diff --git a/ct-ng.in b/ct-ng.in index a8ad09d..7e0368d 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -1,4 +1,4 @@ -#!@@CT_make@@ -rf +#!@MAKE@ -rf # Makefile for crosstool-NG. # Copyright 2006 Yann E. MORIN @@ -16,11 +16,11 @@ export CT_TOP_DIR:=$(shell pwd) # Paths and values set by ./configure # Don't bother to change it other than with a new ./configure! -export CT_LIB_DIR:=@@CT_LIBDIR@@ -export CT_DOC_DIR:=@@CT_DOCDIR@@ +export CT_LIB_DIR:=@libdir@ +export CT_DOC_DIR:=@docdir@ # This is crosstool-NG version string -export CT_VERSION:=@@CT_VERSION@@ +export CT_VERSION:=@PACKAGE_VERSION@ # Paths found by ./configure include $(CT_LIB_DIR)/paths.mk @@ -62,6 +62,59 @@ all: help PHONY += all FORCE: +# Configuration rules. Currently, saveSample.sh uses some of the variables +# below - they should be passed explicitly. + +# Top file of crosstool-NG configuration +export KCONFIG_TOP = $(CT_LIB_DIR)/config/config.in + +# We need CONF for savedefconfig in scripts/saveSample.sh +export CONF := $(CT_LIB_DIR)/kconfig/conf +MCONF := $(CT_LIB_DIR)/kconfig/mconf +NCONF := $(CT_LIB_DIR)/kconfig/nconf + +# Used by conf/mconf/nconf to find the .in files +# TBD needed? We do supply the defconfig name explicitly below +export srctree=$(CT_LIB_DIR) + +.PHONY: menuconfig nconfig oldconfig savedefconfig defconfig + +menuconfig: + @$(CT_ECHO) " CONF $@" + $(SILENT)$(MCONF) $(KCONFIG_TOP) + +nconfig: + @$(CT_ECHO) " CONF $@" + $(SILENT)$(NCONF) $(KCONFIG_TOP) + +oldconfig: .config + @$(CT_ECHO) " CONF $@" + $(SILENT)$(sed) -i -r -f $(CT_LIB_DIR)/scripts/upgrade.sed $< + $(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP) + +savedefconfig: .config + @$(CT_ECHO) ' GEN $@' + $(SILENT)$(CONF) --savedefconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP) + +defconfig: + @$(CT_ECHO) ' CONF $@' + $(SILENT)$(CONF) --defconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP) + +# Always be silent, the stdout an be >.config +extractconfig: + @$(awk) 'BEGIN { dump=0; } \ + dump==1 && $$0~/^\[.....\][[:space:]]+(# )?CT_/ { \ + $$1=""; \ + gsub("^[[:space:]]",""); \ + print; \ + } \ + $$0~/Dumping user-supplied crosstool-NG configuration: done in/ { \ + dump=0; \ + } \ + $$0~/Dumping user-supplied crosstool-NG configuration$$/ { \ + dump=1; \ + }' + # Help system help:: help-head help-config help-samples help-build help-clean help-distrib help-env help-tail @@ -90,8 +143,8 @@ help-distrib:: help-env:: @echo - @if [ -r "@@CT_DOCDIR@@/manual/4_Building.md" ]; then \ - echo 'Environment variables (see @@CT_DOCDIR@@/0 - Table of content.txt):'; \ + @if [ -r "@docdir@/manual/4_Building.md" ]; then \ + echo 'Environment variables (see @docdir@/0 - Table of content.txt):'; \ else \ echo 'Environment variables (see http://crosstool-ng.github.io/docs/build/)'; \ fi @@ -111,12 +164,19 @@ help-clean:: @echo ' clean - Remove generated files' @echo ' distclean - Remove generated files, configuration and build directories' -include $(CT_LIB_DIR)/kconfig/kconfig.mk include $(CT_LIB_DIR)/steps.mk include $(CT_LIB_DIR)/samples/samples.mk include $(CT_LIB_DIR)/scripts/scripts.mk help-config:: + @echo ' menuconfig - Update current config using a menu based program' + @echo ' nconfig - Update current config using a menu based program' + @echo ' oldconfig - Update current config using a provided .config as base' + @echo ' extractconfig - Extract to stdout the configuration items from a' + @echo ' build.log file piped to stdin' + @echo ' savedefconfig - Save current config as a mini-defconfig to $${DEFCONFIG}' + @echo ' defconfig - Update config from a mini-defconfig $${DEFCONFIG}' + @echo ' (default: $${DEFCONFIG}=./defconfig)' @echo ' show-tuple - Print the tuple of the currently configured toolchain' help-distrib:: diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am index 1b4a06c..413d944 100644 --- a/kconfig/Makefile.am +++ b/kconfig/Makefile.am @@ -1,7 +1,9 @@ ## vim: set noet : -## TBD install into lib/crosstool-ng/kconfig? ## TBD turn off program renaming for these? Or account for it in ct-ng script? +transform = s,x,x, + +## TBD install into lib/crosstool-ng/kconfig? or move to libexec which seems more suitable pkglibexec_PROGRAMS = conf nconf mconf AM_LFLAGS = -L -Pzconf diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk deleted file mode 100644 index c489c72..0000000 --- a/kconfig/kconfig.mk +++ /dev/null @@ -1,68 +0,0 @@ -# =========================================================================== -# crosstool-NG configuration targets -# These targets are used from top-level makefile - -#----------------------------------------------------------- -# The configurators rules - -# Top file of crosstool-NG configuration -export KCONFIG_TOP = $(CT_LIB_DIR)/config/config.in - -# We need CONF for savedefconfig in scripts/saveSample.sh -export CONF := $(CT_LIB_DIR)/kconfig/conf -MCONF := $(CT_LIB_DIR)/kconfig/mconf -NCONF := $(CT_LIB_DIR)/kconfig/nconf - -# Used by conf/mconf/nconf to find the .in files -export srctree=$(CT_LIB_DIR) - -.PHONY: menuconfig nconfig oldconfig savedefconfig defconfig - -menuconfig: - @$(CT_ECHO) " CONF $@" - $(SILENT)$(MCONF) $(KCONFIG_TOP) - -nconfig: - @$(CT_ECHO) " CONF $@" - $(SILENT)$(NCONF) $(KCONFIG_TOP) - -oldconfig: .config - @$(CT_ECHO) " CONF $@" - $(SILENT)$(sed) -i -r -f $(CT_LIB_DIR)/scripts/upgrade.sed $< - $(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP) - -savedefconfig: .config - @$(CT_ECHO) ' GEN $@' - $(SILENT)$(CONF) --savedefconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP) - -defconfig: - @$(CT_ECHO) ' CONF $@' - $(SILENT)$(CONF) --defconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP) - -# Always be silent, the stdout an be >.config -extractconfig: - @$(awk) 'BEGIN { dump=0; } \ - dump==1 && $$0~/^\[.....\][[:space:]]+(# )?CT_/ { \ - $$1=""; \ - gsub("^[[:space:]]",""); \ - print; \ - } \ - $$0~/Dumping user-supplied crosstool-NG configuration: done in/ { \ - dump=0; \ - } \ - $$0~/Dumping user-supplied crosstool-NG configuration$$/ { \ - dump=1; \ - }' - -#----------------------------------------------------------- -# Help text used by make help - -help-config:: - @echo ' menuconfig - Update current config using a menu based program' - @echo ' nconfig - Update current config using a menu based program' - @echo ' oldconfig - Update current config using a provided .config as base' - @echo ' extractconfig - Extract to stdout the configuration items from a' - @echo ' build.log file piped to stdin' - @echo ' savedefconfig - Save current config as a mini-defconfig to $${DEFCONFIG}' - @echo ' defconfig - Update config from a mini-defconfig $${DEFCONFIG}' - @echo ' (default: $${DEFCONFIG}=./defconfig)' -- cgit v0.10.2-6-g49f6 From 69df9ae9ddb806b42d962ae8a0b2b8f7b31f480e Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 22 Feb 2018 00:25:36 -0800 Subject: Remove the need for configure substitutions in scripts ... so that scripts/ directory can be installed verbatim. Signed-off-by: Alexey Neyman diff --git a/config/global/build-behave.in b/config/global/build-behave.in index d3298ea..4a50428 100644 --- a/config/global/build-behave.in +++ b/config/global/build-behave.in @@ -13,7 +13,8 @@ config PARALLEL_JOBS Enter 1 to have only one job at a time. - Enter 0 to set automatically based on how many processors the host has. + Enter 0 to set automatically based on how many processors the build + machine has. config LOAD string diff --git a/ct-ng.in b/ct-ng.in index 7e0368d..761b885 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -22,6 +22,10 @@ export CT_DOC_DIR:=@docdir@ # This is crosstool-NG version string export CT_VERSION:=@PACKAGE_VERSION@ +# Download agents used by scripts.mk +CT_WGET := @wget@ +CT_CURL := @curl@ + # Paths found by ./configure include $(CT_LIB_DIR)/paths.mk @@ -203,7 +207,8 @@ source: .config $(SILENT)CT_SOURCE=y $(bash) $(CT_LIB_DIR)/scripts/crosstool-NG.sh build: .config - $(SILENT)$(bash) $(CT_LIB_DIR)/scripts/crosstool-NG.sh + $(SILENT)BUILD_NCPUS=`@@CT_cpucount@@ 2>/dev/null || echo 0` \ + $(bash) $(CT_LIB_DIR)/scripts/crosstool-NG.sh build.%: $(SILENT)$(MAKE) -rf $(CT_NG) build CT_JOBS=$* diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 553a363..0000000 --- a/scripts/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -crosstool-NG.sh -saveSample.sh -scripts.mk diff --git a/scripts/crosstool-NG.sh b/scripts/crosstool-NG.sh new file mode 100644 index 0000000..4d79e48 --- /dev/null +++ b/scripts/crosstool-NG.sh @@ -0,0 +1,722 @@ +# Copyright 2007 Yann E. MORIN +# Licensed under the GPL v2. See COPYING in the root of this package. + +# This is the main entry point to crosstool +# This will: +# - download, extract and patch the toolchain components +# - build and install each components in turn +# - and eventually test the resulting toolchain + +# What this file does is prepare the environment, based upon the user-choosen +# options. It also checks the existing environment for un-friendly variables, +# and builds the tools. + +# Parse the common functions +# Note: some initialisation and sanitizing is done while parsing this file, +# most notably: +# - set trap handler on errors, +# - don't hash commands lookups, +. "${CT_LIB_DIR}/scripts/functions" + +# Read the sample settings +CT_LoadConfig + +# Yes! We can do full logging from now on! Clean any old log file content. +CT_LogEnable clean=yes + +# Check running as root +if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then + if [ $(id -u) -eq 0 ]; then + CT_DoLog ERROR "You must NOT be root to run crosstool-NG" + exit 1 + fi +fi + +# If we want an interactive debug-shell, we must ensure these FDs +# are indeed connected to a terminal (and not redirected in any way). +if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then + CT_DoLog ERROR "Can't spawn interactive debug-shell," + CT_DoLog ERROR "because stdout/stderr has been redirected." + exit 1 +fi + +CT_TrapEnvExport + +# Override the locale early, in case we ever translate crosstool-NG messages +if [ -z "${CT_NO_OVERRIDE_LC_MESSAGES}" ]; then + export LC_ALL=C + export LANG=C +fi + +# remove . from PATH since it can cause gcc build failures +CT_SanitizePath + +# Some sanity checks in the environment and needed tools +CT_DoLog INFO "Performing some trivial sanity checks" +CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH+set}" +CT_TestAndAbort "Don't set LIBRARY_PATH. It screws up the build." -n "${LIBRARY_PATH+set}" +CT_TestAndAbort "Don't set LPATH. It screws up the build." -n "${LPATH+set}" +CT_TestAndAbort "Don't set CPATH. It screws up the build." -n "${CPATH+set}" +CT_TestAndAbort "Don't set C_INCLUDE_PATH. It screws up the build." -n "${C_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set CPLUS_INCLUDE_PATH. It screws up the build." -n "${CPLUS_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set OBJC_INCLUDE_PATH. It screws up the build." -n "${OBJC_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS+set}" +CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS+set}" +CT_TestAndAbort "Don't set CC. It screws up the build." -n "${CC+set}" +CT_TestAndAbort "Don't set CXX. It screws up the build." -n "${CXX+set}" +CT_Test "GREP_OPTIONS screws up the build. Unsetting." -n "${GREP_OPTIONS+set}" +unset GREP_OPTIONS +# Workaround against openSUSE 12.1 that breaks ./configure for cross-compilation: +export CONFIG_SITE= + +# Some sanity checks on paths content +for d in \ + LOCAL_TARBALLS \ + WORK \ + PREFIX \ + INSTALL \ + ; do + eval dir="\${CT_${d}_DIR}" + case "${dir}" in + *" "*) + CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things." + ;; + *:*) + CT_Abort "'CT_${d}_DIR'='${dir}' contains a colon in it.\nDon't use colons in paths, it breaks things." + ;; + *,*) + CT_Abort "'CT_${d}_DIR'='${dir}' contains a comma in it.\nDon't use commas in paths, it breaks things." + ;; + esac +done + +# Where will we work? +CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}" +CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" +CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}" +CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/backtrace" + +# Check build file system case-sensitiveness +CT_DoExecLog DEBUG touch "${CT_WORK_DIR}/foo" +CT_TestAndAbort "Your file system in '${CT_WORK_DIR}' is *not* case-sensitive!" -f "${CT_WORK_DIR}/FOO" +CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/foo" + +# Check the user is using an existing SHELL to be used by ./configure and Makefiles +CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CONFIG_SHELL}" -a -x "${CT_CONFIG_SHELL}" + +# Create the bin-override early +# Contains symlinks to the tools found by ./configure +# Note: CT_DoLog and CT_DoExecLog do not use any of those tool, so +# they can be safely used +CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools" +CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'" +CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin" +cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do + tool="${line%%=*}" + # Suppress extra quoting + eval path=${line#*=} + if [ -r "${CT_LIB_DIR}/scripts/override/$tool" ]; then + tmpl="${CT_LIB_DIR}/scripts/override/$tool" + else + tmpl="${CT_LIB_DIR}/scripts/override/__default" + fi + CT_DoLog DEBUG "Creating script-override for '${tool}' -> '${path}' using '${tmpl}' template" + CT_DoExecLog ALL cp "${tmpl}" "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" + CT_DoExecLog ALL ${sed} -i -r \ + -e "s#@INSTALL_WITH_STRIP_PROGRAM@#${CT_CONFIGURE_has_install_with_strip_program}#g" \ + -e "s#@CONFIG_SHELL@#${CT_CONFIG_SHELL}#g" \ + -e "s#@TOOL_PATH@#${path}#g" \ + -e "s#@TOOLS_OVERRIDE_DIR@#${CT_TOOLS_OVERRIDE_DIR}#g" \ + "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" + CT_DoExecLog ALL chmod 700 "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" +done +export PATH="${CT_TOOLS_OVERRIDE_DIR}/bin:${PATH}" + +# Start date. Can't be done until we know the locale +# Also requires the bin-override tools +CT_STAR_DATE=$(CT_DoDate +%s%N) +CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) + +# Log real begining of build, now +CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" + +CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" +CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config +CT_EndStep + +CT_DoLog DEBUG "Unsetting MAKEFLAGS" +unset MAKEFLAGS + +# Set the shell to be used by ./configure scripts and by Makefiles (those +# that support it!). +export CONFIG_SHELL="${CT_CONFIG_SHELL}" # for ./configure +export SHELL="${CT_CONFIG_SHELL}" # for Makefiles + +CT_DoLog INFO "Building environment variables" + +# Sanity check some directories +CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}" + +# Avoid multiple '/' in the prefix dir, it breaks relocatability +CT_PREFIX_DIR="$( ${sed} -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )" + +# Second kludge: merge user-supplied target CFLAGS with architecture-provided +# target CFLAGS. Do the same for LDFLAGS in case it happens in the future. +# Put user-supplied flags at the end, so that they take precedence. +CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}" +CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" + +# FIXME move to gcc.sh +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) +CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) + +# Starting with 1.0.20, applications using uClibc-ng do not link with +# the default libgcc_c_spec used by GCC if only static libc.a exists - unless +# -static is thrown in. The difference is that with -static, gcc passes +# "--start-group -lgcc -lc --end-group" and without -static, it passes +# "-lgcc -lc -lgcc" instead. The latter leaves a symbol from 2nd libgcc +# (dl_iterate_phdr) unresolved because -lc is already done at this point. +# Force static link on the target. +if [ "${CT_SHARED_LIBS}" != "y" ]; then + CT_TARGET_LDFLAGS+=" -static" +fi + +# Compute the package version string +if [ "${CT_SHOW_CT_VERSION}" = "y" ]; then + CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}" +else + CT_PKGVERSION="${CT_TOOLCHAIN_PKGVERSION}" +fi + +# Compute the working directories names +CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" +CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src" +CT_SRC_DIR="${CT_BUILD_TOP_DIR}/src" +CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" +CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" +# Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a +# sub-dir. So we won't have to save/restore it, not even create it. +# In case of cross or native, host-complibs are used for build-complibs; +# in case of canadian or cross-native, host-complibs are specific +# Note about BUILD_COMPTOOLS_DIR: if installing companion tools for "host" in +# a native or simple cross, we can can use the same binaries we built for +# "build". However, we need companion tools for "build" early - as other +# components may depend on them - so we may skip building for "host" rather +# than for "build" in that case. +case "${CT_TOOLCHAIN_TYPE}" in + native|cross) + CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" + if [ -n "${CT_COMP_TOOLS_FOR_HOST}" ]; then + CT_BUILD_COMPTOOLS_DIR="${CT_PREFIX_DIR}" + else + CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" + fi + ;; + canadian|cross-native) + CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}/complibs-host" + CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" + ;; +esac + +# Compute test suite install directory +CT_TEST_SUITE_DIR=${CT_PREFIX_DIR}/test-suite + +# We must ensure that we can restart if asked for! +if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then + CT_DoLog ERROR "You asked to restart a non-restartable build" + CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS" + CT_DoLog ERROR "in the config options for the previous build, or the state" + CT_DoLog ERROR "directory for the previous build was deleted." + CT_Abort "I will stop here to avoid any carnage" +fi + +# If the local tarball directory does not exist, say so, and don't try to save there! +if [ "${CT_SAVE_TARBALLS}" = "y" \ + -a ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then + CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist." + CT_DoLog WARN "Will not save downloaded tarballs to local storage." + CT_SAVE_TARBALLS= +fi + +# Check now if we can write to the destination directory: +if [ -d "${CT_PREFIX_DIR}" ]; then + CT_TestAndAbort "Destination directory '${CT_PREFIX_DIR}' is not removable" ! -w $(dirname "${CT_PREFIX_DIR}") +fi + +# Good, now grab a bit of informations on the system we're being run on, +# just in case something goes awok, and it's not our fault: +CT_SYS_USER=$(id -un) +CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true) +# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name. +CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}" +CT_SYS_KERNEL=$(uname -s) +CT_SYS_REVISION=$(uname -r) +CT_SYS_OS=$(uname -s) +CT_SYS_MACHINE=$(uname -m) +CT_SYS_PROCESSOR=$(uname -p) +CT_SYS_GCC=$(${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX} -dumpversion) +CT_SYS_TARGET=$(CT_DoConfigGuess) +CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}" + +# Adjust the list of multilibs, if needed +CT_DoArchMultilibList + +CT_DoLog EXTRA "Preparing working directories" + +# Ah! The build directory shall be eradicated, even if we restart! +# Ditto for the build tools install dir +CT_DoForceRmdir "${CT_BUILD_DIR}" "${CT_BUILDTOOLS_PREFIX_DIR}" + +# Don't eradicate directories if we need to restart +if [ -z "${CT_RESTART}" ]; then + # Per-target sources: eliminate + CT_DoForceRmdir "${CT_SRC_DIR}" + # Get rid of pre-existing installed toolchain and previous build directories. + if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then + CT_DoForceRmdir "${CT_TARBALLS_DIR}" + fi + if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_COMMON_SRC_DIR}" ]; then + CT_DoForceRmdir "${CT_COMMON_SRC_DIR}" + fi + if [ -d "${CT_PREFIX_DIR}" -a "${CT_RM_RF_PREFIX_DIR}" = "y" ]; then + CT_DoForceRmdir "${CT_PREFIX_DIR}" + fi + # In case we start anew, get rid of the previously saved state directory + if [ -d "${CT_STATE_DIR}" ]; then + CT_DoForceRmdir "${CT_STATE_DIR}" + fi +fi + +# Create the directories we'll use, even if restarting: it does no harm to +# create already existent directories, and CT_BUILD_DIR needs to be created +# anyway +CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_COMMON_SRC_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" +CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}" + +# Only create the state dir if asked for a restartable build +[ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}" + +# Check install file system case-sensitiveness +CT_DoExecLog DEBUG touch "${CT_PREFIX_DIR}/foo" +CT_TestAndAbort "Your file system in '${CT_PREFIX_DIR}' is *not* case-sensitive!" -f "${CT_PREFIX_DIR}/FOO" +CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo" + +# Kludge: CT_PREFIX_DIR might have grown read-only if +# the previous build was successful. +CT_DoExecLog ALL chmod -R u+w "${CT_PREFIX_DIR}" + +# Setting up the rest of the environment only if not restarting +if [ -z "${CT_RESTART}" ]; then + # Having .. inside CT_PREFIX breaks relocatability. + CT_SanitizeVarDir CT_PREFIX_DIR + + case "${CT_SYSROOT_NAME}" in + "") CT_SYSROOT_NAME="sysroot";; + .) CT_Abort "Sysroot name is set to '.' which is forbidden";; + *' '*) CT_Abort "Sysroot name contains forbidden space(s): '${CT_SYSROOT_NAME}'";; + */*) CT_Abort "Sysroot name contains forbidden slash(es): '${CT_SYSROOT_NAME}'";; + esac + + # Arrange paths depending on whether we use sysroot or not. + if [ "${CT_USE_SYSROOT}" = "y" ]; then + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}" + CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root" + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include" + CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR + CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get + # confused when $sysroot/usr/include is not present. + # Note: --prefix=/usr is magic! + # See http://www.gnu.org/software/libc/FAQ.html#s-2.2 + else + # plain old way. All libraries in prefix/target/lib + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}" + CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}" + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include" + CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR + # hack! Always use --with-sysroot for binutils. + # binutils 2.14 and later obey it, older binutils ignore it. + # Lets you build a working 32->64 bit cross gcc + CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + # Use --with-headers, else final gcc will define disable_glibc while + # building libgcc, and you'll have no profiling + CT_CC_CORE_SYSROOT_ARG="--without-headers" + CT_CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" + fi + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" + CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" + CT_DoExecLog ALL mkdir -p "${CT_HEADERS_DIR}" + + # Need the non-multilib directories: GCC's multi-os-directory is based off them, so + # even if the /lib is not used for any of the multilibs, it must be present so that + # the paths like 'lib/../lib64' still work. + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib" + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib" + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib" + + # Determine build system if not set by the user + if [ -z "${CT_BUILD}" ]; then + CT_BUILD=$(CT_DoConfigGuess) + fi + + # Prepare mangling patterns to later modify BUILD and HOST (see below) + case "${CT_TOOLCHAIN_TYPE}" in + cross) + # A cross-compiler runs on the same machine it is built on + CT_HOST="${CT_BUILD}" + build_mangle="build_" + host_mangle="build_" + target_mangle="" + install_build_tools_for="BUILD" + ;; + canadian) + build_mangle="build_" + host_mangle="host_" + target_mangle="" + install_build_tools_for="BUILD HOST" + ;; + *) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!" + ;; + esac + + # Save the real tuples to generate shell-wrappers to the real tools + CT_REAL_BUILD="${CT_BUILD}" + CT_REAL_HOST="${CT_HOST}" + CT_REAL_TARGET="${CT_TARGET}" + + # Canonicalise CT_BUILD and CT_HOST + # Not only will it give us full-qualified tuples, but it will also ensure + # that they are valid tuples (in case of typo with user-provided tuples) + # That's way better than trying to rewrite config.sub ourselves... + # CT_TARGET is already made canonical in CT_DoBuildTargetTuple + CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}") + CT_HOST=$(CT_DoConfigSub "${CT_HOST}") + + # Modify BUILD and HOST so that gcc always generate a cross-compiler + # even if any of the build, host or target machines are the same. + # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to + # support canadain build, later... + CT_BUILD="${CT_BUILD/-/-${build_mangle}}" + CT_HOST="${CT_HOST/-/-${host_mangle}}" + CT_TARGET="${CT_TARGET/-/-${target_mangle}}" + + # Now we have mangled our BUILD and HOST tuples, we must fake the new + # cross-tools for those mangled tuples. + CT_DoLog DEBUG "Making build system tools available" + for m in ${install_build_tools_for}; do + r="CT_REAL_${m}" + v="CT_${m}" + p="CT_${m}_PREFIX" + s="CT_${m}_SUFFIX" + if [ -n "${!p}" ]; then + t="${!p}" + else + t="${!r}-" + fi + + for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do + # First try with prefix + suffix + # Then try with prefix only + # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST + # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST + # This is needed, because some tools have a prefix and + # a suffix (eg. gcc), while others may have only one, + # or even none (eg. binutils) + where=$(CT_Which "${t}${tool}${!s}") + [ -z "${where}" ] && where=$(CT_Which "${t}${tool}") + if [ -z "${where}" \ + -a \( "${m}" = "BUILD" \ + -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then + where=$(CT_Which "${tool}${!s}") + fi + if [ -z "${where}" \ + -a \( "${m}" = "BUILD" \ + -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then + where=$(CT_Which "${tool}") + fi + + # Not all tools are available for all platforms, but some are required. + if [ -n "${where}" ]; then + CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" + printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" + CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" + else + case "${tool}" in + # We'll at least need some of them... + ar|as|gcc|ld|nm|objcopy|objdump|ranlib) + CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" + ;; + # Some are conditionnally required + # Add them in alphabetical (C locale) ordering + g++) + # g++ (needed for companion lib), only needed for HOST + CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${m}" = "HOST" + ;; + gcj) + CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_CC_LANG_JAVA}" = "y" + ;; + strip) + CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" + ;; + # If any other is missing, only warn at low level + *) + # It does not deserve a WARN level. + CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required." + ;; + esac + fi + done + done + + # Some makeinfo versions are a pain in [put your most sensible body part here]. + # Go ahead with those, by creating a wrapper that keeps partial files, and that + # never fails: + CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'" + printf "#${BANG}${CT_CONFIG_SHELL}\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo" + CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo" + + # Carefully add paths in the order we want them: + # - first try in ${CT_PREFIX_DIR}/bin + # - then try the buildtools dir + # - fall back to searching user's PATH + # Of course, neither cross-native nor canadian can run on BUILD, + # so don't add those PATHs in this case... + # For native and simple cross, build==host, combine the extra CFLAGS/LDFLAGS + # supplied for both (so that it doesn't matter where the user supplied them). + case "${CT_TOOLCHAIN_TYPE}" in + cross|native) + export PATH="${CT_PREFIX_DIR}/bin:${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}" + bh_cflags="${CT_EXTRA_CFLAGS_FOR_BUILD} ${CT_EXTRA_CFLAGS_FOR_HOST}" + bh_ldflags="${CT_EXTRA_LDFLAGS_FOR_BUILD} ${CT_EXTRA_LDFLAGS_FOR_HOST}" + CT_EXTRA_CFLAGS_FOR_BUILD="${bh_cflags}" + CT_EXTRA_CFLAGS_FOR_HOST="${bh_cflags}" + CT_EXTRA_LDFLAGS_FOR_BUILD="${bh_ldflags}" + CT_EXTRA_LDFLAGS_FOR_HOST="${bh_ldflags}" + ;; + canadian|cross-native) + export PATH="${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}" + # build!=host in this case + ;; + *) + ;; + esac + + # Help build gcc + # Explicitly optimise, else the lines below will overide the + # package's default optimisation flags + CT_CFLAGS_FOR_BUILD="-O2 -g -I${CT_BUILDTOOLS_PREFIX_DIR}/include" + CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}" + CT_LDFLAGS_FOR_BUILD="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib" + CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}" + + case "${CT_BUILD}" in + *darwin*) + # Two issues while building on MacOS. Really, we should be checking for + # clang instead. + # - gettext static library fails to link unless CoreFoundation framework + # is included + # - ranlib on MacOS does not include common symbols into the symbol index + # for a static library, and hence linker fails to pull in the right + # archive members; hence, avoid common symbols. Alternative is to + # have ranlib wrapper in buildtools/bin supply -c option. + CT_CFLAGS_FOR_BUILD+=" -fno-common" + CT_LDFLAGS_FOR_BUILD+=" -framework CoreFoundation" + ;; + esac + + CT_DoLog DEBUG "CFLAGS for build compiler: '${CT_CFLAGS_FOR_BUILD}'" + CT_DoLog DEBUG "LDFLAGS for build compiler: '${CT_LDFLAGS_FOR_BUILD}'" + + # Help host gcc + # Explicitly optimise, else the lines below will overide the + # package's default optimisation flags + CT_CFLAGS_FOR_HOST="-O2 -g" + [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe" + CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include" + CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}" + CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib" + CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}" + case "${CT_HOST}" in + *darwin*) + # Same as above, for host + CT_CFLAGS_FOR_HOST+=" -fno-common" + CT_LDFLAGS_FOR_HOST+=" -framework CoreFoundation" + ;; + esac + CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'" + CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'" + + # And help make go faster + JOBSFLAGS= + # Override the configured jobs with what's been given on the command line + if [ -n "${CT_JOBS}" ]; then + if [ ! -z "`echo "${CT_JOBS}" | ${sed} 's/[0-9]//g'`" ]; then + CT_Abort "Number of parallel jobs must be integer." + fi + CT_PARALLEL_JOBS="${CT_JOBS}" + fi + # Use the number of processors+1 when automatically setting the number of + # parallel jobs. + AUTO_JOBS=$[ BUILD_NCPUS + 1 ] + [ ${CT_PARALLEL_JOBS} -eq 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}" + [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" + JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}" + + # Override 'download only' option + [ -n "${CT_SOURCE}" ] && CT_ONLY_DOWNLOAD=y + + # Now that we've set up $PATH and $CT_CFLAGS_FOR_HOST, sanity test that gcc + # is runnable so that the user can troubleshoot problems if not. + CT_DoStep DEBUG "Checking that we can run gcc -v" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" -v + CT_EndStep + + # Create a simple C program for testing. + testc="${CT_BUILD_DIR}/test.c" + printf "int main() { return 0; }\n" >"${testc}" + gccout="${CT_BUILD_DIR}/.gccout" + + CT_DoStep DEBUG "Checking that gcc can compile a trivial program" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -o "${gccout}" + rm -f "${gccout}" + CT_EndStep + + # These tests are only enabled if we need static linking on the *build* + if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then + CT_DoStep DEBUG "Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)" + CT_DoLog DEBUG "You may need to ensure that static libraries such as libc.a are installed on your system" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -o "${gccout}" + rm -f "${gccout}" + CT_EndStep + fi + if [ "${CT_WANTS_STATIC_LINK_CXX}" = "y" ]; then + CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_WANTS_STATIC_LINK_CXX)" + CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -lstdc++ -o "${gccout}" + rm -f "${gccout}" + CT_EndStep + fi + rm -f "${testc}" + + CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration" + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" + CT_DoExecLog DEBUG ${install} -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" + CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" + bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" + + CT_DoStep EXTRA "Dumping internal crosstool-NG configuration" + CT_DoLog EXTRA "Building a toolchain for:" + CT_DoLog EXTRA " build = ${CT_REAL_BUILD}" + CT_DoLog EXTRA " host = ${CT_REAL_HOST}" + CT_DoLog EXTRA " target = ${CT_TARGET}" + set |${grep} -E '^CT_.+=' |sort |CT_DoLog DEBUG + CT_DoLog DEBUG "Other environment:" + printenv |${grep} -v -E '^CT_.+=' |CT_DoLog DEBUG + CT_EndStep + + CT_DoStep INFO "Retrieving needed toolchain components' tarballs" + do_companion_tools_get + do_kernel_get + do_companion_libs_get + do_binutils_get + do_cc_get + do_libc_get + do_debug_get + do_test_suite_get + CT_EndStep + + if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then + if [ "${CT_FORCE_EXTRACT}" = "y" ]; then + CT_DoForceRmdir "${CT_SRC_DIR}" + CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" + fi + + CT_DoStep INFO "Extracting and patching toolchain components" + do_companion_tools_extract + do_kernel_extract + do_companion_libs_extract + do_binutils_extract + do_cc_extract + do_libc_extract + do_debug_extract + do_test_suite_extract + CT_EndStep + fi +fi + +# Now for the job by itself. Go have a coffee! +if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then + # Because of CT_RESTART, this becomes quite complex + do_stop=0 + prev_step= + [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1 + # Aha! CT_STEPS comes from steps.mk! + for step in ${CT_STEPS}; do + if [ ${do_it} -eq 0 ]; then + if [ "${CT_RESTART}" = "${step}" ]; then + CT_DoLoadState "${step}" + do_it=1 + do_stop=0 + fi + else + CT_DoSaveState ${step} + if [ ${do_stop} -eq 1 ]; then + CT_DoLog INFO "Stopping just after step '${prev_step}', as requested." + exit 0 + fi + fi + if [ ${do_it} -eq 1 ]; then + ( do_${step} ) + # POSIX 1003.1-2008 does not say if "set -e" should catch a + # sub-shell ending with !0. bash-3 does not, while bash-4 does, + # so the following line is for bash-3; bash-4 would choke above. + [ $? -eq 0 ] + # Pick up environment changes. + if [ -r "${CT_BUILD_DIR}/env.modify.sh" ]; then + CT_DoLog DEBUG "Step '${step}' modified the environment:" + CT_DoExecLog DEBUG cat "${CT_BUILD_DIR}/env.modify.sh" + . "${CT_BUILD_DIR}/env.modify.sh" + CT_DoExecLog DEBUG rm -f "${CT_BUILD_DIR}/env.modify.sh" + + fi + if [ "${CT_STOP}" = "${step}" ]; then + do_stop=1 + fi + if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then + CT_DoPause "Step '${step}' finished" + fi + fi + prev_step="${step}" + done +fi + +CT_DoEnd INFO + +# From now-on, it can become impossible to log any time, because +# either we're compressing the log file, or it can become RO any +# moment... +CT_DoLog INFO "Finishing installation (may take a few seconds)..." +CT_LogDisable +rm -f ${CT_PREFIX_DIR}/build.log.bz2 +if [ "${CT_LOG_TO_FILE}" = "y" ]; then + cp "${CT_BUILD_LOG}" "${CT_PREFIX_DIR}/build.log" + if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then + bzip2 -9 "${CT_PREFIX_DIR}/build.log" + fi +fi +if [ "${CT_PREFIX_DIR_RO}" = "y" ]; then + chmod -R a-w "${CT_PREFIX_DIR}" +fi +# CT_TEST_SUITE_DIR may not exist if only downloading or extracting +if [ "${CT_TEST_SUITE}" = "y" -a -d "${CT_TEST_SUITE_DIR}" ]; then + chmod -R u+w "${CT_TEST_SUITE_DIR}" +fi + +trap - EXIT diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in deleted file mode 100644 index 878681a..0000000 --- a/scripts/crosstool-NG.sh.in +++ /dev/null @@ -1,722 +0,0 @@ -# Copyright 2007 Yann E. MORIN -# Licensed under the GPL v2. See COPYING in the root of this package. - -# This is the main entry point to crosstool -# This will: -# - download, extract and patch the toolchain components -# - build and install each components in turn -# - and eventually test the resulting toolchain - -# What this file does is prepare the environment, based upon the user-choosen -# options. It also checks the existing environment for un-friendly variables, -# and builds the tools. - -# Parse the common functions -# Note: some initialisation and sanitizing is done while parsing this file, -# most notably: -# - set trap handler on errors, -# - don't hash commands lookups, -. "${CT_LIB_DIR}/scripts/functions" - -# Read the sample settings -CT_LoadConfig - -# Yes! We can do full logging from now on! Clean any old log file content. -CT_LogEnable clean=yes - -# Check running as root -if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then - if [ $(id -u) -eq 0 ]; then - CT_DoLog ERROR "You must NOT be root to run crosstool-NG" - exit 1 - fi -fi - -# If we want an interactive debug-shell, we must ensure these FDs -# are indeed connected to a terminal (and not redirected in any way). -if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then - CT_DoLog ERROR "Can't spawn interactive debug-shell," - CT_DoLog ERROR "because stdout/stderr has been redirected." - exit 1 -fi - -CT_TrapEnvExport - -# Override the locale early, in case we ever translate crosstool-NG messages -if [ -z "${CT_NO_OVERRIDE_LC_MESSAGES}" ]; then - export LC_ALL=C - export LANG=C -fi - -# remove . from PATH since it can cause gcc build failures -CT_SanitizePath - -# Some sanity checks in the environment and needed tools -CT_DoLog INFO "Performing some trivial sanity checks" -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH+set}" -CT_TestAndAbort "Don't set LIBRARY_PATH. It screws up the build." -n "${LIBRARY_PATH+set}" -CT_TestAndAbort "Don't set LPATH. It screws up the build." -n "${LPATH+set}" -CT_TestAndAbort "Don't set CPATH. It screws up the build." -n "${CPATH+set}" -CT_TestAndAbort "Don't set C_INCLUDE_PATH. It screws up the build." -n "${C_INCLUDE_PATH+set}" -CT_TestAndAbort "Don't set CPLUS_INCLUDE_PATH. It screws up the build." -n "${CPLUS_INCLUDE_PATH+set}" -CT_TestAndAbort "Don't set OBJC_INCLUDE_PATH. It screws up the build." -n "${OBJC_INCLUDE_PATH+set}" -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS+set}" -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS+set}" -CT_TestAndAbort "Don't set CC. It screws up the build." -n "${CC+set}" -CT_TestAndAbort "Don't set CXX. It screws up the build." -n "${CXX+set}" -CT_Test "GREP_OPTIONS screws up the build. Unsetting." -n "${GREP_OPTIONS+set}" -unset GREP_OPTIONS -# Workaround against openSUSE 12.1 that breaks ./configure for cross-compilation: -export CONFIG_SITE= - -# Some sanity checks on paths content -for d in \ - LOCAL_TARBALLS \ - WORK \ - PREFIX \ - INSTALL \ - ; do - eval dir="\${CT_${d}_DIR}" - case "${dir}" in - *" "*) - CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things." - ;; - *:*) - CT_Abort "'CT_${d}_DIR'='${dir}' contains a colon in it.\nDon't use colons in paths, it breaks things." - ;; - *,*) - CT_Abort "'CT_${d}_DIR'='${dir}' contains a comma in it.\nDon't use commas in paths, it breaks things." - ;; - esac -done - -# Where will we work? -CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}" -CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" -CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}" -CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/backtrace" - -# Check build file system case-sensitiveness -CT_DoExecLog DEBUG touch "${CT_WORK_DIR}/foo" -CT_TestAndAbort "Your file system in '${CT_WORK_DIR}' is *not* case-sensitive!" -f "${CT_WORK_DIR}/FOO" -CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/foo" - -# Check the user is using an existing SHELL to be used by ./configure and Makefiles -CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CONFIG_SHELL}" -a -x "${CT_CONFIG_SHELL}" - -# Create the bin-override early -# Contains symlinks to the tools found by ./configure -# Note: CT_DoLog and CT_DoExecLog do not use any of those tool, so -# they can be safely used -CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools" -CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'" -CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin" -cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do - tool="${line%%=*}" - # Suppress extra quoting - eval path=${line#*=} - if [ -r "${CT_LIB_DIR}/scripts/override/$tool" ]; then - tmpl="${CT_LIB_DIR}/scripts/override/$tool" - else - tmpl="${CT_LIB_DIR}/scripts/override/__default" - fi - CT_DoLog DEBUG "Creating script-override for '${tool}' -> '${path}' using '${tmpl}' template" - CT_DoExecLog ALL cp "${tmpl}" "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" - CT_DoExecLog ALL ${sed} -i -r \ - -e "s#@INSTALL_WITH_STRIP_PROGRAM@#${CT_CONFIGURE_has_install_with_strip_program}#g" \ - -e "s#@CONFIG_SHELL@#${CT_CONFIG_SHELL}#g" \ - -e "s#@TOOL_PATH@#${path}#g" \ - -e "s#@TOOLS_OVERRIDE_DIR@#${CT_TOOLS_OVERRIDE_DIR}#g" \ - "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" - CT_DoExecLog ALL chmod 700 "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" -done -export PATH="${CT_TOOLS_OVERRIDE_DIR}/bin:${PATH}" - -# Start date. Can't be done until we know the locale -# Also requires the bin-override tools -CT_STAR_DATE=$(CT_DoDate +%s%N) -CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) - -# Log real begining of build, now -CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" - -CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" -CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config -CT_EndStep - -CT_DoLog DEBUG "Unsetting MAKEFLAGS" -unset MAKEFLAGS - -# Set the shell to be used by ./configure scripts and by Makefiles (those -# that support it!). -export CONFIG_SHELL="${CT_CONFIG_SHELL}" # for ./configure -export SHELL="${CT_CONFIG_SHELL}" # for Makefiles - -CT_DoLog INFO "Building environment variables" - -# Sanity check some directories -CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}" - -# Avoid multiple '/' in the prefix dir, it breaks relocatability -CT_PREFIX_DIR="$( ${sed} -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )" - -# Second kludge: merge user-supplied target CFLAGS with architecture-provided -# target CFLAGS. Do the same for LDFLAGS in case it happens in the future. -# Put user-supplied flags at the end, so that they take precedence. -CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}" -CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" - -# FIXME move to gcc.sh -CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) -CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) - -# Starting with 1.0.20, applications using uClibc-ng do not link with -# the default libgcc_c_spec used by GCC if only static libc.a exists - unless -# -static is thrown in. The difference is that with -static, gcc passes -# "--start-group -lgcc -lc --end-group" and without -static, it passes -# "-lgcc -lc -lgcc" instead. The latter leaves a symbol from 2nd libgcc -# (dl_iterate_phdr) unresolved because -lc is already done at this point. -# Force static link on the target. -if [ "${CT_SHARED_LIBS}" != "y" ]; then - CT_TARGET_LDFLAGS+=" -static" -fi - -# Compute the package version string -if [ "${CT_SHOW_CT_VERSION}" = "y" ]; then - CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}" -else - CT_PKGVERSION="${CT_TOOLCHAIN_PKGVERSION}" -fi - -# Compute the working directories names -CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" -CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src" -CT_SRC_DIR="${CT_BUILD_TOP_DIR}/src" -CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" -CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" -# Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a -# sub-dir. So we won't have to save/restore it, not even create it. -# In case of cross or native, host-complibs are used for build-complibs; -# in case of canadian or cross-native, host-complibs are specific -# Note about BUILD_COMPTOOLS_DIR: if installing companion tools for "host" in -# a native or simple cross, we can can use the same binaries we built for -# "build". However, we need companion tools for "build" early - as other -# components may depend on them - so we may skip building for "host" rather -# than for "build" in that case. -case "${CT_TOOLCHAIN_TYPE}" in - native|cross) - CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" - if [ -n "${CT_COMP_TOOLS_FOR_HOST}" ]; then - CT_BUILD_COMPTOOLS_DIR="${CT_PREFIX_DIR}" - else - CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" - fi - ;; - canadian|cross-native) - CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}/complibs-host" - CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}" - ;; -esac - -# Compute test suite install directory -CT_TEST_SUITE_DIR=${CT_PREFIX_DIR}/test-suite - -# We must ensure that we can restart if asked for! -if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then - CT_DoLog ERROR "You asked to restart a non-restartable build" - CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS" - CT_DoLog ERROR "in the config options for the previous build, or the state" - CT_DoLog ERROR "directory for the previous build was deleted." - CT_Abort "I will stop here to avoid any carnage" -fi - -# If the local tarball directory does not exist, say so, and don't try to save there! -if [ "${CT_SAVE_TARBALLS}" = "y" \ - -a ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then - CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist." - CT_DoLog WARN "Will not save downloaded tarballs to local storage." - CT_SAVE_TARBALLS= -fi - -# Check now if we can write to the destination directory: -if [ -d "${CT_PREFIX_DIR}" ]; then - CT_TestAndAbort "Destination directory '${CT_PREFIX_DIR}' is not removable" ! -w $(dirname "${CT_PREFIX_DIR}") -fi - -# Good, now grab a bit of informations on the system we're being run on, -# just in case something goes awok, and it's not our fault: -CT_SYS_USER=$(id -un) -CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true) -# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name. -CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}" -CT_SYS_KERNEL=$(uname -s) -CT_SYS_REVISION=$(uname -r) -CT_SYS_OS=$(uname -s) -CT_SYS_MACHINE=$(uname -m) -CT_SYS_PROCESSOR=$(uname -p) -CT_SYS_GCC=$(${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX} -dumpversion) -CT_SYS_TARGET=$(CT_DoConfigGuess) -CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}" - -# Adjust the list of multilibs, if needed -CT_DoArchMultilibList - -CT_DoLog EXTRA "Preparing working directories" - -# Ah! The build directory shall be eradicated, even if we restart! -# Ditto for the build tools install dir -CT_DoForceRmdir "${CT_BUILD_DIR}" "${CT_BUILDTOOLS_PREFIX_DIR}" - -# Don't eradicate directories if we need to restart -if [ -z "${CT_RESTART}" ]; then - # Per-target sources: eliminate - CT_DoForceRmdir "${CT_SRC_DIR}" - # Get rid of pre-existing installed toolchain and previous build directories. - if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then - CT_DoForceRmdir "${CT_TARBALLS_DIR}" - fi - if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_COMMON_SRC_DIR}" ]; then - CT_DoForceRmdir "${CT_COMMON_SRC_DIR}" - fi - if [ -d "${CT_PREFIX_DIR}" -a "${CT_RM_RF_PREFIX_DIR}" = "y" ]; then - CT_DoForceRmdir "${CT_PREFIX_DIR}" - fi - # In case we start anew, get rid of the previously saved state directory - if [ -d "${CT_STATE_DIR}" ]; then - CT_DoForceRmdir "${CT_STATE_DIR}" - fi -fi - -# Create the directories we'll use, even if restarting: it does no harm to -# create already existent directories, and CT_BUILD_DIR needs to be created -# anyway -CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_COMMON_SRC_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" -CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}" -CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}" - -# Only create the state dir if asked for a restartable build -[ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}" - -# Check install file system case-sensitiveness -CT_DoExecLog DEBUG touch "${CT_PREFIX_DIR}/foo" -CT_TestAndAbort "Your file system in '${CT_PREFIX_DIR}' is *not* case-sensitive!" -f "${CT_PREFIX_DIR}/FOO" -CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo" - -# Kludge: CT_PREFIX_DIR might have grown read-only if -# the previous build was successful. -CT_DoExecLog ALL chmod -R u+w "${CT_PREFIX_DIR}" - -# Setting up the rest of the environment only if not restarting -if [ -z "${CT_RESTART}" ]; then - # Having .. inside CT_PREFIX breaks relocatability. - CT_SanitizeVarDir CT_PREFIX_DIR - - case "${CT_SYSROOT_NAME}" in - "") CT_SYSROOT_NAME="sysroot";; - .) CT_Abort "Sysroot name is set to '.' which is forbidden";; - *' '*) CT_Abort "Sysroot name contains forbidden space(s): '${CT_SYSROOT_NAME}'";; - */*) CT_Abort "Sysroot name contains forbidden slash(es): '${CT_SYSROOT_NAME}'";; - esac - - # Arrange paths depending on whether we use sysroot or not. - if [ "${CT_USE_SYSROOT}" = "y" ]; then - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}" - CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root" - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include" - CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR - CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - CT_CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - CT_CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get - # confused when $sysroot/usr/include is not present. - # Note: --prefix=/usr is magic! - # See http://www.gnu.org/software/libc/FAQ.html#s-2.2 - else - # plain old way. All libraries in prefix/target/lib - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}" - CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}" - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include" - CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR - # hack! Always use --with-sysroot for binutils. - # binutils 2.14 and later obey it, older binutils ignore it. - # Lets you build a working 32->64 bit cross gcc - CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - # Use --with-headers, else final gcc will define disable_glibc while - # building libgcc, and you'll have no profiling - CT_CC_CORE_SYSROOT_ARG="--without-headers" - CT_CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" - fi - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" - CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" - CT_DoExecLog ALL mkdir -p "${CT_HEADERS_DIR}" - - # Need the non-multilib directories: GCC's multi-os-directory is based off them, so - # even if the /lib is not used for any of the multilibs, it must be present so that - # the paths like 'lib/../lib64' still work. - CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib" - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib" - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib" - - # Determine build system if not set by the user - if [ -z "${CT_BUILD}" ]; then - CT_BUILD=$(CT_DoConfigGuess) - fi - - # Prepare mangling patterns to later modify BUILD and HOST (see below) - case "${CT_TOOLCHAIN_TYPE}" in - cross) - # A cross-compiler runs on the same machine it is built on - CT_HOST="${CT_BUILD}" - build_mangle="build_" - host_mangle="build_" - target_mangle="" - install_build_tools_for="BUILD" - ;; - canadian) - build_mangle="build_" - host_mangle="host_" - target_mangle="" - install_build_tools_for="BUILD HOST" - ;; - *) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!" - ;; - esac - - # Save the real tuples to generate shell-wrappers to the real tools - CT_REAL_BUILD="${CT_BUILD}" - CT_REAL_HOST="${CT_HOST}" - CT_REAL_TARGET="${CT_TARGET}" - - # Canonicalise CT_BUILD and CT_HOST - # Not only will it give us full-qualified tuples, but it will also ensure - # that they are valid tuples (in case of typo with user-provided tuples) - # That's way better than trying to rewrite config.sub ourselves... - # CT_TARGET is already made canonical in CT_DoBuildTargetTuple - CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}") - CT_HOST=$(CT_DoConfigSub "${CT_HOST}") - - # Modify BUILD and HOST so that gcc always generate a cross-compiler - # even if any of the build, host or target machines are the same. - # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to - # support canadain build, later... - CT_BUILD="${CT_BUILD/-/-${build_mangle}}" - CT_HOST="${CT_HOST/-/-${host_mangle}}" - CT_TARGET="${CT_TARGET/-/-${target_mangle}}" - - # Now we have mangled our BUILD and HOST tuples, we must fake the new - # cross-tools for those mangled tuples. - CT_DoLog DEBUG "Making build system tools available" - for m in ${install_build_tools_for}; do - r="CT_REAL_${m}" - v="CT_${m}" - p="CT_${m}_PREFIX" - s="CT_${m}_SUFFIX" - if [ -n "${!p}" ]; then - t="${!p}" - else - t="${!r}-" - fi - - for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do - # First try with prefix + suffix - # Then try with prefix only - # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST - # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST - # This is needed, because some tools have a prefix and - # a suffix (eg. gcc), while others may have only one, - # or even none (eg. binutils) - where=$(CT_Which "${t}${tool}${!s}") - [ -z "${where}" ] && where=$(CT_Which "${t}${tool}") - if [ -z "${where}" \ - -a \( "${m}" = "BUILD" \ - -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then - where=$(CT_Which "${tool}${!s}") - fi - if [ -z "${where}" \ - -a \( "${m}" = "BUILD" \ - -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then - where=$(CT_Which "${tool}") - fi - - # Not all tools are available for all platforms, but some are required. - if [ -n "${where}" ]; then - CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" - printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" - CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" - else - case "${tool}" in - # We'll at least need some of them... - ar|as|gcc|ld|nm|objcopy|objdump|ranlib) - CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" - ;; - # Some are conditionnally required - # Add them in alphabetical (C locale) ordering - g++) - # g++ (needed for companion lib), only needed for HOST - CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${m}" = "HOST" - ;; - gcj) - CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_CC_LANG_JAVA}" = "y" - ;; - strip) - CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" - ;; - # If any other is missing, only warn at low level - *) - # It does not deserve a WARN level. - CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required." - ;; - esac - fi - done - done - - # Some makeinfo versions are a pain in [put your most sensible body part here]. - # Go ahead with those, by creating a wrapper that keeps partial files, and that - # never fails: - CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'" - printf "#${BANG}${CT_CONFIG_SHELL}\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo" - CT_DoExecLog ALL chmod 700 "${CT_BUILDTOOLS_PREFIX_DIR}/bin/makeinfo" - - # Carefully add paths in the order we want them: - # - first try in ${CT_PREFIX_DIR}/bin - # - then try the buildtools dir - # - fall back to searching user's PATH - # Of course, neither cross-native nor canadian can run on BUILD, - # so don't add those PATHs in this case... - # For native and simple cross, build==host, combine the extra CFLAGS/LDFLAGS - # supplied for both (so that it doesn't matter where the user supplied them). - case "${CT_TOOLCHAIN_TYPE}" in - cross|native) - export PATH="${CT_PREFIX_DIR}/bin:${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}" - bh_cflags="${CT_EXTRA_CFLAGS_FOR_BUILD} ${CT_EXTRA_CFLAGS_FOR_HOST}" - bh_ldflags="${CT_EXTRA_LDFLAGS_FOR_BUILD} ${CT_EXTRA_LDFLAGS_FOR_HOST}" - CT_EXTRA_CFLAGS_FOR_BUILD="${bh_cflags}" - CT_EXTRA_CFLAGS_FOR_HOST="${bh_cflags}" - CT_EXTRA_LDFLAGS_FOR_BUILD="${bh_ldflags}" - CT_EXTRA_LDFLAGS_FOR_HOST="${bh_ldflags}" - ;; - canadian|cross-native) - export PATH="${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}" - # build!=host in this case - ;; - *) - ;; - esac - - # Help build gcc - # Explicitly optimise, else the lines below will overide the - # package's default optimisation flags - CT_CFLAGS_FOR_BUILD="-O2 -g -I${CT_BUILDTOOLS_PREFIX_DIR}/include" - CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}" - CT_LDFLAGS_FOR_BUILD="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib" - CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}" - - case "${CT_BUILD}" in - *darwin*) - # Two issues while building on MacOS. Really, we should be checking for - # clang instead. - # - gettext static library fails to link unless CoreFoundation framework - # is included - # - ranlib on MacOS does not include common symbols into the symbol index - # for a static library, and hence linker fails to pull in the right - # archive members; hence, avoid common symbols. Alternative is to - # have ranlib wrapper in buildtools/bin supply -c option. - CT_CFLAGS_FOR_BUILD+=" -fno-common" - CT_LDFLAGS_FOR_BUILD+=" -framework CoreFoundation" - ;; - esac - - CT_DoLog DEBUG "CFLAGS for build compiler: '${CT_CFLAGS_FOR_BUILD}'" - CT_DoLog DEBUG "LDFLAGS for build compiler: '${CT_LDFLAGS_FOR_BUILD}'" - - # Help host gcc - # Explicitly optimise, else the lines below will overide the - # package's default optimisation flags - CT_CFLAGS_FOR_HOST="-O2 -g" - [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe" - CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include" - CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}" - CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib" - CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}" - case "${CT_HOST}" in - *darwin*) - # Same as above, for host - CT_CFLAGS_FOR_HOST+=" -fno-common" - CT_LDFLAGS_FOR_HOST+=" -framework CoreFoundation" - ;; - esac - CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'" - CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'" - - # And help make go faster - JOBSFLAGS= - # Override the configured jobs with what's been given on the command line - if [ -n "${CT_JOBS}" ]; then - if [ ! -z "`echo "${CT_JOBS}" | ${sed} 's/[0-9]//g'`" ]; then - CT_Abort "Number of parallel jobs must be integer." - fi - CT_PARALLEL_JOBS="${CT_JOBS}" - fi - # Use the number of processors+1 when automatically setting the number of - # parallel jobs. Fall back to 1 if the host doesn't use GLIBC. - AUTO_JOBS=$((`@@CT_cpucount@@ 2>/dev/null || echo 0` + 1)) - [ ${CT_PARALLEL_JOBS} -eq 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}" - [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" - JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}" - - # Override 'download only' option - [ -n "${CT_SOURCE}" ] && CT_ONLY_DOWNLOAD=y - - # Now that we've set up $PATH and $CT_CFLAGS_FOR_HOST, sanity test that gcc - # is runnable so that the user can troubleshoot problems if not. - CT_DoStep DEBUG "Checking that we can run gcc -v" - CT_DoExecLog DEBUG "${CT_HOST}-gcc" -v - CT_EndStep - - # Create a simple C program for testing. - testc="${CT_BUILD_DIR}/test.c" - printf "int main() { return 0; }\n" >"${testc}" - gccout="${CT_BUILD_DIR}/.gccout" - - CT_DoStep DEBUG "Checking that gcc can compile a trivial program" - CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -o "${gccout}" - rm -f "${gccout}" - CT_EndStep - - # These tests are only enabled if we need static linking on the *build* - if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then - CT_DoStep DEBUG "Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)" - CT_DoLog DEBUG "You may need to ensure that static libraries such as libc.a are installed on your system" - CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -o "${gccout}" - rm -f "${gccout}" - CT_EndStep - fi - if [ "${CT_WANTS_STATIC_LINK_CXX}" = "y" ]; then - CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_WANTS_STATIC_LINK_CXX)" - CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system" - CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -lstdc++ -o "${gccout}" - rm -f "${gccout}" - CT_EndStep - fi - rm -f "${testc}" - - CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration" - CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" - CT_DoExecLog DEBUG ${install} -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" - CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" - bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" - - CT_DoStep EXTRA "Dumping internal crosstool-NG configuration" - CT_DoLog EXTRA "Building a toolchain for:" - CT_DoLog EXTRA " build = ${CT_REAL_BUILD}" - CT_DoLog EXTRA " host = ${CT_REAL_HOST}" - CT_DoLog EXTRA " target = ${CT_TARGET}" - set |${grep} -E '^CT_.+=' |sort |CT_DoLog DEBUG - CT_DoLog DEBUG "Other environment:" - printenv |${grep} -v -E '^CT_.+=' |CT_DoLog DEBUG - CT_EndStep - - CT_DoStep INFO "Retrieving needed toolchain components' tarballs" - do_companion_tools_get - do_kernel_get - do_companion_libs_get - do_binutils_get - do_cc_get - do_libc_get - do_debug_get - do_test_suite_get - CT_EndStep - - if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then - if [ "${CT_FORCE_EXTRACT}" = "y" ]; then - CT_DoForceRmdir "${CT_SRC_DIR}" - CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" - fi - - CT_DoStep INFO "Extracting and patching toolchain components" - do_companion_tools_extract - do_kernel_extract - do_companion_libs_extract - do_binutils_extract - do_cc_extract - do_libc_extract - do_debug_extract - do_test_suite_extract - CT_EndStep - fi -fi - -# Now for the job by itself. Go have a coffee! -if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then - # Because of CT_RESTART, this becomes quite complex - do_stop=0 - prev_step= - [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1 - # Aha! CT_STEPS comes from steps.mk! - for step in ${CT_STEPS}; do - if [ ${do_it} -eq 0 ]; then - if [ "${CT_RESTART}" = "${step}" ]; then - CT_DoLoadState "${step}" - do_it=1 - do_stop=0 - fi - else - CT_DoSaveState ${step} - if [ ${do_stop} -eq 1 ]; then - CT_DoLog INFO "Stopping just after step '${prev_step}', as requested." - exit 0 - fi - fi - if [ ${do_it} -eq 1 ]; then - ( do_${step} ) - # POSIX 1003.1-2008 does not say if "set -e" should catch a - # sub-shell ending with !0. bash-3 does not, while bash-4 does, - # so the following line is for bash-3; bash-4 would choke above. - [ $? -eq 0 ] - # Pick up environment changes. - if [ -r "${CT_BUILD_DIR}/env.modify.sh" ]; then - CT_DoLog DEBUG "Step '${step}' modified the environment:" - CT_DoExecLog DEBUG cat "${CT_BUILD_DIR}/env.modify.sh" - . "${CT_BUILD_DIR}/env.modify.sh" - CT_DoExecLog DEBUG rm -f "${CT_BUILD_DIR}/env.modify.sh" - - fi - if [ "${CT_STOP}" = "${step}" ]; then - do_stop=1 - fi - if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then - CT_DoPause "Step '${step}' finished" - fi - fi - prev_step="${step}" - done -fi - -CT_DoEnd INFO - -# From now-on, it can become impossible to log any time, because -# either we're compressing the log file, or it can become RO any -# moment... -CT_DoLog INFO "Finishing installation (may take a few seconds)..." -CT_LogDisable -rm -f ${CT_PREFIX_DIR}/build.log.bz2 -if [ "${CT_LOG_TO_FILE}" = "y" ]; then - cp "${CT_BUILD_LOG}" "${CT_PREFIX_DIR}/build.log" - if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then - bzip2 -9 "${CT_PREFIX_DIR}/build.log" - fi -fi -if [ "${CT_PREFIX_DIR_RO}" = "y" ]; then - chmod -R a-w "${CT_PREFIX_DIR}" -fi -# CT_TEST_SUITE_DIR may not exist if only downloading or extracting -if [ "${CT_TEST_SUITE}" = "y" -a -d "${CT_TEST_SUITE_DIR}" ]; then - chmod -R u+w "${CT_TEST_SUITE_DIR}" -fi - -trap - EXIT diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh new file mode 100644 index 0000000..5fab6d9 --- /dev/null +++ b/scripts/saveSample.sh @@ -0,0 +1,110 @@ +# This script is responsible for saving the current configuration into a +# sample to be used later on as a pre-configured target. + +# What we need to save: +# - the .config file +# - the uClibc .config file if uClibc selected +# - info about who reported the sample + +# Parse the tools' paths configuration +. "${CT_LIB_DIR}/paths.sh" +. "${CT_LIB_DIR}/scripts/functions" + +CT_LoadConfig + +# We can not reliably save a sample which either uses local patches +# and/or custom Linux kernel headers. Warn the user about this issue +# and continue if he/she confirms sving the sample. +if [ "${CT_CUSTOM_PATCH}" = "y" ]; then + echo "You are using local patches." + echo "You will not be able to (easily) share this sample in this case." + read -p "Press Ctrl-C to stop now, or Enter to continue..." +fi + +# Do not use a progress bar +unset CT_LOG_PROGRESS_BAR + +# Override log options +unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL +CT_LOG_WARN=y +CT_LOG_LEVEL_MAX="WARN" + +# Compute the name of the sample directory +case "${CT_TOOLCHAIN_TYPE}" in + cross) samp_name="${CT_TARGET}";; + canadian) samp_name="${CT_HOST},${CT_TARGET}";; + *) CT_Abort "Unsupported toolchain type '${CT_TOOLCHAIN_TYPE}'";; +esac +samp_dir="samples/${samp_name}" +mkdir -p "${samp_dir}" + +# Tweak the .config file: remove the options that we want to keep +# at default setting in samples. +force_default_opts=( \ + PREFIX_DIR LOG_TO_FILE LOG_FILE_COMPRESS \ + LOCAL_TARBALLS_DIR SAVE_TARBALLS \ + LOG_ERROR LOG_WARN LOG_INFO LOG_EXTRA LOG_ALL LOG_DEBUG \ + LOG_PROGRESS_BAR + ) +regexp=${force_default_opts[*]} +regexp=${regexp// /|} +${grep} -v -E '^(# )?CT_('"${regexp}"')' .config > .defconfig + +# Function to copy a file to the sample directory +# Needed in case the file is already there (think of a previously available sample) +# Usage: CT_DoAddFileToSample +CT_DoAddFileToSample() { + source="$1" + dest="$2" + inode_s=$(ls -i "${source}" | ${awk} '{ print $1; }') + inode_d=$(ls -i "${dest}" 2>/dev/null | ${awk} '{ print $1; }' || true) + if [ "${inode_s}" != "${inode_d}" ]; then + cp "${source}" "${dest}" + fi +} + +if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then + samp_top_dir="\${CT_LIB_DIR}" +else + samp_top_dir="\${CT_TOP_DIR}" +fi + +# Save the uClibc .config file +if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then + # We save the file, and then point the saved sample to this file + CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}.config" + "${sed}" -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE)=.+$|\1="'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}.config"|;' \ + .defconfig +else + # remove any dangling files + for f in "${samp_dir}/${CT_LIBC}-"*.config; do + if [ -f "${f}" ]; then rm -f "${f}"; fi + done +fi + +# Now, actually save the defconfig +export KCONFIG_CONFIG="$(pwd)/.defconfig" +srctree="${CT_LIB_DIR}" ${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" +rm -f .defconfig + +# Fill-in the reported-by info +[ -f "${samp_dir}/reported.by" ] && . "${samp_dir}/reported.by" +old_name="${reporter_name}" +old_url="${reporter_url}" +old_comment="${reporter_comment}" +read -p "Reporter name [${reporter_name}]: " reporter_name +read -p "Reporter URL [${reporter_url}]: " reporter_url +if [ -n "${reporter_comment}" ]; then + echo "Old comment:" + printf "${reporter_comment}\n" | ${sed} -r -e 's/^/ > /;' +fi +echo "Reporter comment (Ctrl-D to finish, '.' to use previous):" +reporter_comment=$(cat) +if [ "${reporter_comment}" = "." ]; then + reporter_comment="${old_comment}" +fi + +( echo "reporter_name=\"${reporter_name:=${old_name}}\"" + echo "reporter_url=\"${reporter_url:=${old_url}}\"" + printf "reporter_comment=\"${reporter_comment}\"\n" +) >"${samp_dir}/reported.by" diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in deleted file mode 100644 index 5fab6d9..0000000 --- a/scripts/saveSample.sh.in +++ /dev/null @@ -1,110 +0,0 @@ -# This script is responsible for saving the current configuration into a -# sample to be used later on as a pre-configured target. - -# What we need to save: -# - the .config file -# - the uClibc .config file if uClibc selected -# - info about who reported the sample - -# Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" -. "${CT_LIB_DIR}/scripts/functions" - -CT_LoadConfig - -# We can not reliably save a sample which either uses local patches -# and/or custom Linux kernel headers. Warn the user about this issue -# and continue if he/she confirms sving the sample. -if [ "${CT_CUSTOM_PATCH}" = "y" ]; then - echo "You are using local patches." - echo "You will not be able to (easily) share this sample in this case." - read -p "Press Ctrl-C to stop now, or Enter to continue..." -fi - -# Do not use a progress bar -unset CT_LOG_PROGRESS_BAR - -# Override log options -unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL -CT_LOG_WARN=y -CT_LOG_LEVEL_MAX="WARN" - -# Compute the name of the sample directory -case "${CT_TOOLCHAIN_TYPE}" in - cross) samp_name="${CT_TARGET}";; - canadian) samp_name="${CT_HOST},${CT_TARGET}";; - *) CT_Abort "Unsupported toolchain type '${CT_TOOLCHAIN_TYPE}'";; -esac -samp_dir="samples/${samp_name}" -mkdir -p "${samp_dir}" - -# Tweak the .config file: remove the options that we want to keep -# at default setting in samples. -force_default_opts=( \ - PREFIX_DIR LOG_TO_FILE LOG_FILE_COMPRESS \ - LOCAL_TARBALLS_DIR SAVE_TARBALLS \ - LOG_ERROR LOG_WARN LOG_INFO LOG_EXTRA LOG_ALL LOG_DEBUG \ - LOG_PROGRESS_BAR - ) -regexp=${force_default_opts[*]} -regexp=${regexp// /|} -${grep} -v -E '^(# )?CT_('"${regexp}"')' .config > .defconfig - -# Function to copy a file to the sample directory -# Needed in case the file is already there (think of a previously available sample) -# Usage: CT_DoAddFileToSample -CT_DoAddFileToSample() { - source="$1" - dest="$2" - inode_s=$(ls -i "${source}" | ${awk} '{ print $1; }') - inode_d=$(ls -i "${dest}" 2>/dev/null | ${awk} '{ print $1; }' || true) - if [ "${inode_s}" != "${inode_d}" ]; then - cp "${source}" "${dest}" - fi -} - -if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then - samp_top_dir="\${CT_LIB_DIR}" -else - samp_top_dir="\${CT_TOP_DIR}" -fi - -# Save the uClibc .config file -if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then - # We save the file, and then point the saved sample to this file - CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}.config" - "${sed}" -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE)=.+$|\1="'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}.config"|;' \ - .defconfig -else - # remove any dangling files - for f in "${samp_dir}/${CT_LIBC}-"*.config; do - if [ -f "${f}" ]; then rm -f "${f}"; fi - done -fi - -# Now, actually save the defconfig -export KCONFIG_CONFIG="$(pwd)/.defconfig" -srctree="${CT_LIB_DIR}" ${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" -rm -f .defconfig - -# Fill-in the reported-by info -[ -f "${samp_dir}/reported.by" ] && . "${samp_dir}/reported.by" -old_name="${reporter_name}" -old_url="${reporter_url}" -old_comment="${reporter_comment}" -read -p "Reporter name [${reporter_name}]: " reporter_name -read -p "Reporter URL [${reporter_url}]: " reporter_url -if [ -n "${reporter_comment}" ]; then - echo "Old comment:" - printf "${reporter_comment}\n" | ${sed} -r -e 's/^/ > /;' -fi -echo "Reporter comment (Ctrl-D to finish, '.' to use previous):" -reporter_comment=$(cat) -if [ "${reporter_comment}" = "." ]; then - reporter_comment="${old_comment}" -fi - -( echo "reporter_name=\"${reporter_name:=${old_name}}\"" - echo "reporter_url=\"${reporter_url:=${old_url}}\"" - printf "reporter_comment=\"${reporter_comment}\"\n" -) >"${samp_dir}/reported.by" diff --git a/scripts/scripts.mk b/scripts/scripts.mk new file mode 100644 index 0000000..d77f1a7 --- /dev/null +++ b/scripts/scripts.mk @@ -0,0 +1,64 @@ +# Makefile for the scripts/ sub-directory + +# Here, we can update the config.* scripts. +# If we're in CT_LIB_DIR, then CT_LIB_DIR == CT_TOP_DIR, and we can update those +# scripts for later inclusion mainline. If CT_LIB_DIR != CT_TOP_DIR, then those +# scripts are downloaded only for use in CT_TOP_DIR. + +# ---------------------------------------------------------- +# The tools help entry + +help-distrib:: + @echo ' updatetools - Update the config tools' + +# ---------------------------------------------------------- +# Where to get tools from, and where to store them into +# The tools are: config.guess and config.sub + +CONFIG_SUB_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" +CONFIG_SUB_DEST=scripts/config.sub +CONFIG_GUESS_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" +CONFIG_GUESS_DEST=scripts/config.guess + +PHONY += updatetools +updatetools: $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST) + +# ---------------------------------------------------------- +# How to retrieve the tools + +ifneq ($(strip $(V)),2) + wget_silent_opt = -o /dev/null + curl_silent_opt = --silent +endif + +ifneq ($(CT_wget),) +download_cmd = $(CT_wget) --passive-ftp $(wget_silent_opt) -O $@ +else +ifneq ($(CT_curl),) +download_cmd = $(CT_curl) --ftp-pasv $(curl_silent_opt) -o $@ +else +download_cmd = $(error wget or curl needed for downloads) +endif +endif + +PHONY += scripts +scripts: + @$(CT_ECHO) ' MKDIR $@' + $(SILENT)mkdir -p $@ + +$(CONFIG_SUB_DEST): scripts FORCE + @$(CT_ECHO) ' DOWNLOAD $@' + $(SILENT)$(download_cmd) $(CONFIG_SUB_SRC) + $(SILENT)chmod u+rwx,go+rx-w $@ + +$(CONFIG_GUESS_DEST): scripts FORCE + @$(CT_ECHO) ' DOWNLOAD $@' + $(SILENT)$(download_cmd) $(CONFIG_GUESS_SRC) + $(SILENT)chmod u+rwx,go+rx-w $@ + +# ---------------------------------------------------------- +# Clean up the mess + +distclean:: + @$(CT_ECHO) " CLEAN scripts" + $(SILENT)[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/scripts diff --git a/scripts/scripts.mk.in b/scripts/scripts.mk.in deleted file mode 100644 index 99b9d76..0000000 --- a/scripts/scripts.mk.in +++ /dev/null @@ -1,64 +0,0 @@ -# Makefile for the scripts/ sub-directory - -# Here, we can update the config.* scripts. -# If we're in CT_LIB_DIR, then CT_LIB_DIR == CT_TOP_DIR, and we can update those -# scripts for later inclusion mainline. If CT_LIB_DIR != CT_TOP_DIR, then those -# scripts are downloaded only for use in CT_TOP_DIR. - -# ---------------------------------------------------------- -# The tools help entry - -help-distrib:: - @echo ' updatetools - Update the config tools' - -# ---------------------------------------------------------- -# Where to get tools from, and where to store them into -# The tools are: config.guess and config.sub - -CONFIG_SUB_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" -CONFIG_SUB_DEST=scripts/config.sub -CONFIG_GUESS_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" -CONFIG_GUESS_DEST=scripts/config.guess - -PHONY += updatetools -updatetools: $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST) - -# ---------------------------------------------------------- -# How to retrieve the tools - -ifneq ($(strip $(V)),2) - wget_silent_opt = -o /dev/null - curl_silent_opt = --silent -endif - -ifneq (@@CT_wget@@,) -download_cmd = wget --passive-ftp $(wget_silent_opt) -O $@ -else -ifneq (@@CT_curl@@,) -download_cmd = curl --ftp-pasv $(curl_silent_opt) -o $@ -else -download_cmd = $(error wget or curl needed for downloads) -endif -endif - -PHONY += scripts -scripts: - @$(CT_ECHO) ' MKDIR $@' - $(SILENT)mkdir -p $@ - -$(CONFIG_SUB_DEST): scripts FORCE - @$(CT_ECHO) ' DOWNLOAD $@' - $(SILENT)$(download_cmd) $(CONFIG_SUB_SRC) - $(SILENT)chmod u+rwx,go+rx-w $@ - -$(CONFIG_GUESS_DEST): scripts FORCE - @$(CT_ECHO) ' DOWNLOAD $@' - $(SILENT)$(download_cmd) $(CONFIG_GUESS_SRC) - $(SILENT)chmod u+rwx,go+rx-w $@ - -# ---------------------------------------------------------- -# Clean up the mess - -distclean:: - @$(CT_ECHO) " CLEAN scripts" - $(SILENT)[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/scripts -- cgit v0.10.2-6-g49f6 From 9dc94f36627ec79721e485bb4ae50af9fb67c9fc Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 23 Feb 2018 19:05:41 -0800 Subject: Install "pure data" directories ... and update .gitignore. Survives 'make distcheck'. Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index 292a4f5..eb7d491 100644 --- a/.gitignore +++ b/.gitignore @@ -7,15 +7,15 @@ config.log config.status Makefile Makefile.in -*ct-ng* +ct-ng !ct-ng.comp !ct-ng.in paths.* -!paths.in config/configure.in config/gen/ config/versions/ .config +verbatim-data.mk maintainer/package-versions # Temporaries @@ -26,9 +26,7 @@ temp.* # This is the place where toolchains are built .build/ -# .. and the legacy location -targets/ # .. and log for 'build-all' -.build-all +.build-all/ # .. and release creation -release +release/ diff --git a/Makefile.am b/Makefile.am index 37996f8..c58c45f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1,16 @@ ## Process this file with automake to produce Makefile.in ## vim: set noet : +include verbatim-data.mk + SUBDIRS = kconfig bin_SCRIPTS = ct-ng CLEANFILES = $(bin_SCRIPTS) EXTRA_DIST = ct-ng.in bootstrap +nobase_dist_pkgdata_DATA = $(verbatim_data) + do_subst = ( @SED@ \ -e 's,[@]bindir[@],$(bindir),g' \ -e 's,[@]libdir[@],$(libdir),g' \ diff --git a/bootstrap b/bootstrap index 25453de..d5d17d4 100755 --- a/bootstrap +++ b/bootstrap @@ -738,6 +738,15 @@ gen_selection menu debug "Debug facilities" gen_selection menu comp_tools "Companion tools" gen_selection menu comp_libs "Companion libraries" +msg "*** Gathering the list of data files to install" +{ + echo -n "verbatim_data =" + find config contrib packages samples scripts -type f | LANG=C sort | while read f; do + echo " \\" + echo -n " ${f}" + done +} > verbatim-data.mk + msg "*** Running autoreconf" autoreconf -Wall --force diff --git a/configure.ac b/configure.ac index bd7ccb4..20d5b42 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,11 @@ AC_CONFIG_AUX_DIR([scripts]) AC_CONFIG_MACRO_DIR([m4]) # TBD try to use gnu strictness? Just add the missing files? -AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2 subdir-objects]) +# Set automake defaults: +# - Tarballs are compressed with xz and bzip2 +# - Object files are generated in a subdirectory (new default in automake) +# - Request new tar format (old, tar-v7, breaks on long paths we have) +AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2 subdir-objects tar-pax]) #-------------------------------------------------------------------- # Allow dummy --{en,dis}able-{static,shared} diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am index 413d944..a54c170 100644 --- a/kconfig/Makefile.am +++ b/kconfig/Makefile.am @@ -1,16 +1,21 @@ ## vim: set noet : ## TBD turn off program renaming for these? Or account for it in ct-ng script? +## TBD when kconfig is split into a subpackage, need to remove this option from sub-configure transform = s,x,x, ## TBD install into lib/crosstool-ng/kconfig? or move to libexec which seems more suitable pkglibexec_PROGRAMS = conf nconf mconf -AM_LFLAGS = -L -Pzconf -AM_YFLAGS = -l -b zconf -p zconf +EXTRA_DIST = zconf.y zconf.l \ + expr.h list.h lkc.h lkc_proto.h nconf.h lxdialog/dialog.h \ + confdata.c expr.c kconf_id.c menu.c symbol.c util.c +CLEANFILES = zconf.lex.c zconf.c BUILT_SOURCES = zconf.c zconf.lex.c +AM_LFLAGS = -L -Pzconf +AM_YFLAGS = -l -b zconf -p zconf AM_CPPFLAGS = -include config.h -DCONFIG_=\"CT_\" conf_SOURCES = conf.c zconf.c diff --git a/scripts/ylwrap b/scripts/ylwrap deleted file mode 120000 index efe1e02..0000000 --- a/scripts/ylwrap +++ /dev/null @@ -1 +0,0 @@ -/usr/share/automake-1.15/ylwrap \ No newline at end of file -- cgit v0.10.2-6-g49f6 From 35b830b55233bd932f0bcb32aff04abb1d9b3c75 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Mar 2018 14:44:05 -0700 Subject: Ignore/modify the list of installed files to match what was installed before. Signed-off-by: Alexey Neyman diff --git a/bootstrap b/bootstrap index d5d17d4..e388420 100755 --- a/bootstrap +++ b/bootstrap @@ -742,6 +742,18 @@ msg "*** Gathering the list of data files to install" { echo -n "verbatim_data =" find config contrib packages samples scripts -type f | LANG=C sort | while read f; do + case "${f}" in + # Skip certain files not needed at runtime (used above for generating kconfig + # fragments). + packages/*.help|packages/*.desc) + continue + ;; + # Special hack for configure.in.in - replace with the file that configure + # will produce. FIXME: create this file at the time of 'ct-ng build'. + config/configure.in.in) + f=config/configure.in + ;; + esac echo " \\" echo -n " ${f}" done -- cgit v0.10.2-6-g49f6 From 0dc8565c4fa521e71667030ec0f994aa4f3918ec Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Mar 2018 15:16:56 -0700 Subject: Merge steps.mk into ct-ng Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index eb7d491..0d917b8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ maintainer/package-versions build.log .config.old temp.* +stamp-h1 # This is the place where toolchains are built .build/ diff --git a/ct-ng.in b/ct-ng.in index 761b885..0b1e47d 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -136,6 +136,7 @@ help-samples:: help-build:: @echo @echo 'Build actions (#: force number of // jobs):' + @echo ' list-steps - List all build steps' help-clean:: @echo @@ -152,6 +153,8 @@ help-env:: else \ echo 'Environment variables (see http://crosstool-ng.github.io/docs/build/)'; \ fi + @echo ' STOP=step - Stop the build just after this step (list with list-steps)' + @echo ' RESTART=step - Restart the build just before this step (list with list-steps)' help-tail:: @echo @@ -213,6 +216,60 @@ build: .config build.%: $(SILENT)$(MAKE) -rf $(CT_NG) build CT_JOBS=$* +# The _for_build steps are noop for native and cross, +# but are actual steps for canadian and cross-native. +# Please keep the last line with a '\' and keep the following empty line: +# it helps when diffing and merging. +CT_STEPS := \ + companion_tools_for_build \ + companion_libs_for_build \ + binutils_for_build \ + companion_tools_for_host \ + companion_libs_for_host \ + binutils_for_host \ + cc_core_pass_1 \ + kernel_headers \ + libc_start_files \ + cc_core_pass_2 \ + libc \ + cc_for_build \ + cc_for_host \ + libc_post_cc \ + companion_libs_for_target \ + binutils_for_target \ + debug \ + test_suite \ + finish \ + +# Keep an empty line above this comment, so the last +# back-slash terminated line works as expected. + +# Make the list available to sub-processes (scripts/crosstool-NG.sh needs it) +export CT_STEPS + +# Print the steps list +PHONY += list-steps +list-steps: + @echo 'Available build steps, in order:' + @for step in $(CT_STEPS); do \ + echo " - $${step}"; \ + done + @echo 'Use "" as action to execute only that step.' + @echo 'Use "+" as action to execute up to that step.' + @echo 'Use "+" as action to execute from that step onward.' + +# ---------------------------------------------------------- +# This part deals with executing steps + +$(CT_STEPS): + $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) RESTART=$@ STOP=$@ build + +$(patsubst %,+%,$(CT_STEPS)): + $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) STOP=$(patsubst +%,%,$@) build + +$(patsubst %,%+,$(CT_STEPS)): + $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) RESTART=$(patsubst %+,%,$@) build + PHONY += version version: @echo 'This is crosstool-NG version $(CT_VERSION)' diff --git a/kconfig/.gitignore b/kconfig/.gitignore index 49c0689..69967bc 100644 --- a/kconfig/.gitignore +++ b/kconfig/.gitignore @@ -1,8 +1,9 @@ conf ?conf *.o -*.dep +.deps +zconf.c zconf.lex.c -zconf.tab.c *.exe Makefile +.dirstamp diff --git a/kconfig/lxdialog/.gitignore b/kconfig/lxdialog/.gitignore deleted file mode 100644 index f2e85c0..0000000 --- a/kconfig/lxdialog/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -*.dep diff --git a/steps.mk b/steps.mk deleted file mode 100644 index e3c4874..0000000 --- a/steps.mk +++ /dev/null @@ -1,69 +0,0 @@ -# Makefile for each steps -# Copyright 2006 Yann E. MORIN - -# ---------------------------------------------------------- -# This is the steps help entry - -help-build:: - @echo ' list-steps - List all build steps' - -help-env:: - @echo ' STOP=step - Stop the build just after this step (list with list-steps)' - @echo ' RESTART=step - Restart the build just before this step (list with list-steps)' - -# ---------------------------------------------------------- -# The steps list - -# The _for_build steps are noop for native and cross, -# but are actual steps for canadian and cross-native. -# Please keep the last line with a '\' and keep the following empty line: -# it helps when diffing and merging. -CT_STEPS := \ - companion_tools_for_build \ - companion_libs_for_build \ - binutils_for_build \ - companion_tools_for_host \ - companion_libs_for_host \ - binutils_for_host \ - cc_core_pass_1 \ - kernel_headers \ - libc_start_files \ - cc_core_pass_2 \ - libc \ - cc_for_build \ - cc_for_host \ - libc_post_cc \ - companion_libs_for_target \ - binutils_for_target \ - debug \ - test_suite \ - finish \ - -# Keep an empty line above this comment, so the last -# back-slash terminated line works as expected. - -# Make the list available to sub-processes (scripts/crosstool-NG.sh needs it) -export CT_STEPS - -# Print the steps list -PHONY += list-steps -list-steps: - @echo 'Available build steps, in order:' - @for step in $(CT_STEPS); do \ - echo " - $${step}"; \ - done - @echo 'Use "" as action to execute only that step.' - @echo 'Use "+" as action to execute up to that step.' - @echo 'Use "+" as action to execute from that step onward.' - -# ---------------------------------------------------------- -# This part deals with executing steps - -$(CT_STEPS): - $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) RESTART=$@ STOP=$@ build - -$(patsubst %,+%,$(CT_STEPS)): - $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) STOP=$(patsubst +%,%,$@) build - -$(patsubst %,%+,$(CT_STEPS)): - $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) RESTART=$(patsubst %+,%,$@) build -- cgit v0.10.2-6-g49f6 From 5b95b81ea90682c124d5280b64a91a249c464ee4 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Mar 2018 17:41:36 -0700 Subject: Kill gperf vestiges Generate paths.sh by configure, do away with paths.mk. Signed-off-by: Alexey Neyman diff --git a/.gitignore b/.gitignore index 0d917b8..0f5d8a9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ Makefile.in ct-ng !ct-ng.comp !ct-ng.in -paths.* +paths.sh config/configure.in config/gen/ config/versions/ diff --git a/.travis.yml b/.travis.yml index 1be7a57..aa56c43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,6 @@ addons: packages: - bison - flex - - gperf - libncurses5-dev - texinfo - help2man diff --git a/bootstrap b/bootstrap index e388420..5c6eaca 100755 --- a/bootstrap +++ b/bootstrap @@ -740,6 +740,7 @@ gen_selection menu comp_libs "Companion libraries" msg "*** Gathering the list of data files to install" { + declare -A seen_files echo -n "verbatim_data =" find config contrib packages samples scripts -type f | LANG=C sort | while read f; do case "${f}" in @@ -754,8 +755,13 @@ msg "*** Gathering the list of data files to install" f=config/configure.in ;; esac + # Checks & substitutions above may result in duplicate files + if [ -n "${seen_files[${f}]}" ]; then + continue + fi echo " \\" echo -n " ${f}" + seen_files[${f}]=y done } > verbatim-data.mk diff --git a/configure.ac b/configure.ac index 20d5b42..5e9fb18 100644 --- a/configure.ac +++ b/configure.ac @@ -297,6 +297,7 @@ AS_IF( AC_CONFIG_FILES([ Makefile + paths.sh kconfig/Makefile config/configure.in ]) diff --git a/ct-ng.in b/ct-ng.in index 0b1e47d..10ee237 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -27,7 +27,18 @@ CT_WGET := @wget@ CT_CURL := @curl@ # Paths found by ./configure -include $(CT_LIB_DIR)/paths.mk +export install = @INSTALL@ +export bash = @BASH_SHELL@ +export awk = @AWK@ +export grep = @GREP@ +export make = @MAKE@ +export sed = @SED@ +export libtool = @LIBTOOL@ +export libtoolize = @LIBTOOLIZE@ +export objcopy = @OBJCOPY@ +export objdump = @OBJDUMP@ +export readelf = @READELF@ +export patch = @PATCH@ # Some distributions (eg. Ubuntu) thought it wise to point /bin/sh to # a truly POSIX-conforming shell, ash in this case. This is not so good diff --git a/debian/control b/debian/control index f6e7eea..4c2a95e 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: devel Priority: optional Maintainer: Multiple Candidates Build-Depends: debhelper (>= 9), autoconf, automake, autotools-dev, - libncursesw5-dev, libncurses5-dev, gperf, bison, flex, + libncursesw5-dev, libncurses5-dev, bison, flex, texinfo, help2man, gawk, git, subversion, bzip2, libtool-bin Standards-Version: 3.9.8 Homepage: http://crosstool-ng.org/ diff --git a/paths.sh.in b/paths.sh.in new file mode 100644 index 0000000..c1ba0bd --- /dev/null +++ b/paths.sh.in @@ -0,0 +1,12 @@ +export install="@INSTALL@" +export bash="@BASH_SHELL@" +export awk="@AWK@" +export grep="@GREP@" +export make="@MAKE@" +export sed="@SED@" +export libtool="@LIBTOOL@" +export libtoolize="@LIBTOOLIZE@" +export objcopy="@OBJCOPY@" +export objdump="@OBJDUMP@" +export readelf="@READELF@" +export patch="@PATCH@" -- cgit v0.10.2-6-g49f6 From 5159cd7bc070a4fbf013e6c8c259ccb8ef391b0d Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Mar 2018 21:43:24 -0700 Subject: Adjust the paths to match new stuff location Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index c58c45f..72df953 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,14 +9,16 @@ bin_SCRIPTS = ct-ng CLEANFILES = $(bin_SCRIPTS) EXTRA_DIST = ct-ng.in bootstrap -nobase_dist_pkgdata_DATA = $(verbatim_data) +# paths.sh generated by configure +nobase_dist_pkgdata_DATA = $(verbatim_data) paths.sh do_subst = ( @SED@ \ -e 's,[@]bindir[@],$(bindir),g' \ - -e 's,[@]libdir[@],$(libdir),g' \ -e 's,[@]docdir[@],$(docdir),g' \ -e 's,[@]mandir[@],$(mandir),g' \ + -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ + -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ | $(SHELL) config.status --file=- ) -ct-ng: ct-ng.in - $(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv $@-t $@ +ct-ng: ct-ng.in Makefile + $(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv -f $@-t $@ diff --git a/ct-ng.in b/ct-ng.in index 10ee237..3ba0d92 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -16,7 +16,8 @@ export CT_TOP_DIR:=$(shell pwd) # Paths and values set by ./configure # Don't bother to change it other than with a new ./configure! -export CT_LIB_DIR:=@libdir@ +export CT_LIB_DIR:=@pkgdatadir@ +export CT_LIBEXEC_DIR:=@pkglibexecdir@ export CT_DOC_DIR:=@docdir@ # This is crosstool-NG version string @@ -84,9 +85,9 @@ FORCE: export KCONFIG_TOP = $(CT_LIB_DIR)/config/config.in # We need CONF for savedefconfig in scripts/saveSample.sh -export CONF := $(CT_LIB_DIR)/kconfig/conf -MCONF := $(CT_LIB_DIR)/kconfig/mconf -NCONF := $(CT_LIB_DIR)/kconfig/nconf +export CONF := $(CT_LIBEXEC_DIR)/conf +MCONF := $(CT_LIBEXEC_DIR)/mconf +NCONF := $(CT_LIBEXEC_DIR)/nconf # Used by conf/mconf/nconf to find the .in files # TBD needed? We do supply the defconfig name explicitly below @@ -182,7 +183,6 @@ help-clean:: @echo ' clean - Remove generated files' @echo ' distclean - Remove generated files, configuration and build directories' -include $(CT_LIB_DIR)/steps.mk include $(CT_LIB_DIR)/samples/samples.mk include $(CT_LIB_DIR)/scripts/scripts.mk -- cgit v0.10.2-6-g49f6 From bc542408ca3c74e977e4f30d77ae6b9a6f388cbe Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 17 Mar 2018 22:19:45 -0700 Subject: config.sub/config.guess must either be executable or be run through shell Signed-off-by: Alexey Neyman diff --git a/bootstrap b/bootstrap index 5c6eaca..e4a207b 100755 --- a/bootstrap +++ b/bootstrap @@ -743,10 +743,15 @@ msg "*** Gathering the list of data files to install" declare -A seen_files echo -n "verbatim_data =" find config contrib packages samples scripts -type f | LANG=C sort | while read f; do + # Implement some kind of .installignore for these files? case "${f}" in # Skip certain files not needed at runtime (used above for generating kconfig # fragments). - packages/*.help|packages/*.desc) + packages/*.help | packages/*.desc) + continue + ;; + # And, some file automake insists we must have + scripts/compile | scripts/missing | scripts/depcomp | scripts/ltmain.sh | scripts/install-sh) continue ;; # Special hack for configure.in.in - replace with the file that configure diff --git a/scripts/functions b/scripts/functions index 9440f0e..62966fd 100644 --- a/scripts/functions +++ b/scripts/functions @@ -986,17 +986,17 @@ CT_GetFile() # Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. CT_DoConfigGuess() { if [ -x "${CT_TOP_DIR}/scripts/config.guess" ]; then - "${CT_TOP_DIR}/scripts/config.guess" + "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.guess" else - "${CT_LIB_DIR}/scripts/config.guess" + "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.guess" fi } CT_DoConfigSub() { if [ -x "${CT_TOP_DIR}/scripts/config.sub" ]; then - "${CT_TOP_DIR}/scripts/config.sub" "$@" + "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.sub" "$@" else - "${CT_LIB_DIR}/scripts/config.sub" "$@" + "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.sub" "$@" fi } -- cgit v0.10.2-6-g49f6 From f45e29c5ca5c50bded67c295fb62e208365cf4d6 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 18 Mar 2018 14:41:30 -0700 Subject: Restore --enable-local use Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 72df953..06c90cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,11 +13,10 @@ EXTRA_DIST = ct-ng.in bootstrap nobase_dist_pkgdata_DATA = $(verbatim_data) paths.sh do_subst = ( @SED@ \ - -e 's,[@]bindir[@],$(bindir),g' \ -e 's,[@]docdir[@],$(docdir),g' \ - -e 's,[@]mandir[@],$(mandir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ + -e 's,[@]enable_local[@],$(enable_local),g' \ | $(SHELL) config.status --file=- ) ct-ng: ct-ng.in Makefile diff --git a/configure.ac b/configure.ac index 5e9fb18..c431f69 100644 --- a/configure.ac +++ b/configure.ac @@ -290,9 +290,9 @@ AS_IF( prefix=$(pwd) exec_prefix="$prefix" bindir="$prefix" - libdir="$prefix" docdir="$prefix""/docs" - datarootdir="$prefix" + pkgdatadir="$prefix" + pkglibexecdir="$prefix/kconfig" mandir="$docdir"]) AC_CONFIG_FILES([ diff --git a/ct-ng.in b/ct-ng.in index 3ba0d92..03925f9 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -16,8 +16,15 @@ export CT_TOP_DIR:=$(shell pwd) # Paths and values set by ./configure # Don't bother to change it other than with a new ./configure! +ifeq (@enable_local@,yes) +# automake does not allow to set pkgxxxdir, they are always derived from +# a respective xxxdir. So, for enable-local case, set them directly here. +export CT_LIB_DIR:=$(CT_TOP_DIR) +export CT_LIBEXEC_DIR:=$(CT_TOP_DIR)/kconfig +else export CT_LIB_DIR:=@pkgdatadir@ export CT_LIBEXEC_DIR:=@pkglibexecdir@ +endif export CT_DOC_DIR:=@docdir@ # This is crosstool-NG version string -- cgit v0.10.2-6-g49f6 From 355f6f03fba92c71f9ff8d2e26985d2c1b7a0a0b Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 18 Mar 2018 23:40:28 -0700 Subject: Cannot ignore 'make install' with automake Automake does not allow us to place the hooks before its generated actions, and does not allow us to check MAKECMDGOALS, and does not support a mechanism for disabling make install (such as noinst_SUBDIRS, requested a few times on automake mailing list). The only way I could preserve the current behavior is to have a GNUmakefile wrapper that will convert MAKECMDGOAL into a variable unknown to automake - which seems too convoluted a solution for the problem being solved. Hence the approach is to not override anything for --enable-local. It is now fully handled by selecting different values for CT_xxx_DIR in ct-ng.in; but at the build-system level, all the variables remain the same. We just don't support 'make install' in that case anymore; but the ct-ng in the working copy can be used after a regular 'make' (or 'make all'). Help message for --enable-local updated accordingly. Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 06c90cf..2e98016 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,6 @@ do_subst = ( @SED@ \ -e 's,[@]docdir[@],$(docdir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ - -e 's,[@]enable_local[@],$(enable_local),g' \ | $(SHELL) config.status --file=- ) ct-ng: ct-ng.in Makefile diff --git a/configure.ac b/configure.ac index c431f69..51e582e 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ AC_ARG_ENABLE( [local], [AS_HELP_STRING( [--enable-local], - [do not install, and use current directory])]) + [run ct-ng from the current directory; 'make install' unsupported])]) AC_SUBST([enable_local], [${enable_local:-no}]) # FIXME: I don't know why we have this. Will remove after the 1.24 release. @@ -279,22 +279,6 @@ AS_IF( [test -f version.sh -a -x version.sh], [PACKAGE_VERSION=$(./version.sh "${PACKAGE_VERSION}")]) -# We are not installing dynamic libraries that need to be found by dynamic linker. -# Install into a subdirectory. -libdir=${libdir}/${PACKAGE_TARNAME} - -# Handle the local case -AS_IF( - [test "x$enable_local" = "xyes"], - [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set]) - prefix=$(pwd) - exec_prefix="$prefix" - bindir="$prefix" - docdir="$prefix""/docs" - pkgdatadir="$prefix" - pkglibexecdir="$prefix/kconfig" - mandir="$docdir"]) - AC_CONFIG_FILES([ Makefile paths.sh diff --git a/ct-ng.in b/ct-ng.in index 03925f9..926ba71 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -14,18 +14,19 @@ export CT_NG:=$(abspath $(lastword $(MAKEFILE_LIST))) # and this is where we're working in: export CT_TOP_DIR:=$(shell pwd) -# Paths and values set by ./configure -# Don't bother to change it other than with a new ./configure! ifeq (@enable_local@,yes) # automake does not allow to set pkgxxxdir, they are always derived from # a respective xxxdir. So, for enable-local case, set them directly here. export CT_LIB_DIR:=$(CT_TOP_DIR) export CT_LIBEXEC_DIR:=$(CT_TOP_DIR)/kconfig +export CT_DOC_DIR:=$(CT_TOP_DIR)/docs else +# Paths and values set by ./configure +# Don't bother to change it other than with a new ./configure! export CT_LIB_DIR:=@pkgdatadir@ export CT_LIBEXEC_DIR:=@pkglibexecdir@ -endif export CT_DOC_DIR:=@docdir@ +endif # This is crosstool-NG version string export CT_VERSION:=@PACKAGE_VERSION@ -- cgit v0.10.2-6-g49f6 From d6f5c308f9b9564df548d7d6a245a56dbf5360bc Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 30 Mar 2018 23:09:49 -0700 Subject: No need for overriding MAKELEVEL anymore Signed-off-by: Alexey Neyman diff --git a/debian/rules b/debian/rules index b8fd445..d85609e 100755 --- a/debian/rules +++ b/debian/rules @@ -19,7 +19,7 @@ include /usr/share/dpkg/default.mk # main packaging script based on dh7 syntax %: - MAKELEVEL=0 dh $@ + dh $@ # Make sure we call ./bootstrap before running dh_auto_configure override_dh_auto_configure: @@ -28,7 +28,7 @@ override_dh_auto_configure: #Make sure to include bash completion file in the package override_dh_auto_install: - MAKELEVEL=0 dh_auto_install + dh_auto_install install -D -m 0644 ct-ng.comp $$(pwd)/debian/crosstool-ng/usr/share/bash-completion/completions/ct-ng.comp override_dh_update_autotools_config: -- cgit v0.10.2-6-g49f6 From 56d785bd006ab823caf39fc16e2ae6833ef2d780 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 31 Mar 2018 13:12:54 -0700 Subject: Docs installation - Move downloading the pages from a website to a separate script, invoke as dist hook - Install manpage Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 2e98016..e89523c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,14 +9,25 @@ bin_SCRIPTS = ct-ng CLEANFILES = $(bin_SCRIPTS) EXTRA_DIST = ct-ng.in bootstrap +man1_MANS = docs/ct-ng.1 + # paths.sh generated by configure nobase_dist_pkgdata_DATA = $(verbatim_data) paths.sh + + do_subst = ( @SED@ \ -e 's,[@]docdir[@],$(docdir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ + -e 's,[@]progname[@],'`echo ct-ng | sed '$(transform)'`',g' \ | $(SHELL) config.status --file=- ) ct-ng: ct-ng.in Makefile $(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv -f $@-t $@ + +docs/ct-ng.1: docs/ct-ng.1.in + $(AM_V_GEN)$(MKDIR_P) docs && $(do_subst) < $< >$@-t && mv -f $@-t $@ + +dist-hook: maintainer/download-docs.sh + $< $(top_distdir) diff --git a/docs/ct-ng.1.in b/docs/ct-ng.1.in index 4630f30..924bdd5 100644 --- a/docs/ct-ng.1.in +++ b/docs/ct-ng.1.in @@ -5,15 +5,15 @@ .\" Beautifying URLs .mso www.tmac .\" -.TH crosstool-NG 1 "@@CT_DATE@@" "version @@CT_VERSION@@" "User Commands" +.TH crosstool-NG 1 "@DATE@" "version @PACKAGE_VERSION@" "User Commands" .\" .\" .SH NAME -@@CT_PROG_NAME@@, crosstool-NG \- Build cross-toolchains +@progname@, crosstool-NG \- Build cross-toolchains .\" .\" .SH SYNOPSIS -.B @@CT_PROG_NAME@@ ACTION +.B @progname@ ACTION .\" .\" .SH DESCRIPTION @@ -28,7 +28,7 @@ according to the targeted processor. .SH ACTIONS Here are the most commonly used actions. For other actions, please see the documentation in -.I @@CT_DOCDIR@@ +.I @docdir@ .TP .B help Prints a little help text. @@ -53,7 +53,7 @@ configuration, and associated components' config files, into a sample. Samples are saved in their own sub-directory, named after the target's tuple, in the .I samples sub-directory of the current directory. Samples can be later recalled by calling -.B @@CT_PROG_NAME@@ +.B @progname@ with the target tuple they represent. .\" .TP @@ -117,13 +117,6 @@ configuration file. The generated toolchain is left untouched, as well as samples which are not removed. .\" .TP -.B regtest -Calls the -.B crosstool-NG -regression test suite. All samples are build, and the regression test suite is -run against every one of them. -.\" -.TP .B updatetools Updates the .I config.guess @@ -144,7 +137,7 @@ The list of steps is viewable with the action .\" .SH EXIT VALUE The -.B @@CT_PROG_NAME@@ +.B @progname@ frontend is in fact a .BR make (1) script. See the man page for @@ -170,7 +163,7 @@ Yann E. MORIN and a lot of contributors. .\" .SH SEE ALSO You can find more in-depth documentation in -.IR "@@CT_DOCDIR@@" . +.IR "@docdir@" . Please have a look at the .URL "http://www.kegel.com/crosstool" "original crosstool" " by Daniel KEGEL" diff --git a/maintainer/create-release.sh b/maintainer/create-release.sh index 6aa4cc8..498fc0a 100755 --- a/maintainer/create-release.sh +++ b/maintainer/create-release.sh @@ -1,8 +1,5 @@ #!/bin/bash -# Configurable portions -docs_git=https://github.com/crosstool-ng/crosstool-ng.github.io.git -docs_subdir=_pages/docs formats=( "bz2" "xz" ) declare -A tar_opt=( ["bz2"]=j ["xz"]=J ) digests=( md5 sha1 sha512 ) @@ -43,39 +40,9 @@ do_trace "Copying crosstool-NG" rm -rf "release/${version}" git archive --prefix="${version}/" HEAD | tar xf - -C "release" -# Clone a repository for docs. Github does not support 'git archive --remote='. -do_trace "Checking out docs" -rm -rf "release/site" -git clone --depth=1 "${docs_git}" "release/site" - # The rest of modifications are inside the release directory cd "release/${version}" -# Copy the docs instead of the MANUAL_ONLINE placeholder -do_trace "Replacing docs" -rm "docs/MANUAL_ONLINE" -mkdir -p "docs/manual" -for i in "../site/${docs_subdir}/"*.md; do - awk ' -BEGIN { skip=0; } - { - if ($0=="---") { - if (NR==1) { - skip=1 - next - } - else if (skip) { - skip=0 - next - } - } - if (!skip) { - print $0 - } - } -' < "${i}" > "docs/manual/${i##*/}" -done - # Run bootstrap before it is removed do_trace "Bootstrapping" ./bootstrap diff --git a/maintainer/download-docs.sh b/maintainer/download-docs.sh new file mode 100755 index 0000000..5ef3c6a --- /dev/null +++ b/maintainer/download-docs.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +distdir=${1:-.} + +# Configurable portions +docs_git=https://github.com/crosstool-ng/crosstool-ng.github.io.git +docs_subdir=_pages/docs + +# Clone a repository for docs. Github does not support 'git archive --remote='. +set -ex +git clone --depth=1 "${docs_git}" "${distdir}/site-docs" + +# Copy the docs instead of the MANUAL_ONLINE placeholder +mkdir -p "${distdir}/docs/manual" +for i in "${distdir}/site-docs/${docs_subdir}/"*.md; do + awk ' +BEGIN { skip=0; } + { + if ($0=="---") { + if (NR==1) { + skip=1 + next + } + else if (skip) { + skip=0 + next + } + } + if (!skip) { + print $0 + } + } +' < "${i}" > "${distdir}/docs/manual/${i##*/}" +done +rm -rf "${distdir}/site-docs" -- cgit v0.10.2-6-g49f6 From bb6c97551f7cfafea811367de0a6f382d9aec36b Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 3 Apr 2018 00:01:17 -0700 Subject: User manual installation ... when running from a release tarball. Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index e89523c..a331832 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,14 +7,33 @@ SUBDIRS = kconfig bin_SCRIPTS = ct-ng CLEANFILES = $(bin_SCRIPTS) -EXTRA_DIST = ct-ng.in bootstrap +EXTRA_DIST = ct-ng.in bootstrap docs/ct-ng.1.in man1_MANS = docs/ct-ng.1 # paths.sh generated by configure nobase_dist_pkgdata_DATA = $(verbatim_data) paths.sh - +USER_MANUAL_FILES = \ + docs/manual/1_Introduction.md \ + docs/manual/2_Installation.md \ + docs/manual/3_Configuration.md \ + docs/manual/4_Building.md \ + docs/manual/5_Toolchain_Usage.md \ + docs/manual/6_Toolchain_Types.md \ + docs/manual/7_Contributing.md \ + docs/manual/8_Internals.md \ + docs/manual/9_Toolchain_Construction.md \ + docs/manual/A_Credits.md \ + docs/manual/B_Known_issues.md \ + docs/manual/C_Setup_OS.md \ + docs/manual/D_Tutorials_features.md + +if INSTALL_USER_MANUAL +doc_DATA = $(USER_MANUAL_FILES) +else +doc_DATA = docs/MANUAL_ONLINE +endif do_subst = ( @SED@ \ -e 's,[@]docdir[@],$(docdir),g' \ @@ -30,4 +49,4 @@ docs/ct-ng.1: docs/ct-ng.1.in $(AM_V_GEN)$(MKDIR_P) docs && $(do_subst) < $< >$@-t && mv -f $@-t $@ dist-hook: maintainer/download-docs.sh - $< $(top_distdir) + $< $(top_distdir) $(USER_MANUAL_FILES) diff --git a/configure.ac b/configure.ac index 51e582e..c7b6f5a 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ([2.67]) # FIXME Temporary hack until the next release (we'll switch to plain numeric tags then) -# TBD need to quote sed expression +# FIXME need to quote sed expression AC_INIT( [crosstool-NG], [m4_esyscmd_s([git describe --always --dirty | sed s,^crosstool-ng-,,])], @@ -14,13 +14,16 @@ AC_INIT( AC_CONFIG_AUX_DIR([scripts]) AC_CONFIG_MACRO_DIR([m4]) -# TBD try to use gnu strictness? Just add the missing files? +# FIXME try to use gnu strictness? Just add the missing files? # Set automake defaults: # - Tarballs are compressed with xz and bzip2 # - Object files are generated in a subdirectory (new default in automake) # - Request new tar format (old, tar-v7, breaks on long paths we have) AM_INIT_AUTOMAKE([-Wall -Werror foreign no-dist-gzip dist-xz dist-bzip2 subdir-objects tar-pax]) +# Safety check per autoconf best practices +AC_CONFIG_SRCDIR([ct-ng.in]) + #-------------------------------------------------------------------- # Allow dummy --{en,dis}able-{static,shared} AC_ARG_ENABLE( @@ -274,6 +277,11 @@ AH_BOTTOM([ AX_BUILD_DATE_EPOCH(DATE, [%c]) AC_SUBST([DATE]) +AM_CONDITIONAL([INSTALL_USER_MANUAL], [test ! -f "${srcdir}/docs/MANUAL_ONLINE"]) +AC_MSG_CHECKING([if the manual needs to be installed]) +AM_COND_IF([INSTALL_USER_MANUAL], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) + +# FIXME Retire? We don't want to debug a version that has been mislabeled by a user # Decorate the version string per user-supplied version.sh, if any AS_IF( [test -f version.sh -a -x version.sh], diff --git a/docs/MANUAL_ONLINE b/docs/MANUAL_ONLINE index 3f36b42..8457b20 100644 --- a/docs/MANUAL_ONLINE +++ b/docs/MANUAL_ONLINE @@ -1 +1,4 @@ -http://crosstool-ng.github.io/docs +This is a development version of crosstool-NG. It does not ship with +a user manual; please refer to the online documentation at: + + http://crosstool-ng.github.io/docs diff --git a/maintainer/download-docs.sh b/maintainer/download-docs.sh index 5ef3c6a..3514a57 100755 --- a/maintainer/download-docs.sh +++ b/maintainer/download-docs.sh @@ -1,6 +1,9 @@ #!/bin/bash -distdir=${1:-.} +# Usage: +# download-docs.sh TOP-LEVEL-DIR MANUAL-FILES... +distdir=${1} +shift # Configurable portions docs_git=https://github.com/crosstool-ng/crosstool-ng.github.io.git @@ -12,7 +15,16 @@ git clone --depth=1 "${docs_git}" "${distdir}/site-docs" # Copy the docs instead of the MANUAL_ONLINE placeholder mkdir -p "${distdir}/docs/manual" -for i in "${distdir}/site-docs/${docs_subdir}/"*.md; do +while [ -n "${1}" ]; do + case "${1}" in + docs/manual/*) ;; + *) echo "Expected file not in docs/manual/: $1" >&2; exit 1;; + esac + input="${distdir}/site-docs/${docs_subdir}/${1#docs/manual/}" + if [ ! -r "${input}" ]; then + echo "Not found: ${1}" >&2 + exit 1 + fi awk ' BEGIN { skip=0; } { @@ -30,6 +42,18 @@ BEGIN { skip=0; } print $0 } } -' < "${i}" > "${distdir}/docs/manual/${i##*/}" + ' < "${input}" > "${distdir}/${1}" + rm -f "${input}" + shift +done +extra_md_pages=false +for i in "${distdir}/site-docs/${docs_subdir}/"*.md; do + if [ -r "${i}" ]; then + echo "Unpackaged page in the manual: ${i#${distdir}/site-docs/${docs_subdir}/}" + extra_md_files=true + fi done +if [ "${extra_md_files}" = "true" ]; then + exit 1 +fi rm -rf "${distdir}/site-docs" diff --git a/samples/samples.mk b/samples/samples.mk index 178e537..aafac48 100644 --- a/samples/samples.mk +++ b/samples/samples.mk @@ -19,6 +19,7 @@ CT_UPDATE_SAMPLES := no # This part deals with the samples help entries help-config:: + @echo ' show-config - show a brief overview of current configuration' @echo ' saveconfig - Save current config as a preconfigured target' help-samples:: -- cgit v0.10.2-6-g49f6 From 970811a1c58d22fad37d8cbe2233b8344f358e78 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 4 Apr 2018 00:07:45 -0700 Subject: Conditionally install bash completion Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index a331832..768a3c5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,8 +6,13 @@ include verbatim-data.mk SUBDIRS = kconfig bin_SCRIPTS = ct-ng -CLEANFILES = $(bin_SCRIPTS) -EXTRA_DIST = ct-ng.in bootstrap docs/ct-ng.1.in +CLEANFILES = ct-ng ct-ng.comp docs/ct-ng.1 +EXTRA_DIST = bootstrap ct-ng.in ct-ng.comp.in docs/ct-ng.1.in maintainer + +if INSTALL_BASH_COMPLETION +compdir = $(sysconfdir)/@BASH_COMPLETION_DIR@ +comp_SCRIPTS = ct-ng.comp +endif man1_MANS = docs/ct-ng.1 @@ -45,8 +50,11 @@ do_subst = ( @SED@ \ ct-ng: ct-ng.in Makefile $(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv -f $@-t $@ -docs/ct-ng.1: docs/ct-ng.1.in +docs/ct-ng.1: docs/ct-ng.1.in Makefile $(AM_V_GEN)$(MKDIR_P) docs && $(do_subst) < $< >$@-t && mv -f $@-t $@ +ct-ng.comp: ct-ng.comp.in Makefile + $(AM_V_GEN)$(do_subst) < $< >$@-t && mv -f $@-t $@ + dist-hook: maintainer/download-docs.sh $< $(top_distdir) $(USER_MANUAL_FILES) diff --git a/configure.ac b/configure.ac index c7b6f5a..920e42d 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,16 @@ AC_ARG_ENABLE( [run ct-ng from the current directory; 'make install' unsupported])]) AC_SUBST([enable_local], [${enable_local:-no}]) +AC_ARG_WITH([bash-completion-dir], + [AS_HELP_STRING( + [--with-bash-completion], + [install bash(1) command completion for ct-ng into specified directory, + relative to sysconfdir])], + [], + [with_bash_completion_dir=bash_completion.d]) +AM_CONDITIONAL([INSTALL_BASH_COMPLETION], [test "${with_bash_completion_dir}" != "no" ]) +AC_SUBST([BASH_COMPLETION_DIR], [${with_bash_completion_dir}]) + # FIXME: I don't know why we have this. Will remove after the 1.24 release. AC_ARG_ENABLE( [shared], diff --git a/ct-ng.comp b/ct-ng.comp deleted file mode 100644 index e89e686..0000000 --- a/ct-ng.comp +++ /dev/null @@ -1,36 +0,0 @@ -# To be sourced - -_ct_ng () { - local cur prev samples show_samples actions steps start_steps stop_steps ct_ng_opts vars - COMPREPLY=() - cur=$(_get_cword) - prev=${COMP_WORDS[COMP_CWORD-1]} - - samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null ) - show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;') - build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;') - check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;') - - steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }') - start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;') - stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;') - - actions='help menuconfig nconfig oldconfig saveconfig extractconfig - defconfig savedefconfig - build build. build-all build-all. - wiki-samples list-samples list-samples-short check-samples - list-steps - show-tuple show-all show-config - clean distclean updatetools - version' - - vars="RESTART= STOP= PREFIX= V= DEFCONFIG=" - - ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples} - ${steps} ${start_steps} ${stop_steps} - ${actions} ${vars}" - - COMPREPLY=($(compgen -W "${ct_ng_opts}" -- "${cur}")) - return 0 -} -complete -F _ct_ng ct-ng diff --git a/ct-ng.comp.in b/ct-ng.comp.in new file mode 100644 index 0000000..f38c881 --- /dev/null +++ b/ct-ng.comp.in @@ -0,0 +1,36 @@ +# To be sourced + +_ct_ng () { + local cur prev samples show_samples actions steps start_steps stop_steps ct_ng_opts vars + COMPREPLY=() + cur=$(_get_cword) + prev=${COMP_WORDS[COMP_CWORD-1]} + + samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null ) + show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;') + build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;') + check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;') + + steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }') + start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;') + stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;') + + actions='help menuconfig nconfig oldconfig saveconfig extractconfig + defconfig savedefconfig + build build-all + wiki-samples list-samples list-samples-short check-samples + list-steps + show-tuple show-all show-config + clean distclean updatetools + version' + + vars="RESTART= STOP= PREFIX= V= DEFCONFIG=" + + ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples} + ${steps} ${start_steps} ${stop_steps} + ${actions} ${vars}" + + COMPREPLY=($(compgen -W "${ct_ng_opts}" -- "${cur}")) + return 0 +} +complete -F _ct_ng @progname@ -- cgit v0.10.2-6-g49f6 From b670aaf1ad5ed2531079a7992b6feb87c0b3b9ea Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 4 Apr 2018 23:08:48 -0700 Subject: Install bash completion into new location /share/bash-completion/completions rather than /etc/bash_completion.d Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 768a3c5..88ac882 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,12 +6,12 @@ include verbatim-data.mk SUBDIRS = kconfig bin_SCRIPTS = ct-ng -CLEANFILES = ct-ng ct-ng.comp docs/ct-ng.1 -EXTRA_DIST = bootstrap ct-ng.in ct-ng.comp.in docs/ct-ng.1.in maintainer +CLEANFILES = ct-ng bash-completion/ct-ng docs/ct-ng.1 +EXTRA_DIST = bootstrap ct-ng.in bash-completion/ct-ng.in docs/ct-ng.1.in maintainer if INSTALL_BASH_COMPLETION -compdir = $(sysconfdir)/@BASH_COMPLETION_DIR@ -comp_SCRIPTS = ct-ng.comp +compdir = @BASH_COMPLETION_DIR@ +comp_SCRIPTS = bash-completion/ct-ng endif man1_MANS = docs/ct-ng.1 @@ -53,8 +53,8 @@ ct-ng: ct-ng.in Makefile docs/ct-ng.1: docs/ct-ng.1.in Makefile $(AM_V_GEN)$(MKDIR_P) docs && $(do_subst) < $< >$@-t && mv -f $@-t $@ -ct-ng.comp: ct-ng.comp.in Makefile - $(AM_V_GEN)$(do_subst) < $< >$@-t && mv -f $@-t $@ +bash-completion/ct-ng: bash-completion/ct-ng.in Makefile + $(AM_V_GEN)$(MKDIR_P) bash-completion && $(do_subst) < $< >$@-t && mv -f $@-t $@ dist-hook: maintainer/download-docs.sh $< $(top_distdir) $(USER_MANUAL_FILES) diff --git a/bash-completion/ct-ng.in b/bash-completion/ct-ng.in new file mode 100644 index 0000000..f38c881 --- /dev/null +++ b/bash-completion/ct-ng.in @@ -0,0 +1,36 @@ +# To be sourced + +_ct_ng () { + local cur prev samples show_samples actions steps start_steps stop_steps ct_ng_opts vars + COMPREPLY=() + cur=$(_get_cword) + prev=${COMP_WORDS[COMP_CWORD-1]} + + samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null ) + show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;') + build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;') + check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;') + + steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }') + start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;') + stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;') + + actions='help menuconfig nconfig oldconfig saveconfig extractconfig + defconfig savedefconfig + build build-all + wiki-samples list-samples list-samples-short check-samples + list-steps + show-tuple show-all show-config + clean distclean updatetools + version' + + vars="RESTART= STOP= PREFIX= V= DEFCONFIG=" + + ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples} + ${steps} ${start_steps} ${stop_steps} + ${actions} ${vars}" + + COMPREPLY=($(compgen -W "${ct_ng_opts}" -- "${cur}")) + return 0 +} +complete -F _ct_ng @progname@ diff --git a/configure.ac b/configure.ac index 920e42d..c19d6ed 100644 --- a/configure.ac +++ b/configure.ac @@ -33,27 +33,19 @@ AC_ARG_ENABLE( [run ct-ng from the current directory; 'make install' unsupported])]) AC_SUBST([enable_local], [${enable_local:-no}]) -AC_ARG_WITH([bash-completion-dir], +AC_ARG_WITH([bash-completion], [AS_HELP_STRING( [--with-bash-completion], - [install bash(1) command completion for ct-ng into specified directory, - relative to sysconfdir])], + [install bash(1) command completion; can specify a path where it will be installed])], [], - [with_bash_completion_dir=bash_completion.d]) -AM_CONDITIONAL([INSTALL_BASH_COMPLETION], [test "${with_bash_completion_dir}" != "no" ]) -AC_SUBST([BASH_COMPLETION_DIR], [${with_bash_completion_dir}]) - -# FIXME: I don't know why we have this. Will remove after the 1.24 release. -AC_ARG_ENABLE( - [shared], - [AS_HELP_STRING( - [--enable-shared], - [build shared libraries (deprecated, ignored)])]) -AC_ARG_ENABLE( - [static], - [AS_HELP_STRING( - [--enable-static], - [build static libraries (deprecated, ignored)])]) + [with_bash_completion=yes]) +AS_IF([test "${with_bash_completion}" = "no"], + [BASH_COMPLETION_DIR=], + [test "${with_bash_completion}" != "yes"], + [BASH_COMPLETION_DIR="${with_bash_completion}"], + [BASH_COMPLETION_DIR='${datadir}/bash-completion/completions']) +AM_CONDITIONAL([INSTALL_BASH_COMPLETION], [test -n "${BASH_COMPLETION_DIR}"]) +AC_SUBST([BASH_COMPLETION_DIR]) # Check for --build and --host... AC_CANONICAL_BUILD diff --git a/ct-ng.comp.in b/ct-ng.comp.in deleted file mode 100644 index f38c881..0000000 --- a/ct-ng.comp.in +++ /dev/null @@ -1,36 +0,0 @@ -# To be sourced - -_ct_ng () { - local cur prev samples show_samples actions steps start_steps stop_steps ct_ng_opts vars - COMPREPLY=() - cur=$(_get_cword) - prev=${COMP_WORDS[COMP_CWORD-1]} - - samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null ) - show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;') - build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;') - check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;') - - steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }') - start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;') - stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;') - - actions='help menuconfig nconfig oldconfig saveconfig extractconfig - defconfig savedefconfig - build build-all - wiki-samples list-samples list-samples-short check-samples - list-steps - show-tuple show-all show-config - clean distclean updatetools - version' - - vars="RESTART= STOP= PREFIX= V= DEFCONFIG=" - - ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples} - ${steps} ${start_steps} ${stop_steps} - ${actions} ${vars}" - - COMPREPLY=($(compgen -W "${ct_ng_opts}" -- "${cur}")) - return 0 -} -complete -F _ct_ng @progname@ -- cgit v0.10.2-6-g49f6 From 20e8402779db3d47856b45b31e5f3d76c8554a55 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 4 Apr 2018 23:37:54 -0700 Subject: Compress the manpage Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 88ac882..cfe5210 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,9 @@ man1_MANS = docs/ct-ng.1 # paths.sh generated by configure nobase_dist_pkgdata_DATA = $(verbatim_data) paths.sh +# ct-ng, as renamed by the installation +ctng_progname = `echo ct-ng | sed '$(transform)'` + USER_MANUAL_FILES = \ docs/manual/1_Introduction.md \ docs/manual/2_Installation.md \ @@ -44,7 +47,7 @@ do_subst = ( @SED@ \ -e 's,[@]docdir[@],$(docdir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ -e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \ - -e 's,[@]progname[@],'`echo ct-ng | sed '$(transform)'`',g' \ + -e 's,[@]progname[@],'$(ctng_progname)',g' \ | $(SHELL) config.status --file=- ) ct-ng: ct-ng.in Makefile @@ -56,5 +59,12 @@ docs/ct-ng.1: docs/ct-ng.1.in Makefile bash-completion/ct-ng: bash-completion/ct-ng.in Makefile $(AM_V_GEN)$(MKDIR_P) bash-completion && $(do_subst) < $< >$@-t && mv -f $@-t $@ +# automake doesn't offer an option to compress manpages, do it after installation +install-data-hook: + gzip -9 $(DESTDIR)$(man1dir)/$(ctng_progname).1 + +uninstall-hook: + rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz + dist-hook: maintainer/download-docs.sh $< $(top_distdir) $(USER_MANUAL_FILES) -- cgit v0.10.2-6-g49f6 From fda857aeb851e5329b5dec664cc14903bf4d20a6 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 7 Apr 2018 11:31:50 -0700 Subject: Debian: no longer need to install completion separately Signed-off-by: Alexey Neyman diff --git a/debian/rules b/debian/rules index d85609e..4a3a8e3 100755 --- a/debian/rules +++ b/debian/rules @@ -29,7 +29,6 @@ override_dh_auto_configure: #Make sure to include bash completion file in the package override_dh_auto_install: dh_auto_install - install -D -m 0644 ct-ng.comp $$(pwd)/debian/crosstool-ng/usr/share/bash-completion/completions/ct-ng.comp override_dh_update_autotools_config: @: -- cgit v0.10.2-6-g49f6 From 7eb903667b59ac00d28e2ebad26e4b8c56bb0b84 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 7 Apr 2018 12:00:24 -0700 Subject: Lintian warnings cleanup Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index cfe5210..87e019f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,8 +60,13 @@ bash-completion/ct-ng: bash-completion/ct-ng.in Makefile $(AM_V_GEN)$(MKDIR_P) bash-completion && $(do_subst) < $< >$@-t && mv -f $@-t $@ # automake doesn't offer an option to compress manpages, do it after installation +# Also, lintian is picky about execute-bit on the scripts install-data-hook: + rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz gzip -9 $(DESTDIR)$(man1dir)/$(ctng_progname).1 + chmod +x $(DESTDIR)$(pkgdatadir)/scripts/config.guess + chmod +x $(DESTDIR)$(pkgdatadir)/scripts/config.sub + chmod -x $(DESTDIR)$(compdir)/$(ctng_progname) uninstall-hook: rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz diff --git a/configure.ac b/configure.ac index c19d6ed..5cb82a8 100644 --- a/configure.ac +++ b/configure.ac @@ -26,16 +26,17 @@ AC_CONFIG_SRCDIR([ct-ng.in]) #-------------------------------------------------------------------- # Allow dummy --{en,dis}able-{static,shared} -AC_ARG_ENABLE( - [local], - [AS_HELP_STRING( - [--enable-local], +AC_ARG_ENABLE([local], + [AS_HELP_STRING([--enable-local], [run ct-ng from the current directory; 'make install' unsupported])]) AC_SUBST([enable_local], [${enable_local:-no}]) +AC_ARG_ENABLE([maintainer-mode], + [AS_HELP_STRING([--enable-maintainer-mode], + [Ignored; accepted to avoid a warning from debuild])]) + AC_ARG_WITH([bash-completion], - [AS_HELP_STRING( - [--with-bash-completion], + [AS_HELP_STRING([--with-bash-completion], [install bash(1) command completion; can specify a path where it will be installed])], [], [with_bash_completion=yes]) -- cgit v0.10.2-6-g49f6 From 4e7d0906c1047516ab6517e3abd4a83cba98139d Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 7 Apr 2018 14:39:56 -0700 Subject: Support out-of-tree local builds Signed-off-by: Alexey Neyman diff --git a/ct-ng.in b/ct-ng.in index 926ba71..2331b86 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -17,7 +17,7 @@ export CT_TOP_DIR:=$(shell pwd) ifeq (@enable_local@,yes) # automake does not allow to set pkgxxxdir, they are always derived from # a respective xxxdir. So, for enable-local case, set them directly here. -export CT_LIB_DIR:=$(CT_TOP_DIR) +export CT_LIB_DIR:=$(shell cd "@srcdir@" && pwd) export CT_LIBEXEC_DIR:=$(CT_TOP_DIR)/kconfig export CT_DOC_DIR:=$(CT_TOP_DIR)/docs else diff --git a/scripts/crosstool-NG.sh b/scripts/crosstool-NG.sh index 4d79e48..d4414b5 100644 --- a/scripts/crosstool-NG.sh +++ b/scripts/crosstool-NG.sh @@ -111,7 +111,7 @@ CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CON CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools" CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'" CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin" -cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do +cat "${paths_sh_location}" |while read trash line; do tool="${line%%=*}" # Suppress extra quoting eval path=${line#*=} diff --git a/scripts/functions b/scripts/functions index 62966fd..0b8fba5 100644 --- a/scripts/functions +++ b/scripts/functions @@ -985,7 +985,7 @@ CT_GetFile() # Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. # Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. CT_DoConfigGuess() { - if [ -x "${CT_TOP_DIR}/scripts/config.guess" ]; then + if [ -r "${CT_TOP_DIR}/scripts/config.guess" ]; then "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.guess" else "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.guess" @@ -993,7 +993,7 @@ CT_DoConfigGuess() { } CT_DoConfigSub() { - if [ -x "${CT_TOP_DIR}/scripts/config.sub" ]; then + if [ -r "${CT_TOP_DIR}/scripts/config.sub" ]; then "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.sub" "$@" else "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.sub" "$@" @@ -2283,3 +2283,16 @@ CT_GetChoicePkgBuildVersion() eval "component=\${CT_${choice}_CHOICE_KSYM}" CT_GetPkgBuildVersion "${choice}" "${component}" "${var}" } + +# Finally, load paths.sh. For --enable-local build, it is located in +# the current directory (CT_TOP_DIR) while the rest of the scripts are +# in the source directory (CT_LIB_DIR). For other setups, paths.sh +# is in CT_LIB_DIR. +if [ -r "${CT_LIB_DIR}/paths.sh" ]; then + paths_sh_location="${CT_LIB_DIR}/paths.sh" +elif [ -r "${CT_TOP_DIR}/paths.sh" ]; then + paths_sh_location="${CT_TOP_DIR}/paths.sh" +else + CT_Error "Not found: paths.sh" +fi +. "${paths_sh_location}" diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh index 5fab6d9..2f4a10b 100644 --- a/scripts/saveSample.sh +++ b/scripts/saveSample.sh @@ -7,7 +7,6 @@ # - info about who reported the sample # Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" . "${CT_LIB_DIR}/scripts/functions" CT_LoadConfig diff --git a/scripts/show-config.sh b/scripts/show-config.sh index 9e56f07..7112269 100644 --- a/scripts/show-config.sh +++ b/scripts/show-config.sh @@ -2,7 +2,6 @@ # the versions of the main tools # Use tools discovered by ./configure -. "${CT_LIB_DIR}/paths.sh" . "${CT_LIB_DIR}/scripts/functions" [ "$1" = "-v" ] && opt="$1" && shift diff --git a/scripts/show-tuple.sh b/scripts/show-tuple.sh index 9031b3c..4b0b9b0 100644 --- a/scripts/show-tuple.sh +++ b/scripts/show-tuple.sh @@ -1,9 +1,6 @@ # What we need: # - the .config file -# Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" - # Parse the common functions . "${CT_LIB_DIR}/scripts/functions" -- cgit v0.10.2-6-g49f6 From c4608f07f7e06a58d48d74b64296be663a94c604 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 8 Apr 2018 20:42:07 -0700 Subject: Only attempt to chmod bash completion script ... if it has been installed. Signed-off-by: Alexey Neyman diff --git a/Makefile.am b/Makefile.am index 87e019f..5ee3682 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,7 +66,9 @@ install-data-hook: gzip -9 $(DESTDIR)$(man1dir)/$(ctng_progname).1 chmod +x $(DESTDIR)$(pkgdatadir)/scripts/config.guess chmod +x $(DESTDIR)$(pkgdatadir)/scripts/config.sub +if INSTALL_BASH_COMPLETION chmod -x $(DESTDIR)$(compdir)/$(ctng_progname) +endif uninstall-hook: rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz -- cgit v0.10.2-6-g49f6