Skip to content

Commit

Permalink
adjustment for different build dir
Browse files Browse the repository at this point in the history
  • Loading branch information
fceller committed Jan 4, 2012
1 parent 668fb3c commit 50c022f
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 128 deletions.
63 changes: 6 additions & 57 deletions Makefile.am
Expand Up @@ -19,73 +19,22 @@ include Makefile.files
## FLEX
################################################################################

if ENABLE_FLEX

@srcdir@/%.c: @srcdir@/%.l
@top_srcdir@/config/flex-c.sh $(LEX) `dirname $@` `basename $^ .l`

else

@srcdir@/%.c: @srcdir@/%.l
@echo '+---------------------------------------------------------------+'
@echo '| WARNING: required FLEX version not found, cannot update files |'
@echo '+---------------------------------------------------------------+'

endif
JsonParser/%.c: @srcdir@/JsonParser/%.l
@top_srcdir@/config/flex-c.sh $(LEX) "$@" "$^"

################################################################################
## FLEX++
################################################################################

if ENABLE_FLEX

@srcdir@/%.cpp: @srcdir@/%.ll
@top_srcdir@/config/flex-c++.sh $(LEX) `dirname $@` `basename $^ .ll`

else

@srcdir@/%.cpp: @srcdir@/%.ll
@echo '+---------------------------------------------------------------+'
@echo '| WARNING: required FLEX version not found, cannot update files |'
@echo '+---------------------------------------------------------------+'

endif

################################################################################
## BISON
################################################################################

if ENABLE_BISON

@srcdir@/%.cpp: @srcdir@/%.yy
@top_srcdir@/config/bison-c.sh $(BISON) `dirname $@` `basename $^ .yy`

else

@srcdir@/%.cpp: @srcdir@/%.yy
@echo '+----------------------------------------------------------------+'
@echo '| WARNING: required BISON version not found, cannot update files |'
@echo '+----------------------------------------------------------------+'

endif
V8/%.cpp: @srcdir@/V8/%.ll
@top_srcdir@/config/flex-c++.sh $(LEX) "$@" "$^"

################################################################################
## BISON++
################################################################################

if ENABLE_BISON

@srcdir@/%.cpp: @srcdir@/%.yy
@top_srcdir@/config/bison-c++.sh $(BISON) `dirname $@` `basename $^ .yy`

else

@srcdir@/%.cpp: @srcdir@/%.yy
@echo '+----------------------------------------------------------------+'
@echo '| WARNING: required BISON version not found, cannot update files |'
@echo '+----------------------------------------------------------------+'

endif
JsonParserX/%.cpp: @srcdir@/JsonParserX/%.yy
@top_srcdir@/config/bison-c++.sh $(BISON) "$@" "$^"

################################################################################
## build information
Expand Down
5 changes: 5 additions & 0 deletions Makefile.files
Expand Up @@ -219,18 +219,23 @@ BUILT_SOURCES += \
@builddir@/js/js-modules.h

@builddir@/js/js-modules.h: @srcdir@/js/modules.js
@test -d @builddir@/js || mkdir @builddir@/js || true
@top_srcdir@/config/js2c.sh $^ > $@

@builddir@/js/js-json.h: @srcdir@/js/json.js
@test -d @builddir@/js || mkdir @builddir@/js || true
@top_srcdir@/config/js2c.sh $^ > $@

@builddir@/js/js-graph.h: @srcdir@/js/graph.js
@test -d @builddir@/js || mkdir @builddir@/js || true
@top_srcdir@/config/js2c.sh $^ > $@

@builddir@/js/js-shell.h: @srcdir@/js/shell.js
@test -d @builddir@/js || mkdir @builddir@/js || true
@top_srcdir@/config/js2c.sh $^ > $@

@builddir@/js/js-actions.h: @srcdir@/js/actions.js
@test -d @builddir@/js || mkdir @builddir@/js || true
@top_srcdir@/config/js2c.sh $^ > $@

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion build.h
@@ -1 +1 @@
#define TRIAGENS_VERSION "0.0.8 [1101:1102M]"
#define TRIAGENS_VERSION "0.0.8 [exported]"
38 changes: 14 additions & 24 deletions config/bison-c++.sh
@@ -1,56 +1,46 @@
#!/bin/sh

