Skip to content

Commit

Permalink
Use autoconfig-archve/automake tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Neyman <stilor@att.net>
  • Loading branch information
stilor committed Apr 7, 2018
1 parent 896bc2d commit 0bcb67f
Show file tree
Hide file tree
Showing 18 changed files with 3,235 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
configure
autom4te.cache
aclocal.m4
config.h*
config.log
config.status
/Makefile
Expand Down
101 changes: 52 additions & 49 deletions configure.ac
Expand Up @@ -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])
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 <ncursesw/curses.h>
#elif defined HAVE_NCURSESW_H
# define CURSES_LOC <ncursesw.h>
#elif defined HAVE_NCURSES_CURSES_H
# define CURSES_LOC <ncurses/curses.h>
#elif defined HAVE_NCURSES_H
# define CURSES_LOC <ncurses.h>
#elif defined HAVE_CURSES_H
# define CURSES_LOC <curses.h>
#else
# /* not an error - maybe a configuration didn't need curses */
#endif
#if defined HAVE_NCURSESW_PANEL_H
# define PANEL_LOC <ncursesw/panel.h>
#elif defined HAVE_NCURSES_PANEL_H
# define PANEL_LOC <ncurses/panel.h>
#elif defined HAVE_PANEL_H
# define PANEL_LOC <panel.h>
#else
# /* not an error */
#endif
#if defined HAVE_NCURSESW_MENU_H
# define MENU_LOC <ncursesw/menu.h>
#elif defined HAVE_NCURSES_MENU_H
# define MENU_LOC <ncurses/menu.h>
#elif defined HAVE_MENU_H
# define MENU_LOC <menu.h>
#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
Expand Down
27 changes: 12 additions & 15 deletions kconfig/Makefile.in
Expand Up @@ -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) \
Expand All @@ -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))
Expand Down
70 changes: 70 additions & 0 deletions 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 <bavier@member.fsf.org>
#
# 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 <https://www.gnu.org/licenses/>.
#
# 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

0 comments on commit 0bcb67f

Please sign in to comment.