diff --git a/.travis.yml b/.travis.yml index 6cbf65c..8f8bb6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,5 +15,8 @@ before_script: - flex --version - if [ "$TRAVIS_OS_NAME" != "osx" ]; then valgrind --version; fi script: - - make + - make -f Makefile.sample all test.pl - if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./test.pl; else ./test.pl --valgrind; fi + - autoreconf --install + - ./configure + - make distcheck diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..ad20667 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,37 @@ +bin_PROGRAMS = detex + +detex_SOURCES = detex.h detex.l +detex_AMCFLAGS = -O +# detex_AMCPPFLAGS = -DVERSION=\"${VERSION}\" + +dist_man_MANS = detex.1 + +TESTS = test.pl +TEST_EXTENSIONS = .pl +PL_LOG_COMPILER = $(PERL) +AM_PL_LOG_FLAGS = -w + +dist_check_DATA = test/correct.txt test/in.tex test/noinclude.tex \ + test/noinclude-correct.txt test/nouns.tex \ + test/nouns-correct.txt test/part.tex test/unterminated.txt \ + test/words.tex test/words-correct.txt +dist_check_SCRIPTS = test.pl valgrind.sh + +EXTRA_DIST = ChangeLog COPYRIGHT INSTALL README README-development.md \ + CONTRIBUTING Makefile.sample + +install-exec-hook: + (cd "$(DESTDIR)$(bindir)" && rm -f delatex && $(LN_S) detex$(EXEEXT) delatex) + +uninstall-hook: + (cd "$(DESTDIR)$(bindir)" && rm -f delatex) + +installcheck-local: + test -x "$(DESTDIR)$(bindir)/detex$(EXEEXT)" + test -x "$(DESTDIR)$(bindir)/delatex" + +check-valgrind: + ./test.pl --valgrind + +print: detex.h detex.l + lpr -p Makefile detex.h detex.l diff --git a/Makefile b/Makefile.sample similarity index 95% rename from Makefile rename to Makefile.sample index 963daf0..a98682a 100644 --- a/Makefile +++ b/Makefile.sample @@ -140,11 +140,16 @@ clean: -rm -f a.out core *.s *.o ERRS errs .,* .emacs_[0-9]* -rm -f ${PROGS} xxx.l lex.yy.c detex.c -rm -f *.tar.bz2 + -rm -f config.h test.pl print: ${HDR} ${SRC} ${LPR} Makefile ${HDR} ${SRC} -test: all +test.pl: test.pl.in + sed -e 's/@top_srcdir@/./g' test.pl.in >test.pl + chmod u+x test.pl + +test: all test.pl ./test.pl run: delatex @@ -158,3 +163,7 @@ package: clean detex.c detex.c: detex.h detex.c: detex.l +detex.o: config.h + +config.h: + touch config.h diff --git a/README-development.md b/README-development.md index 771a34e..5bb04d1 100644 --- a/README-development.md +++ b/README-development.md @@ -16,7 +16,7 @@ After pushing check cross-platform compilation results on commits list on GitHub 1. Create a commit setting version to stable: - ChangeLog: change UNRELEASED to current date - - Makefile: strip -UNRELEASED from version number + - Makefile.sample and configure.ac: strip -UNRELEASED from version number - README: remove UNRELEASED 2. Make sure it works: `make clean test package` 3. Git-tag this version like "v2.8.5" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..02f5ee4 --- /dev/null +++ b/configure.ac @@ -0,0 +1,46 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.69]) +AC_INIT([opendetex], [2.8.6-UNRELEASED], [BUG-REPORT-ADDRESS]) +AC_CONFIG_SRCDIR([detex.h]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_AUX_DIR([aux_files]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([foreign dist-bzip2]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_LEX +AX_PROG_FLEX([AC_SUBST([FLEX_SCANNER], [1])], []) +AC_PROG_LN_S +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PATH_PROG([PERL], [perl]) +AX_CFLAGS_WARN_ALL + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lfl': +AC_CHECK_LIB([fl], [yylex]) +# also yywrap, yyrestart + +# Checks for header files. +AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/param.h limits.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_CHECK_HEADER_STDBOOL + +# Checks for library functions. +AC_FUNC_MALLOC +AC_CHECK_FUNCS([strchr strrchr]) + +AC_CONFIG_FILES([Makefile test.pl]) +dnl AC_CONFIG_LINKS([correct.txt:test/correct.txt in.tex:test/in.tex +dnl noinclude.tex:test/noinclude.tex +dnl noinclude-correct.txt:test/noinclude-corrext.txt +dnl nouns.tex:test/nouns.tex nouns-correct.txt:test/nouns-correct.txt +dnl part.tex:test/part.tex unterminated.txt:test/unterminated.txt +dnl words.tex:test/words.tex words-correct.txt:test/words-correct.txt]) +AC_CONFIG_LINKS([part.tex:test/part.tex]) +AC_OUTPUT diff --git a/detex.l b/detex.l index 4b638f9..72cb67b 100644 --- a/detex.l +++ b/detex.l @@ -47,6 +47,7 @@ * file. */ +#include "config.h" #include "detex.h" #ifdef KPATHSEA diff --git a/test.pl b/test.pl.in similarity index 84% rename from test.pl rename to test.pl.in index d330bf3..20f1180 100755 --- a/test.pl +++ b/test.pl.in @@ -18,14 +18,14 @@ sub assert_produces_correct_output { my ($input, $correct, $options) = @_; $options ||= ''; my $options_desc = $options ? " ($options)" : ''; - print "Checking correct output is produced for $input->$correct$options_desc...\n"; - chdir 'test'; - execute_cmd("../delatex $options $input > /tmp/testDelatex.txt"); - my $compared = "$correct /tmp/testDelatex.txt"; + print "Checking correct output is produced for $input->$correct$options_desc\n"; + execute_cmd("./detex $options @top_srcdir@/test/$input > /tmp/testDelatex.txt"); + + my $compared = "@top_srcdir@/test/$correct /tmp/testDelatex.txt"; my $diffResult = `diff $compared 2>&1`; if ($diffResult ne '') { - print "Test failed:\n"; + print "Test failed:\n": if (`which kdiff3`) { system("kdiff3 $compared"); } elsif (!$ENV{CI} && `which vimdiff`) { @@ -35,18 +35,17 @@ sub assert_produces_correct_output { } exit(11); } - chdir '..' } sub run_for_wrong_input { my ($input) = @_; print "Checking response for $input...\n"; - execute_cmd("./delatex $input"); + execute_cmd("./detex @top_srcdir@/$input"); } sub execute_cmd { my ($cmd) = @_; - system(get_cmd($cmd)) == 0 or die; + system(get_cmd($cmd)) or die; } sub get_cmd { diff --git a/test/in.tex b/test/in.tex index 082a459..0d556c7 100644 --- a/test/in.tex +++ b/test/in.tex @@ -103,7 +103,7 @@ \chapter*{First} b + c$ should not produce an empty line -\input{part} +\input{test/part} \newcounter{equation} where\addtocounter{equation}{1}\setcounter{equation}{50}