BISON="$1"
SRC="$2"
DST="$2"
FILE="$3"
OUTPUT="$2"
INPUT="$3"

if test "x$BISON" = x -o "x$SRC" = x -o "x$DST" = x -o "x$FILE" = x; then
echo "usage: $0 <bison> <directory> <file-prefix>"
exit 1
fi

if test ! -d "$SRC"; then
echo "$0: expecting '$SRC' to be a directory"
exit 1
fi

if test ! -d "$DST"; then
echo "$0: expecting '$DST' to be a directory"
if test "x$BISON" = x -o "x$OUTPUT" = x -o "x$INPUT" = x; then
echo "usage: $0 <bison> <output> <input>"
exit 1
fi

#############################################################################
## bison
#############################################################################

${BISON} -l -d -ra -S lalr1.cc -o "${DST}/${FILE}.cpp" "${SRC}/${FILE}.yy"
${BISON} -l -d -ra -S lalr1.cc -o ${OUTPUT} ${INPUT}

#############################################################################
## sanity checks
#############################################################################

test -f ${SRC}/${FILE}.hpp || exit 1
test -f ${SRC}/${FILE}.cpp || exit 1
test -f ${SRC}/position.hh || exit 1
PREFIX=`echo ${OUTPUT} | sed -e 's:\.cpp$::'`

test -f ${PREFIX}.hpp || exit 1
test -f ${PREFIX}.cpp || exit 1

#############################################################################
## rename file
#############################################################################

mv ${SRC}/${FILE}.hpp ${SRC}/${FILE}.h || exit 1
mv ${PREFIX}.hpp ${PREFIX}.h || exit 1

#############################################################################
## fix header file name in source, fix defines
#############################################################################

sed -e 's:\.hpp:.h:' < ${SRC}/${FILE}.cpp \
sed -e 's:\.hpp:.h:' < ${OUTPUT} \
| sed -e 's:# if YYENABLE_NLS:# if defined(YYENABLE_NLS) \&\& YYENABLE_NLS:' \
> ${SRC}/${FILE}.cpp.tmp
> ${OUTPUT}.tmp

# give some information
diff -u ${SRC}/${FILE}.cpp ${SRC}/${FILE}.cpp.tmp
diff -u ${OUTPUT} ${OUTPUT}.tmp

# and move the files to the final destination
mv ${SRC}/${FILE}.cpp.tmp ${SRC}/${FILE}.cpp || exit 1
mv ${OUTPUT}.tmp ${OUTPUT} || exit 1

8 changes: 4 additions & 4 deletions config/build_header.sh
Expand Up @@ -11,11 +11,11 @@ if test -d .svn; then
revision=`svnversion`
else
if test ! -f "$INFO"; then
echo "$0: cannot open info file $INFO"
exit 1
echo "WARNING: cannot open info file $INFO"
revision="exported"
else
revision=`grep 'Revision:' $INFO | awk '{print $2}'`
fi

revision=`grep 'Revision:' $INFO | awk '{print $2}'`
fi

if test -z "$revision"; then
Expand Down
25 changes: 10 additions & 15 deletions config/flex-c++.sh
@@ -1,41 +1,36 @@
#!/bin/sh

FLEX="$1"
DIR="$2"
FILE="$3"
OUTPUT="$2"
INPUT="$3"

if test "x$FLEX" = "x" -o "x$DIR" = "x" -o "x$FILE" = "x" -o ! -d "$DIR"; then
echo "usage: $0 <flex> <directory> <file-prefix>"
exit 1
fi

if test ! -d "$DIR"; then
echo "$0: expecting '$DIR' to be a directory"
if test "x$FLEX" = "x" -o "x$OUTPUT" = "x" -o "x$INPUT" = "x"; then
echo "usage: $0 <flex> <output> <input>"
exit 1
fi

#############################################################################
## flex
#############################################################################

${FLEX} -L -o${DIR}/${FILE}.cpp ${DIR}/${FILE}.ll
${FLEX} -L -o${OUTPUT} ${INPUT}

