Skip to content

Commit

Permalink
build: allow to build ctags even if bash and seq are not available in…
Browse files Browse the repository at this point in the history
… build environment

bash and seq are needed to run optlib2c translator.
If they are not available, use pre-translated C code for building ctags executable.

Close universal-ctags#794.

Using /usr/bin/env is suggested by @jockej.
  • Loading branch information
masatake committed Feb 18, 2016
1 parent f2fef59 commit 54fc59c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ $(REPOINFO_HEADS):
echo > $@
endif

if RUN_OPTLIB2C
optlib2c_verbose = $(optlib2c_verbose_@AM_V@)
optlib2c_verbose_ = $(optlib2c_verbose_@AM_DEFAULT_V@)
optlib2c_verbose_0 = @echo OPTLIB2C " $@";
OPTLIB2C = $(srcdir)/misc/optlib2c
%.c: %.ctags $(OPTLIB2C) Makefile
$(optlib2c_verbose)$(OPTLIB2C) --transform-xcmd="$(program_transform_name)" $< > $@
endif
dist_ctags_SOURCES = $(ALL_HEADS) $(ALL_SRCS)

man_MANS = ctags.1
Expand Down
30 changes: 23 additions & 7 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/bin/sh
misc/dist-test-cases > makefiles/test-cases.mak && \
autoreconf -vfi && {
for i in `make -f makefiles/list-translator-input.mak`; do
o=${i%.ctags}.c
echo "optlib2c: translating $i to $o"
./misc/optlib2c $i > $o
done

verify_optlib2c_requirements()
{
: &&
which bash > /dev/null &&
which seq > /dev/null
}

ctags_files=`make -f makefiles/list-translator-input.mak`
misc/dist-test-cases > makefiles/test-cases.mak && \
if autoreconf -vfi; then
if can_run_optlib2c; then
for i in ${ctags_files}; do
o=${i%.ctags}.c
echo "optlib2c: translating $i to $o"
./misc/optlib2c $i > $o
done
else
for i in ${ctags_files}; do
o=${i%.ctags}.c
echo "use pre-translated file: $o"
done
fi
fi

exit $?
9 changes: 5 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ AC_PROG_LN_S
AC_CHECK_PROG(STRIP, strip, strip, :)
AC_SYS_LARGEFILE

AC_CHECK_PROGS([BASH], [bash])
if ! test "${BASH+set}" = "set"; then
AC_MSG_ERROR([bash is needed to run optlib2c translator])
fi
AC_CHECK_PROG([bash_found], [bash], [yes], [no])
AC_CHECK_PROG([seq_found], [seq], [yes], [no])
AM_CONDITIONAL([RUN_OPTLIB2C],
[test "${bash_found}" = "yes" -a "${seq_found}" = "yes"])


# Checks for operating environment
# --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion misc/optlib2c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# optlib2c - a tool translating ctags option file to C
#
Expand Down

0 comments on commit 54fc59c

Please sign in to comment.