diff --git a/configure.ac b/configure.ac index 870903642..3f317da1a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,9 @@ if test "x$LEX" != "xflex" ; then fi AC_PROG_VERSION_CHECK([flex], [2.5.33], [2.5.34]) +AX_WITH_PROG([PERL], [perl], []) +AM_CONDITIONAL([PERL_AVAILABLE], test -z "$PERL") + # Enable Compiler/LibC GNU extensions AC_GNU_SOURCE @@ -371,3 +374,8 @@ if test "x$use_system_sqlite" = "xno" ; then AC_MSG_WARN([${SQLITE_PKG_ERRORS}]) AC_MSG_WARN([We currently only accept SQLite versions >= 3.6.]) fi + +if test -z "$PERL" ; then + AC_MSG_NOTICE() + AC_MSG_WARN([Perl isn't installed, autogeneration of some sources will not work.]) +fi diff --git a/data/base/stats-sql/Makefile.am b/data/base/stats-sql/Makefile.am index 0ce3ae2ff..b0e491154 100644 --- a/data/base/stats-sql/Makefile.am +++ b/data/base/stats-sql/Makefile.am @@ -1,9 +1,11 @@ +if PERL_AVAILABLE %.schema.sql: $(top_srcdir)/build_tools/code-generators/db-lang.pl $(top_srcdir)/build_tools/code-generators/sql_tabledef_cg.pm $(top_srcdir)/src/%.tpl - $^ $@ + $(PERL) $^ $@ %.data.sql: $(top_srcdir)/build_tools/code-generators/db-lang.pl $(top_srcdir)/build_tools/code-generators/sql_insertdef_cg.pm $(srcdir)/../stats $(top_srcdir)/src/%.tpl - $^ $@ + $(PERL) $^ $@ BUILT_SOURCES = \ stats-db2.data.sql \ stats-db2.schema.sql +endif diff --git a/m4/ax_with_perl.m4 b/m4/ax_with_perl.m4 new file mode 100644 index 000000000..58db1a764 --- /dev/null +++ b/m4/ax_with_perl.m4 @@ -0,0 +1,36 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_with_perl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_PERL([VALUE-IF-NOT-FOUND],[PATH]) +# +# DESCRIPTION +# +# Locates an installed Perl binary, placing the result in the precious +# variable $PERL. Accepts a present $PERL, then --with-perl, and failing +# that searches for perl in the given path (which defaults to the system +# path). If perl is found, $PERL is set to the full path of the binary; if +# it is not found $PERL is set to VALUE-IF-NOT-FOUND if provided, +# unchanged otherwise. +# +# A typical use could be the following one: +# +# AX_WITH_PERL +# +# LAST MODIFICATION +# +# 2008-05-05 +# +# COPYLEFT +# +# Copyright (c) 2008 Francesco Salvestrini +# +# 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. + +AC_DEFUN([AX_WITH_PERL],[ + AX_WITH_PROG(PERL,perl,$1,$2) +]) diff --git a/m4/ax_with_prog.m4 b/m4/ax_with_prog.m4 new file mode 100644 index 000000000..b4d463ac3 --- /dev/null +++ b/m4/ax_with_prog.m4 @@ -0,0 +1,75 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_with_prog.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH]) +# +# DESCRIPTION +# +# Locates an installed program binary, placing the result in the precious +# variable VARIABLE. Accepts a present VARIABLE, then --with-program, and +# failing that searches for program in the given path (which defaults to +# the system path). If program is found, VARIABLE is set to the full path +# of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND +# if provided, unchanged otherwise. +# +# A typical example could be the following one: +# +# AX_WITH_PROG(PERL,perl) +# +# NOTE: This macro is based upon the original AX_WITH_PYTHON macro from +# Dustin J. Mitchell . +# +# LAST MODIFICATION +# +# 2008-05-05 +# +# COPYLEFT +# +# Copyright (c) 2008 Francesco Salvestrini +# Copyright (c) 2008 Dustin J. Mitchell +# +# 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. + +AC_DEFUN([AX_WITH_PROG],[ + AC_PREREQ([2.61]) + + pushdef([VARIABLE],$1) + pushdef([EXECUTABLE],$2) + pushdef([VALUE_IF_NOT_FOUND],$3) + pushdef([PATH_PROG],$4) + + AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable) + + AS_IF(test -z "$VARIABLE",[ + AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided) + AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[[PATH]]]]],absolute path to EXECUTABLE executable), [ + AS_IF([test "$withval" != "yes" -a "$withval" != "no"],[ + VARIABLE="$withval" + AC_MSG_RESULT($VARIABLE) + ],[ + AS_IF([test "$withval" = "no"],[ + VARIABLE="VALUE_IF_NOT_FOUND" + ],[ + VARIABLE="" + ]) + AC_MSG_RESULT([no]) + ]) + ],[ + AC_MSG_RESULT([no]) + ]) + + AS_IF(test -z "$VARIABLE" -a "$withval" != "no",[ + AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) + ]) + ]) + + popdef([PATH_PROG]) + popdef([VALUE_IF_NOT_FOUND]) + popdef([EXECUTABLE]) + popdef([VARIABLE]) +]) diff --git a/src/Makefile.am b/src/Makefile.am index 2d042ba2f..955de1e04 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,11 +4,13 @@ %.lex.h %.lex.c:: %.l $(LEX) $(LFLAGS) $(AM_LFLAGS) -o$@ $< +if PERL_AVAILABLE %.c: $(top_srcdir)/build_tools/code-generators/db-lang.pl $(top_srcdir)/build_tools/code-generators/c_sqliteload_cg.pm %.tpl.sql.c %.tpl - $^ $@ + $(PERL) $^ $@ %.h: $(top_srcdir)/build_tools/code-generators/db-lang.pl $(top_srcdir)/build_tools/code-generators/c_structdef_cg.pm %.tpl.struct.h %.tpl - $^ $@ + $(PERL) $^ $@ +endif # Required to force using a C++ linker force-linker.cpp: @@ -27,9 +29,13 @@ BUILT_SOURCES = \ message_parser.tab.h \ scriptvals_lexer.lex.c \ scriptvals_parser.tab.c \ - scriptvals_parser.tab.h \ + scriptvals_parser.tab.h + +if PERL_AVAILABLE +BUILT_SOURCES += \ stats-db2.c \ stats-db2.h +endif CLEANFILES = \ force-linker.cpp \