From 1e020586317fbebda88d99f727ff234489809dc0 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Tue, 17 Jan 2012 21:01:01 +0100 Subject: [PATCH] scripts: add autostuff stuff To be noted: - the lex/yacc/gperf generated files include one another, so it is not possible to use proper automake constructs to generate the lexer - it is possible to tell bison and flex to change the prefix of the generated symbols, different from the default 'yy'; but if one does so, then the names of the generated files also include this prefix instead of the default (here, we use 'zconf' instead of 'yy' - autoconf has a /built-in/ check for lex, but has no way to know that the output files is differently named Because of all these mis-features, the autostuff files contain some dubious constructs, as a palliative. Signed-off-by: "Yann E. MORIN" --- .hgignore | 22 ++++++++++ .version | 1 + Makefile.am | 29 +++++++++++++ bootstrap | 17 ++++++++ configure.ac | 86 ++++++++++++++++++++++++++++++++++++++ zconf.gperf => hconf.gperf | 0 zconf.l => lconf.l | 0 lxdialog/Makefile.am | 12 ++++++ zconf.y => yconf.y | 4 +- 9 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 .hgignore create mode 100644 .version create mode 100644 Makefile.am create mode 100755 bootstrap create mode 100644 configure.ac rename zconf.gperf => hconf.gperf (100%) rename zconf.l => lconf.l (100%) create mode 100644 lxdialog/Makefile.am rename zconf.y => yconf.y (99%) diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..aa858a3 --- /dev/null +++ b/.hgignore @@ -0,0 +1,22 @@ +syntax: glob + +.*.swp +*.o +*.a + +aclocal.m4 +configure +config.h +config.h.in +config.log +config.status + +Makefile +Makefile.in +lxdialog/Makefile +lxdialog/Makefile.in +stamp-h1 + +.deps/ +autom4te.cache/ +scripts/ diff --git a/.version b/.version new file mode 100644 index 0000000..cbb0de2 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +hg diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..5d89c81 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +SUFFIXES = .gperf + +bin_PROGRAMS = conf nconf mconf + +conf_SOURCES = \ + conf.c \ + yconf.y + +mconf_SOURCES = \ + mconf.c \ + yconf.y +mconf_CFLAGS = -DCURSES_LOC='"${CURSES_LOC}"' +mconf_LDADD = lxdialog/liblxdialog.a + +nconf_SOURCES = \ + nconf.c \ + nconf.gui.c \ + yconf.y +nconf_LDADD = -lmenu -lpanel + +yconf.o: lconf.c hconf.c + +.gperf.c: + $(GPERF) -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< + +.l.c: + $(LEX) $(LFLAGS) $(AM_LFLAGS) -o$@ $< + +SUBDIRS = lxdialog . diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..b07f76d --- /dev/null +++ b/bootstrap @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +printf "Running aclocal...\n" +aclocal -Wall --force + +printf "Running autoconf...\n" +autoconf -Wall --force + +printf "Running autoheader...\n" +autoheader -Wall --force + +printf "Running automake...\n" +mkdir -p scripts +automake --foreign --add-missing --copy -Wall --force + +printf "Done. You may now run:\n ./configure\n" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..9393234 --- /dev/null +++ b/configure.ac @@ -0,0 +1,86 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.67]) +AC_INIT([kconfig-frontends], [m4_esyscmd_s([cat .version])], [nobody@nowhere.org]) +AC_CONFIG_SRCDIR([menu.c]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_AUX_DIR([scripts]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_RANLIB + +AM_INIT_AUTOMAKE +AM_PROG_CC_C_O +AC_PROG_LEX +AC_PROG_YACC +AC_CHECK_PROGS( + [GPERF], + [gperf]) +AS_IF( + [test -z "$GPERF"], + [AC_MSG_ERROR([can not find gperf])]) +AC_SUBST([AM_LFLAGS], ["-L -P zconf"]) +AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"]) + +# Checks for libraries. + +# Checks for header files. +AC_CHECK_HEADERS([ fcntl.h libintl.h limits.h locale.h stdlib.h string.h sys/time.h unistd.h ]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_SIZE_T + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([ bzero gettimeofday memmove memset mkdir regcomp setlocale strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol uname ]) + +#---------------------------------------- +AC_C_INLINE +AC_HEADER_STDC +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_FUNC_ALLOCA + +#---------------------------------------- +# Check for gettext, 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],, + [#include <$ac_ct_gettext_hdr>])]) + +#---------------------------------------- +# Check for ncurses, for the kconfig frontends +AC_SUBST([CURSES_LOC]) +AC_CHECK_HEADERS( + [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h], + [CURSES_LOC=$ac_header; break]) +AS_IF( + [test -z "$CURSES_LOC"], + [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_CONFIG_FILES([ + Makefile + lxdialog/Makefile +]) +AC_OUTPUT diff --git a/zconf.gperf b/hconf.gperf similarity index 100% rename from zconf.gperf rename to hconf.gperf diff --git a/zconf.l b/lconf.l similarity index 100% rename from zconf.l rename to lconf.l diff --git a/lxdialog/Makefile.am b/lxdialog/Makefile.am new file mode 100644 index 0000000..cf66893 --- /dev/null +++ b/lxdialog/Makefile.am @@ -0,0 +1,12 @@ +noinst_LIBRARIES = liblxdialog.a + +liblxdialog_a_SOURCES = \ + checklist.c \ + dialog.h \ + inputbox.c \ + menubox.c \ + textbox.c \ + util.c \ + yesno.c + +liblxdialog_a_CFLAGS = -DCURSES_LOC='"${CURSES_LOC}"' diff --git a/zconf.y b/yconf.y similarity index 99% rename from zconf.y rename to yconf.y index 864da07..a09276e 100644 --- a/zconf.y +++ b/yconf.y @@ -96,7 +96,7 @@ static struct menu *current_menu, *current_entry; %{ /* Include zconf.hash.c here so it can see the token constants. */ -#include "zconf.hash.c" +#include "hconf.c" %} %% @@ -732,7 +732,7 @@ void zconfdump(FILE *out) } } -#include "zconf.lex.c" +#include "lconf.c" #include "util.c" #include "confdata.c" #include "expr.c" -- 2.39.5