Added mingw builds for windows.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 11 May 2015 10:13:34 +0000 (11:13 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 11 May 2015 10:13:34 +0000 (11:13 +0100)
To enable mingw build, confugure with "--host i686-w64-mingw32".
Simple 'make' will then build re2c.exe executable for windows.
Note that 'make bootstrap' will not work: it will try to run
re2c.exe in order to recompile scanner and this will surely fail.

Testing with wine can be done using 'make wtests'.

re2c/Makefile.am
re2c/README
re2c/build_mingw.sh [new file with mode: 0755]
re2c/run_tests.sh.in

index bdbc23d5298020eae9c992b7017d7e449c753c3e..d1e8ec7eac9b7831f61b59ba5cc247dc15a7307e 100644 (file)
@@ -163,6 +163,9 @@ tests: all $(TESTS)
 .PHONY: vtests
 vtests: all $(TESTS)
        ./$(TESTS) --valgrind
+.PHONY: wtests
+wtests: all $(TESTS)
+       ./$(TESTS) --wine -j1
 
 .PHONY: docs
 if REBUILD_DOCS
index be2a0db0ae48986be5698b5795a3fad4813e1aed..a73cd90612433aa484734d7382c79664168bd5ad 100644 (file)
@@ -35,14 +35,23 @@ Clone git repo:
 
 BUILD
 --------------------------------------------------------------------------------
-Simplest possible build:
+Contents:
+    1. simple build
+    2. bootstrap
+    3. out-of-source build
+    4. testing
+    5. rebuild documentation
+    6. build for windows with mingw
+    7. build from git
+
+1. Simplest possible build:
     $ ./configure [--prefix=<prefix>]
     $ make
     $ make install
 This will build re2c and install it (binary and man page) to <prefix> (defaults
 to /usr/local).
 
-Bootstrap and rebuild:
+2. Bootstrap and rebuild:
     $ ./configure [--prefix=<prefix>]
     $ make bootstrap
     $ make install
@@ -53,26 +62,32 @@ Usual bootstrap procedure: re2c uses re2c to compile its lexer.
 3. build lexer from source using re2c binary in build directory
 4. rebuild re2c
 
-Out-of-source build:
+3. Out-of-source build:
     $ mkdir <build-directory>
     $ cd <build-directory>
     $ <path-to-configure>/configure [--prefix=<prefix>]
     $ make
     $ make install
 
-Testing:
+4. Testing:
     $ make check
 This will redirect test script output to file. If you want to see progress:
     $ make tests
 Testing under valgrind (takes a long time):
     $ make vtests
 
-Rebuild documentation (requires asciidoc and a2x):
+5. Rebuild documentation (requires asciidoc and a2x):
     $ ./configure --enable-docs [--prefix=<prefix>]
     $ make docs
     $ make install
 
-If you want to build from git, you'll first need to generate autotools files:
+6. Build for windows using mingw:
+    $ ../configure --host i686-w64-mingw32  [--prefix=<prefix>]
+    $ make
+This will result into an executable re2c.exe, which can be tested with wine:
+    $ make wtests
+
+7. If you want to build from git, you'll first need to generate autotools files:
     $ ./autogen.sh
 --------------------------------------------------------------------------------
 
diff --git a/re2c/build_mingw.sh b/re2c/build_mingw.sh
new file mode 100755 (executable)
index 0000000..f5980b3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+builddir=.build_mingw
+rm -rf $builddir
+mkdir $builddir
+
+cd $builddir
+../configure --enable-silent-rules --host i686-w64-mingw32 && \
+make -j5
+cd ..
index 59c4823bd9526f2bf68e753fbe80bc731b9e36e8..99a833a552b7bfae009e959c4a6bbfd054b84c3d 100644 (file)
@@ -18,16 +18,21 @@ detect_cpu_count () {
         # nothing helped
         CPUS="1"
     fi
-    echo "using ${CPUS} CPUs" >&2
 }
 
 valgrind=""
+wine=""
+re2c="@builddir@/re2c"
 threads=`detect_cpu_count; echo $CPUS`
 tests=()
 for arg in $*
 do
        case $arg in
                "--valgrind" ) valgrind=`which valgrind` ;;
+               "--wine" )
+                       wine=`which wine`
+                       re2c="${re2c}.exe"
+                       ;;
                "-j"* )
                        number=${arg#-j}
                        number_pattern='^[0-9]+$'
@@ -39,6 +44,7 @@ do
                * ) tests+=("$arg") ;;
        esac
 done
+echo "Running in ${threads} thread(s)"
 
 testdir="@srcdir@/test"
 if [ ${#tests[@]} -eq 0 ]
@@ -53,7 +59,6 @@ do
        packs[$i]=${tests[@]:j:tests_per_thread}
 done
 
-re2c='@builddir@/re2c'
 if test ! -x "${re2c}"
 then
        echo "Cannot find re2c executable (${re2c})."
@@ -71,10 +76,9 @@ then
                "--malloc-fill=0xa1"
                "--free-fill=0xa1"
                )
-       valgrind="${valgrind} ${valgrind_options[@]} "
+       valgrind="${valgrind} ${valgrind_options[@]}"
        echo $valgrind
 fi
-re2c="${valgrind}${re2c}"
 
 run_pack() {
        local log="$1"
@@ -93,7 +97,12 @@ run_pack() {
                local typname=$testdir/`basename ${x%.re}.h.temp`
                local typdiff=$testdir/`basename ${x%.re}.h.diff`
 
-               $re2c $switches $x 2>&1 | LC_ALL=C sed -e "s,$x,`basename $x`,g" -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' > $outname
+               local cmd="${valgrind} ${wine} ${re2c} $switches $x"
+               if test -n "${wine}"
+               then
+                       local filter_newlines='-e s/\r//g'
+               fi
+               $cmd 2>&1 | LC_ALL=C sed -e "s,$x,`basename $x`,g" -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' ${filter_newlines} > $outname
                if test -n "$genname"
                then
                        cat $genname | sed -e 's,'"$testdir"'/,,g' -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' > $outname