Project: Gentoo libbash
Code Location: git://git.overlays.gentoo.org/proj/libbash.gitmaster
Browse
/
Download File
Makefile.am
###############################################
#Please use git log for copyright holder and year information
#
#This file is part of libbash.
#
#libbash 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 of the License, or
#(at your option) any later version.
#
#libbash 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 libbash.  If not, see <http://www.gnu.org/licenses/>.
###############################################
# Makefile.am for libbash
# Author: Nathan Eloe
###############################################
include doc/doxygen.am

ACLOCAL_AMFLAGS = -I m4

TEST_EXTENSIONS= .gunit .bash .ebuild
GUNIT_LOG_COMPILER = $(srcdir)/bashast/gunit/runtests.sh
AM_GUNIT_LOG_FLAGS = @antlr_cp@:.
GUNIT_TESTS = bashast/gunit/arith_main.gunit \
			  bashast/gunit/array.gunit \
			  bashast/gunit/assoc_array.gunit \
			  bashast/gunit/brace.gunit \
			  bashast/gunit/command_sub.gunit \
			  bashast/gunit/comment.gunit \
			  bashast/gunit/compound.gunit \
			  bashast/gunit/cond_main.gunit \
			  bashast/gunit/continued_lines.gunit \
			  bashast/gunit/expansions.gunit \
			  bashast/gunit/fname.gunit \
			  bashast/gunit/function.gunit \
			  bashast/gunit/list.gunit \
			  bashast/gunit/param_main.gunit \
			  bashast/gunit/pipeline.gunit \
			  bashast/gunit/process_substitution.gunit \
			  bashast/gunit/redir.gunit \
			  bashast/gunit/simp_command.gunit \
			  bashast/gunit/simp_prog.gunit

BASH_LOG_COMPILER = $(srcdir)/test/bash_compiler.sh
BASH_TESTS = scripts/var_def.bash \
			 scripts/command_execution.bash \
			 scripts/function_def.bash \
			 scripts/arithmetic_assignment.bash \
			 scripts/var_expansion.bash \
			 scripts/test_expr.bash \
			 scripts/isolated_functions.bash \
			 scripts/compound_command.bash \
			 scripts/binary_arithmetic.bash

EBUILD_LOG_COMPILER = $(srcdir)/test/ebuild_compiler.sh
EBUILD_TESTS = scripts/sunpinyin-2.0.3-r1.ebuild
EBUILD_RESULT = scripts/sunpinyin-2.0.3-r1.ebuild.result

TESTS = $(GUNIT_TESTS) $(BASH_TESTS) $(EBUILD_TESTS)
# these get cleaned so only add autogenerated stuff or modify CLEANFILES
check_JAVA = bashast/java_libbashLexer.java bashast/java_libbashParser.java
AM_JAVACFLAGS = -source 1.4 -classpath @antlr_cp@

AM_CXXFLAGS = -std=c++0x
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include

if DEVELOPER_MODE
# -Weffc++ seems to be giving false positives on protected non
# virtual destructors in base classes
AM_CXXFLAGS += -Wall \
			   -Wextra \
			   -Wold-style-cast \
			   -Woverloaded-virtual \
			   -Wsign-promo \
			   -pedantic-errors \
			   -Werror
AM_CPPFLAGS += -D_GLIBCXX_DEBUG
endif

if HAVE_GTEST
TESTS += cppunittests \
		 test/verify_error_output_test.sh \
		 test/ast_printer_test.sh \
		 test/verify_bashs_test.sh \
		 test/verify_here_document.sh \
		 test/bash_result_tests.sh
check_PROGRAMS = cppunittests

cppunittests_SOURCES =  test/run_tests.cpp \
						src/core/tests/symbols_test.cpp \
						src/core/tests/interpreter_test.cpp \
						src/core/tests/bash_ast_test.cpp \
						src/core/tests/bash_condition_test.cpp \
						src/builtins/tests/continue_tests.cpp \
						src/builtins/tests/break_tests.cpp \
						src/builtins/tests/echo_tests.cpp \
						src/builtins/tests/declare_tests.cpp \
						src/builtins/tests/boolean_tests.cpp \
						src/builtins/tests/source_tests.cpp \
						src/builtins/tests/shift_tests.cpp \
						src/builtins/tests/shopt_tests.cpp \
						src/builtins/tests/return_tests.cpp \
						src/builtins/tests/read_tests.cpp \
						src/builtins/tests/set_tests.cpp \
						src/builtins/tests/unset_tests.cpp \
						src/builtins/tests/printf_tests.cpp \
						test/test.h \
						test/test.cpp \
						test/post_check.cpp \
						test/api_test.cpp \
						test/walker_test.cpp