#############################################################################
## sanity checks
#############################################################################

test -f ${DIR}/${FILE}.cpp || exit 1
test -f ${OUTPUT} || exit 1

#############################################################################
## fix casts
#############################################################################

cat ${DIR}/${FILE}.cpp \
cat ${OUTPUT} \
| sed -e 's:(yy_n_chars), (size_t) num_to_read );:(yy_n_chars), (int) num_to_read );:' \
> ${DIR}/${FILE}.cpp.tmp
> ${OUTPUT}.tmp

# give some information
diff -u ${DIR}/${FILE}.cpp ${DIR}/${FILE}.cpp.tmp
diff -u ${OUTPUT} ${OUTPUT}.tmp

# and move the files to the final destination
mv ${DIR}/${FILE}.cpp.tmp ${DIR}/${FILE}.cpp || exit 1
mv ${OUTPUT}.tmp ${OUTPUT} || exit 1
29 changes: 11 additions & 18 deletions config/flex-c.sh
@@ -1,44 +1,37 @@
#!/bin/sh

FLEX="$1"
DIR="$2"
FILE="$3"
OUTPUT="$2"
INPUT="$3"

if test "x$FLEX" = "x" -o "x$DIR" = "x" -o "x$FILE" = "x" -o ! -d "$DIR"; then
echo "usage: $0 <flex> <directory> <file-prefix>"
exit 1
fi

if test ! -d "$DIR"; then
echo "$0: expecting '$DIR' to be a directory"
if test "x$FLEX" = "x" -o "x$OUTPUT" = "x" -o "x$INPUT" = "x"; then
echo "usage: $0 <flex> <output> <input>"
exit 1
fi

#############################################################################
## flex
#############################################################################

${FLEX} -L -o${DIR}/${FILE}.c ${DIR}/${FILE}.l
${FLEX} -L -o${OUTPUT} ${INPUT}

#############################################################################
## sanity checks
#############################################################################

test -f ${DIR}/${FILE}.c || exit 1
test -f ${OUTPUT} || exit 1

#############################################################################
## fix casts
#############################################################################

cat ${DIR}/${FILE}.c \
cat ${OUTPUT} \
| sed -e 's:yy_n_chars, (size_t) num_to_read );:yy_n_chars, (int) num_to_read );:' \
| sed -e 's:extern int isatty (int );:#ifndef _WIN32\
\0\
#endif:' \
> ${DIR}/${FILE}.c.tmp
| awk '$0 == "extern int isatty (int );" {print "#ifndef _WIN32"; print $0; print "#endif"; next;} {print $0}' \
> ${OUTPUT}.tmp

# give some information
diff -u ${DIR}/${FILE}.c ${DIR}/${FILE}.c.tmp
diff -u ${OUTPUT} ${OUTPUT}.tmp

# and move the files to the final destination
mv ${DIR}/${FILE}.c.tmp ${DIR}/${FILE}.c || exit 1
mv ${OUTPUT}.tmp ${OUTPUT} || exit 1
2 changes: 1 addition & 1 deletion config/js2c.sh
Expand Up @@ -3,4 +3,4 @@ NAME=`basename $1 .js`

cat $1 \
| sed -e 's:\(["\]\):\\\0:g' \
| awk 'BEGIN {print "static string JS_'$NAME' = " } { print " \"" $$0 "\\n\"" } END { print ";"}'
| awk 'BEGIN {print "static string JS_'$NAME' = " } { print " \"" $0 "\\n\"" } END { print ";"}'
8 changes: 0 additions & 8 deletions m4/external.boost
Expand Up @@ -49,14 +49,6 @@ AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
AC_SUBST(BOOST_LIBS)

dnl -----------------------------------------------------------------------------------------
dnl restore flags
dnl -----------------------------------------------------------------------------------------

LIBS="$SAVE_LIBS"
LDFLAGS="$SAVE_LDFLAGS"
CPPFLAGS="$SAVE_CPPFLAGS"

dnl -----------------------------------------------------------------------------------------
dnl informational output
dnl -----------------------------------------------------------------------------------------
Expand Down

0 comments on commit 50c022f

Please sign in to comment.