cppunittests_LDADD = libbash.la \
					 $(GTEST_LIBS) \
					 $(BOOST_SYSTEM_LIB) \
					 $(BOOST_FILESYSTEM_LIB)
cppunittests_LDFLAGS = -static
cppunittests_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/test/

endif

noinst_LIBRARIES = libmetadata.a

libmetadata_a_SOURCES = utils/metadata.h utils/metadata.cpp
libmetadata_a_CPPFLAGS = $(AM_CPPFLAGS) -Iutils

noinst_PROGRAMS = variable_printer metadata_generator ast_printer instruo bash

variable_printer_SOURCES = utils/variable_printer.cpp
variable_printer_LDADD = libbash.la

bash_SOURCES = utils/bash.cpp test/test.h  test/test.cpp
bash_LDADD = libbash.la
bash_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/test/

metadata_generator_SOURCES = utils/metadata_generator.cpp
metadata_generator_LDADD = libbash.la libmetadata.a
metadata_generator_CPPFLAGS = $(AM_CPPFLAGS) -Iutils

instruo_SOURCES = utils/instruo.cpp \
				  utils/command_line.cpp \
				  utils/command_line.h \
				  test/test.h \
				  test/test.cpp
instruo_LDADD = libbash.la @PALUDIS_LIBS@ libmetadata.a
instruo_CPPFLAGS = $(AM_CPPFLAGS) @PALUDIS_CFLAGS@ -Iutils -I$(top_srcdir)/test/
instruo_CXXFLAGS = $(AM_CXXFLAGS) -Wno-extra -fopenmp

ast_printer_SOURCES = utils/ast_printer.cpp
ast_printer_LDADD = libbash.la $(BOOST_PROGRAM_OPTIONS_LIB)
ast_printer_LDFLAGS = -static
# boost is probably compiled without debug STL so if that is used
# linking will fail
ast_printer_CPPFLAGS = $(AM_CPPFLAGS) -U_GLIBCXX_DEBUG $(BOOST_CPPFLAGS)

GENERATED_LEXER_CPP = libbashLexer.cpp
GENERATED_LEXER_H = libbashLexer.h
GENERATED_PARSER_CPP = libbashParser.cpp
GENERATED_PARSER_H = libbashParser.h
GENERATED_WALKER_CPP = libbashWalker.cpp
GENERATED_WALKER_H = libbashWalker.h
BUILT_SOURCES = $(GENERATED_PARSER_CPP) \
				$(GENERATED_PARSER_H) \
				$(GENERATED_LEXER_CPP) \
				$(GENERATED_LEXER_H) \
				$(GENERATED_WALKER_CPP) \
				$(GENERATED_WALKER_H) \
				$(check_JAVA)
CLEANFILES = $(GENERATED_PARSER_CPP) \
			 $(GENERATED_PARSER_H) \
			 $(GENERATED_LEXER_CPP) \
			 $(GENERATED_LEXER_H) \
			 $(GENERATED_WALKER_CPP) \
			 $(GENERATED_WALKER_H) \
			 $(check_JAVA) \
			 libbash.g \
			 java_libbash.g \
			 libbash.tokens \
			 libbash.tokens.md5 \
			 libbashWalker.h.md5 \
			 bashast/java_libbash.tokens \
			 libbashWalker.tokens \
			 javagrammar.run \
			 cgrammar.run \
			 walker.run \
			 massif.out \
			 callgrind.out

libbash_includedir = $(includedir)/libbash-@PACKAGE_VERSION@/libbash
libbash_include_HEADERS = include/libbash.h \
                          include/common.h \
                          include/divide_by_zero_error.h \
                          include/illegal_argument_exception.h \
                          include/interpreter_exception.h \
                          include/parse_exception.h \
                          include/readonly_exception.h \
                          include/runtime_exception.h \
                          include/unsupported_exception.h \
                          include/exceptions.h

lib_LTLIBRARIES = libbash.la
libbash_la_SOURCES = include/common.h \
					 include/libbash.h \
					 src/libbash.cpp \
					 src/cppbash_builtin.cpp \
					 src/cppbash_builtin.h \
					 src/builtins/continue_builtin.cpp \
					 src/builtins/continue_builtin.h \
					 src/builtins/break_builtin.cpp \
					 src/builtins/break_builtin.h \
					 src/builtins/echo_builtin.cpp \
					 src/builtins/echo_builtin.h \
					 src/builtins/eval_builtin.cpp \
					 src/builtins/eval_builtin.h \
					 src/builtins/export_builtin.cpp \
					 src/builtins/export_builtin.h \
					 src/builtins/local_builtin.cpp \
					 src/builtins/local_builtin.h \
					 src/builtins/declare_builtin.cpp \
					 src/builtins/declare_builtin.h \
					 src/builtins/boolean_builtins.h \
					 src/builtins/source_builtin.h \
					 src/builtins/source_builtin.cpp \
					 src/builtins/shift_builtin.h \
					 src/builtins/shift_builtin.cpp \
					 src/builtins/shopt_builtin.h \
					 src/builtins/shopt_builtin.cpp \
					 src/builtins/return_builtin.h \
					 src/builtins/return_builtin.cpp \
					 src/builtins/printf_builtin.h \
					 src/builtins/printf_builtin.cpp \
					 src/builtins/let_builtin.h \
					 src/builtins/let_builtin.cpp \
					 src/builtins/inherit_builtin.h \
					 src/builtins/inherit_builtin.cpp \
					 src/builtins/unset_builtin.h \
					 src/builtins/unset_builtin.cpp \
					 src/builtins/read_builtin.h \
					 src/builtins/read_builtin.cpp \
					 src/builtins/set_builtin.h \
					 src/builtins/set_builtin.cpp \
					 src/builtins/builtin_exceptions.h \
					 $(GENERATED_PARSER_C) \
					 $(GENERATED_PARSER_H) \
					 include/divide_by_zero_error.h \
					 include/exceptions.h \
					 include/illegal_argument_exception.h \
					 include/interpreter_exception.h \
					 include/parse_exception.h \
					 include/readonly_exception.h \
					 include/runtime_exception.h \
					 include/unsupported_exception.h \
					 src/core/interpreter.cpp \
					 src/core/interpreter.h \
					 src/core/symbols.hpp \
					 src/core/function.h \
					 src/core/function.cpp \
					 src/core/bash_condition.h \
					 src/core/bash_condition.cpp \
					 src/core/bash_ast.cpp \
					 src/core/bash_ast.h

# separate library because we need per file CXXFLAGS
# as antlr generated code does not pass our strict developer
# warning settings
noinst_LTLIBRARIES = libparser.la libwalker.la
libparser_la_SOURCES = $(GENERATED_PARSER_CPP) \
					   $(GENERATED_PARSER_H) \
					   $(GENERATED_LEXER_CPP) \
					   $(GENERATED_LEXER_H)

libparser_la_CXXFLAGS = -std=c++0x \
						-fvisibility=hidden \
						-fvisibility-inlines-hidden

libwalker_la_SOURCES = $(GENERATED_WALKER_CPP) \
					   $(GENERATED_WALKER_H)

libwalker_la_CXXFLAGS = -std=c++0x \
						-fvisibility=hidden \
						-fvisibility-inlines-hidden

libbash_la_CXXFLAGS = $(AM_CXXFLAGS) \
						 -fvisibility=hidden \
						 -fvisibility-inlines-hidden
if DEVELOPER_MODE
# Paludis cannot get compiled with these flags.
# So we only turn them on for our library.
libbash_la_CXXFLAGS += -Wconversion -Wsign-conversion
endif
libbash_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
libbash_la_LIBADD = libparser.la libwalker.la
libbash_la_LDFLAGS = -version-info $(LIBBASH_SO_VERSION)

EXTRA_DIST = bashast/bashast.g \
			 bashast/libbashWalker.g \
			 bashast/features_script/features.sh \
			 bashast/features_script/features.sh.ast \
			 bashast/features_script/features.sh.tokens \
			 bashast/features_script/features.sh.walker.tokens \
			 test/ast_printer_test.sh \
			 test/verify_bashs_test.sh \
			 test/verify_error_output_test.sh \
			 test/verify_here_document.sh \
			 test/bash_result_tests.sh \
			 scripts/naughty_tests \
			 scripts/naughty_tests.result \
			 scripts/here_document.ast \
			 scripts/here_document.sh \
			 scripts/source_false.sh \
			 scripts/source_true.sh \
			 scripts/source_return.sh \
			 scripts/illegal_script.sh \
			 scripts/illegal_script.sh.tokens \
			 scripts/foo.eclass \
			 scripts/bar.eclass \
			 utils/metadata_diff.sh \
			 utils/isolated-functions.sh \
			 test/test_coverage.sh \
			 autogen.sh \
			 $(BASH_TESTS) \
			 $(EBUILD_TESTS) \
			 $(EBUILD_RESULT) \
			 $(GUNIT_TESTS) \
			 $(GUNIT_LOG_COMPILER) \
			 $(BASH_LOG_COMPILER) \
			 $(EBUILD_LOG_COMPILER)

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libbash.pc

coding_standard.pdf: coding_standard/coding_standard.tex
	$(AM_V_GEN)@PDFLATEX@ coding_standard/coding_standard.tex 2&>1 > /dev/null

ANTLR = @JAVA@ -classpath @antlr_cp@ org.antlr.Tool $(ANTLRFLAGS)

cgrammar.run: libbash.g
	$(AM_V_at)touch $@.tmp
	$(AM_V_GEN)$(ANTLR) -fo . $<
	$(AM_V_at)mv libbashParser.{c,cpp}
	$(AM_V_at)mv libbashLexer.{c,cpp}
	$(AM_V_at)mv $@.tmp $@

libbash.g: bashast/bashast.g
	$(AM_V_at)$(CC) -E -x c++ -D OUTPUT_C $< > $@
	$(AM_V_at)sed -i '/^#.*/d' $@
	$(AM_V_at)sed -i 's/C_INCLUDE \(.*\)/\1/' $@

# http://www.kolpackov.net/pipermail/notes/2004-September.txt
libbash.tokens.md5: libbash.tokens
	$(AM_V_at)md5sum $< | cmp -s $@ -; if test $$? -ne 0; then md5sum $< > $@; fi

# Avoid initializing C++ type to NULL by sed, variables whose name
# starts with libbash_ will be stripped
# The date information is removed from libbashWalker.h in order to make the md5 trick working
walker.run: bashast/libbashWalker.g libbash.tokens.md5
	$(AM_V_at)touch $@.tmp
	$(AM_V_at)if test -a libbashWalker.h; then mv libbashWalker.h libbashWalker.h.bak; fi
	$(AM_V_GEN)$(ANTLR) -fo . $<
	$(AM_V_at)sed -i '/ *     -                            On/d' libbashWalker.h
	$(AM_V_at)md5sum libbashWalker.h | cmp -s libbashWalker.h.md5 -; \
		if test $$? -ne 0; then \
			md5sum libbashWalker.h > libbashWalker.h.md5; \
		elif test -a libbashWalker.h.bak; then \
			mv libbashWalker.h.bak libbashWalker.h; \
		fi
	$(AM_V_at)sed -i -e 's/\(libbash_.*\) = NULL/\1/' libbashWalker.c
	$(AM_V_at)mv libbashWalker.{c,cpp}
	$(AM_V_at)mv $@.tmp $@

$(GENERATED_PARSER_CPP): cgrammar.run
$(GENERATED_PARSER_H): cgrammar.run
$(GENERATED_LEXER_CPP): cgrammar.run
$(GENERATED_LEXER_H): cgrammar.run
libbash.tokens: cgrammar.run

$(GENERATED_WALKER_CPP): walker.run
$(GENERATED_WALKER_H): walker.run

java_libbash.g: bashast/bashast.g
	$(AM_V_at)$(CC) -E -x c++ -D OUTPUT_JAVA $< > $@
	$(AM_V_at)sed -i '/^#.*/d' $@

javagrammar.run: java_libbash.g
	$(AM_V_at)touch $@.tmp
	$(AM_V_GEN)$(ANTLR) -fo bashast $<
	$(AM_V_at)mv $@.tmp $@

$(check_JAVA): javagrammar.run

massif.out: ast_printer
		libtool --mode=execute valgrind \
		--tool=massif --massif-out-file=massif.out \
		./ast_printer -nsf /usr/portage/eclass/versionator.eclass

massif: massif.out
	ms_print --threshold=10 $<

callgrind.out: ast_printer
	libtool --mode=execute valgrind \
		--tool=callgrind --callgrind-out-file=callgrind.out \
		./instruo -D /usr/portage/ --output-dir metadata_output

benchmark_parser: callgrind.out
	callgrind_annotate callgrind.out

test_coverage: dist
	MAKE=$(MAKE) DIST_ARCHIVES=$(DIST_ARCHIVES) test/test_coverage.sh
	rm $(DIST_ARCHIVES)