summaryrefslogtreecommitdiff
path: root/dev/build
diff options
context:
space:
mode:
Diffstat (limited to 'dev/build')
-rwxr-xr-xdev/build/osx/make-macos-dmg.sh19
-rw-r--r--dev/build/windows/MakeCoq_84pl6_abs_ocaml.bat22
-rw-r--r--dev/build/windows/MakeCoq_85pl2_abs_ocaml.bat22
-rw-r--r--dev/build/windows/MakeCoq_85pl3_abs_ocaml.bat22
-rw-r--r--dev/build/windows/MakeCoq_85pl3_installer.bat22
-rw-r--r--dev/build/windows/MakeCoq_85pl3_installer_32.bat22
-rw-r--r--dev/build/windows/MakeCoq_86git_abs_ocaml.bat22
-rw-r--r--dev/build/windows/MakeCoq_86git_abs_ocaml_gtksrc.bat22
-rw-r--r--dev/build/windows/MakeCoq_86git_installer.bat22
-rw-r--r--dev/build/windows/MakeCoq_86git_installer_32.bat22
-rwxr-xr-xdev/build/windows/MakeCoq_86git_installer_cyglocal.bat27
-rwxr-xr-xdev/build/windows/MakeCoq_88git_installer.bat27
-rwxr-xr-x[-rw-r--r--]dev/build/windows/MakeCoq_MinGW.bat225
-rw-r--r--dev/build/windows/MakeCoq_SetRootPath.bat11
-rwxr-xr-xdev/build/windows/MakeCoq_explicitcachefolders_installer.bat28
-rwxr-xr-xdev/build/windows/MakeCoq_local_installer.bat26
-rw-r--r--dev/build/windows/MakeCoq_regtest_noproxy.bat17
-rw-r--r--dev/build/windows/MakeCoq_regtests.bat42
-rwxr-xr-xdev/build/windows/MakeCoq_trunk_installer.bat26
-rw-r--r--dev/build/windows/ReadMe.txt29
-rw-r--r--dev/build/windows/configure_profile.sh15
-rw-r--r--dev/build/windows/difftar-folder.sh63
-rwxr-xr-x[-rw-r--r--]dev/build/windows/makecoq_mingw.sh1141
-rw-r--r--dev/build/windows/patches_coq/ReplaceInFile.nsh67
-rw-r--r--dev/build/windows/patches_coq/StrRep.nsh60
-rw-r--r--dev/build/windows/patches_coq/aactactis-86ac28259030649ef51460e4de2441c8a1017751.patch21
-rw-r--r--dev/build/windows/patches_coq/coq_new.nsi191
-rw-r--r--dev/build/windows/patches_coq/lablgtk-2.18.3.patch44
-rw-r--r--dev/build/windows/patches_coq/lablgtk-2.18.6.patch101
-rw-r--r--dev/build/windows/patches_coq/ln.c2
-rw-r--r--dev/build/windows/patches_coq/quickchick-v1.0.2.patch38
-rwxr-xr-xdev/build/windows/patches_coq/sed-4.2.2-3.src.patch1301
-rwxr-xr-xdev/build/windows/patches_coq/sed-4.2.2.patch1301
33 files changed, 4413 insertions, 607 deletions
diff --git a/dev/build/osx/make-macos-dmg.sh b/dev/build/osx/make-macos-dmg.sh
index b43ada90..dc33838f 100755
--- a/dev/build/osx/make-macos-dmg.sh
+++ b/dev/build/osx/make-macos-dmg.sh
@@ -4,32 +4,25 @@
set -e
# Configuration setup
-eval `opam config env`
-make distclean
OUTDIR=$PWD/_install
DMGDIR=$PWD/_dmg
-./configure -debug -prefix $OUTDIR -native-compiler no
VERSION=$(sed -n -e '/^let coq_version/ s/^[^"]*"\([^"]*\)"$/\1/p' configure.ml)
APP=bin/CoqIDE_${VERSION}.app
-# Create a .app file with CoqIDE
-~/.local/bin/jhbuild run make -j -l2 $APP
-
-# Build Coq and run test-suite
-make && make check
+# Create a .app file with CoqIDE, without signing it
+make PRIVATEBINARIES=$APP -j $NJOBS -l2 $APP
# Add Coq to the .app file
make OLDROOT=$OUTDIR COQINSTALLPREFIX=$APP/Contents/Resources/ install-coq install-ide-toploop
-# Sign the .app file
-codesign -f -s - $APP
-
# Create the dmg bundle
mkdir -p $DMGDIR
ln -sf /Applications $DMGDIR/Applications
cp -r $APP $DMGDIR
+mkdir -p _build
+
# Temporary countermeasure to hdiutil error 5341
-head -c9703424 /dev/urandom > $DMGDIR/.padding
+# head -c9703424 /dev/urandom > $DMGDIR/.padding
-hdiutil create -imagekey zlib-level=9 -volname CoqIDE_$VERSION -srcfolder $DMGDIR -ov -format UDZO CoqIDE_$VERSION.dmg
+hdiutil create -imagekey zlib-level=9 -volname coq-$VERSION-installer-macos -srcfolder $DMGDIR -ov -format UDZO _build/coq-$VERSION-installer-macos.dmg
diff --git a/dev/build/windows/MakeCoq_84pl6_abs_ocaml.bat b/dev/build/windows/MakeCoq_84pl6_abs_ocaml.bat
index bdcb01db..9dbce192 100644
--- a/dev/build/windows/MakeCoq_84pl6_abs_ocaml.bat
+++ b/dev/build/windows/MakeCoq_84pl6_abs_ocaml.bat
@@ -1,3 +1,16 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
@@ -6,5 +19,10 @@ call MakeCoq_MinGW.bat ^
-ocaml=Y ^
-make=Y ^
-coqver=8.4pl6 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_84pl6_abs ^
- -destcoq=%ROOTPATH%\coq64_84pl6_abs
+ -destcyg="%ROOTPATH%\cygwin_coq64_84pl6_abs" ^
+ -destcoq="%ROOTPATH%\coq64_84pl6_abs"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_84pl6_abs_ocaml.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_85pl2_abs_ocaml.bat b/dev/build/windows/MakeCoq_85pl2_abs_ocaml.bat
index 2e4a692e..7faf3e9c 100644
--- a/dev/build/windows/MakeCoq_85pl2_abs_ocaml.bat
+++ b/dev/build/windows/MakeCoq_85pl2_abs_ocaml.bat
@@ -1,3 +1,16 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
@@ -6,5 +19,10 @@ call MakeCoq_MinGW.bat ^
-ocaml=Y ^
-make=Y ^
-coqver=8.5pl2 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_85pl2_abs ^
- -destcoq=%ROOTPATH%\coq64_85pl2_abs
+ -destcyg="%ROOTPATH%\cygwin_coq64_85pl2_abs" ^
+ -destcoq="%ROOTPATH%\coq64_85pl2_abs"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_85pl2_abs_ocaml.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_85pl3_abs_ocaml.bat b/dev/build/windows/MakeCoq_85pl3_abs_ocaml.bat
index 6e4e440a..b719b14c 100644
--- a/dev/build/windows/MakeCoq_85pl3_abs_ocaml.bat
+++ b/dev/build/windows/MakeCoq_85pl3_abs_ocaml.bat
@@ -1,3 +1,16 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
@@ -6,5 +19,10 @@ call MakeCoq_MinGW.bat ^
-ocaml=Y ^
-make=Y ^
-coqver=8.5pl3 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_85pl3_abs ^
- -destcoq=%ROOTPATH%\coq64_85pl3_abs
+ -destcyg="%ROOTPATH%\cygwin_coq64_85pl3_abs" ^
+ -destcoq="%ROOTPATH%\coq64_85pl3_abs"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_85pl3_abs_ocaml.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_85pl3_installer.bat b/dev/build/windows/MakeCoq_85pl3_installer.bat
index c305e2f5..a9f4e2da 100644
--- a/dev/build/windows/MakeCoq_85pl3_installer.bat
+++ b/dev/build/windows/MakeCoq_85pl3_installer.bat
@@ -1,8 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
-arch=64 ^
-installer=Y ^
-coqver=8.5pl3 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_85pl3_inst ^
- -destcoq=%ROOTPATH%\coq64_85pl3_inst
+ -destcyg="%ROOTPATH%\cygwin_coq64_85pl3_inst" ^
+ -destcoq="%ROOTPATH%\coq64_85pl3_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_85pl3_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_85pl3_installer_32.bat b/dev/build/windows/MakeCoq_85pl3_installer_32.bat
index d87ff591..ef593cc6 100644
--- a/dev/build/windows/MakeCoq_85pl3_installer_32.bat
+++ b/dev/build/windows/MakeCoq_85pl3_installer_32.bat
@@ -1,8 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
-arch=32 ^
-installer=Y ^
-coqver=8.5pl3 ^
- -destcyg=%ROOTPATH%\cygwin_coq32_85pl3_inst ^
- -destcoq=%ROOTPATH%\coq32_85pl3_inst
+ -destcyg="%ROOTPATH%\cygwin_coq32_85pl3_inst" ^
+ -destcoq="%ROOTPATH%\coq32_85pl3_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_85pl3_installer_32.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_86git_abs_ocaml.bat b/dev/build/windows/MakeCoq_86git_abs_ocaml.bat
index f1d855a0..99a1f156 100644
--- a/dev/build/windows/MakeCoq_86git_abs_ocaml.bat
+++ b/dev/build/windows/MakeCoq_86git_abs_ocaml.bat
@@ -1,3 +1,16 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
@@ -6,5 +19,10 @@ call MakeCoq_MinGW.bat ^
-ocaml=Y ^
-make=Y ^
-coqver=git-v8.6 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_86git_abs ^
- -destcoq=%ROOTPATH%\coq64_86git_abs
+ -destcyg="%ROOTPATH%\cygwin_coq64_86git_abs" ^
+ -destcoq="%ROOTPATH%\coq64_86git_abs"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_abs_ocaml.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_86git_abs_ocaml_gtksrc.bat b/dev/build/windows/MakeCoq_86git_abs_ocaml_gtksrc.bat
index 70ab42bc..896d1cd6 100644
--- a/dev/build/windows/MakeCoq_86git_abs_ocaml_gtksrc.bat
+++ b/dev/build/windows/MakeCoq_86git_abs_ocaml_gtksrc.bat
@@ -1,3 +1,16 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
@@ -7,5 +20,10 @@ call MakeCoq_MinGW.bat ^
-make=Y ^
-gtksrc=Y ^
-coqver=git-v8.6 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_86git_abs_gtksrc ^
- -destcoq=%ROOTPATH%\coq64_86git_abs_gtksrc
+ -destcyg="%ROOTPATH%\cygwin_coq64_86git_abs_gtksrc" ^
+ -destcoq="%ROOTPATH%\coq64_86git_abs_gtksrc"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_abs_ocaml_gtksrc.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_86git_installer.bat b/dev/build/windows/MakeCoq_86git_installer.bat
index 40506318..c4823103 100644
--- a/dev/build/windows/MakeCoq_86git_installer.bat
+++ b/dev/build/windows/MakeCoq_86git_installer.bat
@@ -1,8 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
-arch=64 ^
-installer=Y ^
-coqver=git-v8.6 ^
- -destcyg=%ROOTPATH%\cygwin_coq64_86git_inst ^
- -destcoq=%ROOTPATH%\coq64_86git_inst
+ -destcyg="%ROOTPATH%\cygwin_coq64_86git_inst" ^
+ -destcoq="%ROOTPATH%\coq64_86git_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_86git_installer_32.bat b/dev/build/windows/MakeCoq_86git_installer_32.bat
index b9127c94..19146c96 100644
--- a/dev/build/windows/MakeCoq_86git_installer_32.bat
+++ b/dev/build/windows/MakeCoq_86git_installer_32.bat
@@ -1,8 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
call MakeCoq_MinGW.bat ^
-arch=32 ^
-installer=Y ^
-coqver=git-v8.6 ^
- -destcyg=%ROOTPATH%\cygwin_coq32_86git_inst ^
- -destcoq=%ROOTPATH%\coq32_86git_inst
+ -destcyg="%ROOTPATH%\cygwin_coq32_86git_inst" ^
+ -destcoq="%ROOTPATH%\coq32_86git_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_installer_32.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_86git_installer_cyglocal.bat b/dev/build/windows/MakeCoq_86git_installer_cyglocal.bat
new file mode 100755
index 00000000..cf6cafaa
--- /dev/null
+++ b/dev/build/windows/MakeCoq_86git_installer_cyglocal.bat
@@ -0,0 +1,27 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
+call MakeCoq_SetRootPath
+
+call MakeCoq_MinGW.bat ^
+ -arch=64 ^
+ -installer=Y ^
+ -coqver=git-v8.6 ^
+ -cyglocal=Y ^
+ -destcyg="%ROOTPATH%\cygwin_coq64_86git_inst_cyglocal" ^
+ -destcoq="%ROOTPATH%\coq64_86git_inst_cyglocal"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_installer_cyglocal.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_88git_installer.bat b/dev/build/windows/MakeCoq_88git_installer.bat
new file mode 100755
index 00000000..b016fb38
--- /dev/null
+++ b/dev/build/windows/MakeCoq_88git_installer.bat
@@ -0,0 +1,27 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
+call MakeCoq_SetRootPath
+
+call MakeCoq_MinGW.bat ^
+ -arch=64 ^
+ -installer=Y ^
+ -coqver=git-v8.8 ^
+ -destcyg=%ROOTPATH%\cygwin_coq64_88_inst ^
+ -destcoq=%ROOTPATH%\coq64_88_inst ^
+ -addon=bignums
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_88git_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_MinGW.bat b/dev/build/windows/MakeCoq_MinGW.bat
index 1e08cc5a..61cf6bc4 100644..100755
--- a/dev/build/windows/MakeCoq_MinGW.bat
+++ b/dev/build/windows/MakeCoq_MinGW.bat
@@ -18,7 +18,7 @@ REM ========== DEFAULT VALUES FOR PARAMETERS ==========
REM For a description of all parameters, see ReadMe.txt
-SET BATCHFILE=%0
+SET BATCHFILE=%~0
SET BATCHDIR=%~dp0
REM see -arch in ReadMe.txt, but values are x86_64 or i686 (not 64 or 32)
@@ -34,7 +34,7 @@ REM see -ocaml in ReadMe.txt
SET INSTALLOCAML=N
REM see -make in ReadMe.txt
-SET INSTALLMAKE=Y
+SET INSTALLMAKE=N
REM see -destcyg in ReadMe.txt
SET DESTCYG=C:\bin\cygwin_coq
@@ -47,9 +47,11 @@ SET SETUP=setup-x86_64.exe
REM see -proxy in ReadMe.txt
IF DEFINED HTTP_PROXY (
- SET PROXY="%HTTP_PROXY:http://=%"
+ SET PROXY=%HTTP_PROXY:http://=%
) else (
- SET PROXY=""
+ REM One can't set a variable to empty in DOS, but you can set it to a space this way.
+ REM The quotes are just there to make the space visible and to protect from "remove trailing spaces".
+ SET "PROXY= "
)
REM see -cygrepo in ReadMe.txt
@@ -76,18 +78,21 @@ SET GTK_FROM_SOURCES=N
REM see -threads in ReadMe.txt
SET MAKE_THREADS=8
+REM see -addon in ReadMe.txt
+SET "COQ_ADDONS= "
+
REM ========== PARSE COMMAND LINE PARAMETERS ==========
SHIFT
:Parse
-IF "%0" == "-arch" (
- IF "%1" == "32" (
+IF "%~0" == "-arch" (
+ IF "%~1" == "32" (
SET ARCH=i686
SET SETUP=setup-x86.exe
) ELSE (
- IF "%1" == "64" (
+ IF "%~1" == "64" (
SET ARCH=x86_64
SET SETUP=setup-x86_64.exe
) ELSE (
@@ -100,15 +105,15 @@ IF "%0" == "-arch" (
GOTO Parse
)
-IF "%0" == "-mode" (
- IF "%1" == "mingwincygwin" (
- SET INSTALLMODE=%1
+IF "%~0" == "-mode" (
+ IF "%~1" == "mingwincygwin" (
+ SET INSTALLMODE=%~1
) ELSE (
- IF "%1" == "absolute" (
- SET INSTALLMODE=%1
+ IF "%~1" == "absolute" (
+ SET INSTALLMODE=%~1
) ELSE (
- IF "%1" == "relocatable" (
- SET INSTALLMODE=%1
+ IF "%~1" == "relocatable" (
+ SET INSTALLMODE=%~1
) ELSE (
ECHO "Invalid -mode, valid are mingwincygwin, absolute and relocatable"
GOTO :EOF
@@ -120,122 +125,137 @@ IF "%0" == "-mode" (
GOTO Parse
)
-IF "%0" == "-installer" (
- SET MAKEINSTALLER=%1
+IF "%~0" == "-installer" (
+ SET MAKEINSTALLER=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-ocaml" (
+ SET INSTALLOCAML=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-ocaml" (
- SET INSTALLOCAML=%1
+IF "%~0" == "-make" (
+ SET INSTALLMAKE=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-make" (
- SET INSTALLMAKE=%1
+IF "%~0" == "-destcyg" (
+ SET DESTCYG=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-destcyg" (
- SET DESTCYG=%1
+IF "%~0" == "-destcoq" (
+ SET DESTCOQ=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-destcoq" (
- SET DESTCOQ=%1
+IF "%~0" == "-setup" (
+ SET SETUP=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-setup" (
- SET SETUP=%1
+IF "%~0" == "-proxy" (
+ SET PROXY=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-proxy" (
- SET PROXY="%1"
+IF "%~0" == "-cygrepo" (
+ SET CYGWIN_REPOSITORY=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-cygrepo" (
- SET CYGWIN_REPOSITORY="%1"
+IF "%~0" == "-cygcache" (
+ SET CYGWIN_LOCAL_CACHE_WFMT=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-cygcache" (
- SET CYGWIN_LOCAL_CACHE_WFMT="%1"
+IF "%~0" == "-cyglocal" (
+ SET CYGWIN_FROM_CACHE=%~1
+ CALL :CheckYN -cyglocal %~1 || GOTO ErrorExit
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-cyglocal" (
- SET CYGWIN_FROM_CACHE=%1
+IF "%~0" == "-cygquiet" (
+ SET CYGWIN_QUIET=%~1
+ CALL :CheckYN -cygquiet %~1 || GOTO ErrorExit
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-cygquiet" (
- SET CYGWIN_QUIET=%1
+IF "%~0" == "-srccache" (
+ SET SOURCE_LOCAL_CACHE_WFMT=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-srccache" (
- SET SOURCE_LOCAL_CACHE_WFMT="%1"
+IF "%~0" == "-coqver" (
+ SET COQ_VERSION=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-coqver" (
- SET COQ_VERSION=%1
+IF "%~0" == "-gtksrc" (
+ SET GTK_FROM_SOURCES=%~1
+ CALL :CheckYN -gtksrc %~1 || GOTO ErrorExit
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-gtksrc" (
- SET GTK_FROM_SOURCES=%1
+IF "%~0" == "-threads" (
+ SET MAKE_THREADS=%~1
SHIFT
SHIFT
GOTO Parse
)
-IF "%0" == "-threads" (
- SET MAKE_THREADS=%1
+IF "%~0" == "-addon" (
+ SET "COQ_ADDONS=%COQ_ADDONS% %~1"
SHIFT
SHIFT
GOTO Parse
)
-IF NOT "%0" == "" (
+
+IF NOT "%~0" == "" (
ECHO Install cygwin and download, compile and install OCaml and Coq for MinGW
- ECHO !!! Illegal parameter %0
- ECHO Usage:
+ ECHO !!! Illegal parameter %~0
+ ECHO Usage:
ECHO MakeCoq_MinGW
CALL :PrintPars
- goto :EOF
+ GOTO :EOF
)
IF NOT EXIST %SETUP% (
ECHO The cygwin setup program %SETUP% doesn't exist. You must download it from https://cygwin.com/install.html.
+ ECHO If the setup is in a different folder, set the full path to %SETUP% using the -setup option.
GOTO :EOF
)
@@ -247,16 +267,14 @@ IF "%INSTALLMODE%" == "mingwincygwin" (
IF "%MAKEINSTALLER%" == "Y" (
SET INSTALLMODE=relocatable
- SET INSTALLOCAML=Y
- SET INSTALLMAKE=Y
)
REM ========== CONFIRM PARAMETERS ==========
CALL :PrintPars
REM Note: DOS batch replaces variables on parsing, so one can't use a variable just set in an () block
-IF "%COQREGTESTING%"=="Y" (GOTO :DontAsk)
- SET /p ANSWER=Is this correct? y/n
+IF "%COQREGTESTING%"=="Y" (GOTO DontAsk)
+ SET /p ANSWER="Is this correct? y/n "
IF NOT "%ANSWER%"=="y" (GOTO :EOF)
:DontAsk
@@ -296,12 +314,13 @@ ECHO RESULT INSTALL DIR (MINGW) = %RESULT_INSTALLDIR_MFMT%
ECHO RESULT INSTALL DIR (CYGWIN) = %RESULT_INSTALLDIR_CFMT%
REM WARNING: Add a space after the = in case you want set this to empty, otherwise the variable will be unset
-SET MAKE_OPT=-j %MAKE_THREADS%
+SET MAKE_OPT=-j %MAKE_THREADS%
REM ========== DERIVED CYGWIN SETUP OPTIONS ==========
-REM WARNING: Add a space after the = otherwise the variable will be unset
-SET CYGWIN_OPT=
+REM One can't set a variable to empty in DOS, but you can set it to a space this way.
+REM The quotes are just there to make the space visible and to protect from "remove trailing spaces".
+SET "CYGWIN_OPT= "
IF "%CYGWIN_FROM_CACHE%" == "Y" (
SET CYGWIN_OPT= %CYGWIN_OPT% -L
@@ -315,17 +334,9 @@ IF "%GTK_FROM_SOURCES%"=="N" (
SET CYGWIN_OPT= %CYGWIN_OPT% -P mingw64-%ARCH%-gtk2.0,mingw64-%ARCH%-gtksourceview2.0
)
-ECHO ========== INSTALL CYGWIN ==========
-
REM Cygwin setup sets proper ACLs (permissions) for folders it CREATES.
REM Otherwise chmod won't work and e.g. the ocaml build will fail.
REM Cygwin setup does not touch the ACLs of existing folders.
-REM => Create the setup log in a temporary location and move it later.
-
-REM Get Unique temporary file name
-:logfileloop
-SET LOGFILE=%TEMP%\CygwinSetUp%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.log
-if exist "%LOGFILE%" goto :logfileloop
REM Run Cygwin Setup
@@ -337,18 +348,31 @@ IF NOT "%CYGWIN_QUIET%" == "Y" (
SET RUNSETUP=Y
)
+IF "%COQREGTESTING%" == "Y" (
+ ECHO "========== REMOVE EXISTING CYGWIN =========="
+ DEL /S /F /Q "%CYGWIN_INSTALLDIR_WFMT%" > NUL
+ SET RUNSETUP=Y
+)
+
+SET "EXTRAPACKAGES= "
+
+IF NOT "%APPVEYOR%" == "True" (
+ SET EXTRAPACKAGES=-P wget,curl,git,gcc-core,gcc-g++,automake1.5
+)
+
+ECHO "========== INSTALL CYGWIN =========="
+
IF "%RUNSETUP%"=="Y" (
%SETUP% ^
- --proxy %PROXY% ^
- --site %CYGWIN_REPOSITORY% ^
- --root %CYGWIN_INSTALLDIR_WFMT% ^
- --local-package-dir %CYGWIN_LOCAL_CACHE_WFMT% ^
+ --proxy "%PROXY%" ^
+ --site "%CYGWIN_REPOSITORY%" ^
+ --root "%CYGWIN_INSTALLDIR_WFMT%" ^
+ --local-package-dir "%CYGWIN_LOCAL_CACHE_WFMT%" ^
--no-shortcuts ^
%CYGWIN_OPT% ^
- -P wget,curl,git,make,unzip ^
- -P gcc-core,gcc-g++ ^
+ -P make,unzip ^
-P gdb,liblzma5 ^
- -P patch,automake1.14,automake1.15 ^
+ -P patch,automake1.14 ^
-P mingw64-%ARCH%-binutils,mingw64-%ARCH%-gcc-core,mingw64-%ARCH%-gcc-g++,mingw64-%ARCH%-pkg-config,mingw64-%ARCH%-windows_default_manifest ^
-P mingw64-%ARCH%-headers,mingw64-%ARCH%-runtime,mingw64-%ARCH%-pthreads,mingw64-%ARCH%-zlib ^
-P libiconv-devel,libunistring-devel,libncurses-devel ^
@@ -358,15 +382,13 @@ IF "%RUNSETUP%"=="Y" (
-P gtk-update-icon-cache ^
-P libtool,automake ^
-P intltool ^
- > "%LOGFILE%" ^
- || GOTO :Error
+ %EXTRAPACKAGES% ^
+ || GOTO ErrorExit
- MKDIR %CYGWIN_INSTALLDIR_WFMT%\build
- MKDIR %CYGWIN_INSTALLDIR_WFMT%\build\buildlogs
- MOVE "%LOGFILE%" %CYGWIN_INSTALLDIR_WFMT%\build\buildlogs\cygwinsetup.log || GOTO :Error
+ MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build"
+ MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\buildlogs"
)
-
IF NOT "%CYGWIN_QUIET%" == "Y" (
REM Like most setup programs, cygwin setup starts the real setup as a separate process, so wait for it.
REM This is not required with the -cygquiet=Y and the resulting --no-admin option.
@@ -377,18 +399,24 @@ IF NOT "%CYGWIN_QUIET%" == "Y" (
ECHO ========== CONFIGURE CYGWIN USER ACCOUNT ==========
-copy %BATCHDIR%\configure_profile.sh %CYGWIN_INSTALLDIR_WFMT%\var\tmp || GOTO :Error
-%BASH% --login %CYGWIN_INSTALLDIR_CFMT%\var\tmp\configure_profile.sh %PROXY% || GOTO :Error
+REM In case this batch file is called from a cygwin bash (e.g. a git repo) we need to clear
+REM HOME (otherwise we get to the home directory of the other installation)
+REM PROFILEREAD (this is set to true if the /etc/profile has been read, which creates user)
+SET "HOME="
+SET "PROFILEREAD="
+
+copy "%BATCHDIR%\configure_profile.sh" "%CYGWIN_INSTALLDIR_WFMT%\var\tmp" || GOTO ErrorExit
+%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\var\tmp\configure_profile.sh" "%PROXY%" || GOTO ErrorExit
ECHO ========== BUILD COQ ==========
-MKDIR %CYGWIN_INSTALLDIR_WFMT%\build
-MKDIR %CYGWIN_INSTALLDIR_WFMT%\build\patches
+MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build"
+MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\patches"
-COPY %BATCHDIR%\makecoq_mingw.sh %CYGWIN_INSTALLDIR_WFMT%\build || GOTO :Error
-COPY %BATCHDIR%\patches_coq\*.* %CYGWIN_INSTALLDIR_WFMT%\build\patches || GOTO :Error
+COPY "%BATCHDIR%\makecoq_mingw.sh" "%CYGWIN_INSTALLDIR_WFMT%\build" || GOTO ErrorExit
+COPY "%BATCHDIR%\patches_coq\*.*" "%CYGWIN_INSTALLDIR_WFMT%\build\patches" || GOTO ErrorExit
-%BASH% --login %CYGWIN_INSTALLDIR_CFMT%\build\makecoq_mingw.sh || GOTO :Error
+%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\build\makecoq_mingw.sh" || GOTO ErrorExit
ECHO ========== FINISHED ==========
@@ -411,12 +439,13 @@ ECHO ========== BATCH FUNCTIONS ==========
ECHO -proxy ^<internet proxy^>
ECHO -cygrepo ^<cygwin download repository^>
ECHO -cygcache ^<local cygwin repository/cache^>
- ECHO -cyglocal ^<Y or N^> install cygwin from cache
+ ECHO -cyglocal ^<Y or N^> install cygwin from cache
ECHO -cygquiet ^<Y or N^> install cygwin without user interaction
ECHO -srccache ^<local source code repository/cache^>
- ECHO -coqver ^<Coq version to install^>
+ ECHO -coqver ^<Coq version to install^>
ECHO -gtksrc ^<Y or N^> build GTK ^(90 min^) or use cygwin version
ECHO -threads ^<1..N^> Number of make threads
+ ECHO -addon ^<name^> Enable building selected addon (can be repeated)
ECHO(
ECHO See ReadMe.txt for a detailed description of all parameters
ECHO(
@@ -426,9 +455,9 @@ ECHO ========== BATCH FUNCTIONS ==========
ECHO -ocaml = %INSTALLOCAML%
ECHO -installer= %MAKEINSTALLER%
ECHO -make = %INSTALLMAKE%
- ECHO -destcyg = %DESTCYG%
- ECHO -destcoq = %DESTCOQ%
- ECHO -setup = %SETUP%
+ ECHO -destcyg = %DESTCYG%
+ ECHO -destcoq = %DESTCOQ%
+ ECHO -setup = %SETUP%
ECHO -proxy = %PROXY%
ECHO -cygrepo = %CYGWIN_REPOSITORY%
ECHO -cygcache = %CYGWIN_LOCAL_CACHE_WFMT%
@@ -438,8 +467,22 @@ ECHO ========== BATCH FUNCTIONS ==========
ECHO -coqver = %COQ_VERSION%
ECHO -gtksrc = %GTK_FROM_SOURCES%
ECHO -threads = %MAKE_THREADS%
+ ECHO -addon = %COQ_ADDONS%
+ GOTO :EOF
+
+:CheckYN
+ REM Reset errorlevel to 0
+ CMD /c "EXIT /b 0"
+ IF "%2" == "Y" (
+ REM OK Y
+ ) ELSE IF "%2" == "N" (
+ REM OK N
+ ) ELSE (
+ ECHO ERROR Parameter %1 must be Y or N, but is %2
+ GOTO ErrorExit
+ )
GOTO :EOF
-:Error
-ECHO Building Coq failed with error code %errorlevel%
-EXIT /b %errorlevel%
+:ErrorExit
+ ECHO ERROR MakeCoq_MinGW.bat failed
+ EXIT /b 1
diff --git a/dev/build/windows/MakeCoq_SetRootPath.bat b/dev/build/windows/MakeCoq_SetRootPath.bat
index 3a371172..bcb10477 100644
--- a/dev/build/windows/MakeCoq_SetRootPath.bat
+++ b/dev/build/windows/MakeCoq_SetRootPath.bat
@@ -1,3 +1,14 @@
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== CHOOSE A SENSIBLE ROOT PATH ==========
+
@ ECHO OFF
REM Figure out a root path for coq and cygwin
diff --git a/dev/build/windows/MakeCoq_explicitcachefolders_installer.bat b/dev/build/windows/MakeCoq_explicitcachefolders_installer.bat
new file mode 100755
index 00000000..d7d3c5b9
--- /dev/null
+++ b/dev/build/windows/MakeCoq_explicitcachefolders_installer.bat
@@ -0,0 +1,28 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
+call MakeCoq_SetRootPath
+
+call MakeCoq_MinGW.bat ^
+ -arch=64 ^
+ -installer=Y ^
+ -coqver=git-v8.6 ^
+ -destcyg="%ROOTPATH%\cygwin_coq64_cachefolder_inst" ^
+ -destcoq="%ROOTPATH%\coq64_cachefolder_inst" ^
+ -cygcache="%ROOTPATH%\cache\cygwin" ^
+ -srccache="%ROOTPATH%\cache\source"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_explicitcachefolders_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_local_installer.bat b/dev/build/windows/MakeCoq_local_installer.bat
new file mode 100755
index 00000000..752b73c1
--- /dev/null
+++ b/dev/build/windows/MakeCoq_local_installer.bat
@@ -0,0 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
+call MakeCoq_SetRootPath
+
+call MakeCoq_MinGW.bat ^
+ -arch=64 ^
+ -installer=Y ^
+ -coqver=/cygdrive/d/coqgit/coq-8.6 ^
+ -destcyg="%ROOTPATH%\cygwin_coq64_local_inst" ^
+ -destcoq="%ROOTPATH%\coq64_local_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_local_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/MakeCoq_regtest_noproxy.bat b/dev/build/windows/MakeCoq_regtest_noproxy.bat
index 2b0b83fe..7140a7c6 100644
--- a/dev/build/windows/MakeCoq_regtest_noproxy.bat
+++ b/dev/build/windows/MakeCoq_regtest_noproxy.bat
@@ -1,7 +1,18 @@
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
call MakeCoq_SetRootPath
SET HTTP_PROXY=
-EXPORT HTTP_PROXY=
+SET HTTPS_PROXY=
MKDIR C:\Temp\srccache
call MakeCoq_MinGW.bat ^
@@ -14,5 +25,5 @@ call MakeCoq_MinGW.bat ^
-cygquiet=Y ^
-destcyg %ROOTPATH%\cygwin_coq64_85pl2_abs ^
-destcoq %ROOTPATH%\coq64_85pl2_abs
-
-pause \ No newline at end of file
+
+pause
diff --git a/dev/build/windows/MakeCoq_regtests.bat b/dev/build/windows/MakeCoq_regtests.bat
index 6e36d014..74c26456 100644
--- a/dev/build/windows/MakeCoq_regtests.bat
+++ b/dev/build/windows/MakeCoq_regtests.bat
@@ -1,16 +1,36 @@
-SET COQREGTESTING=Y
+REM ========== COPYRIGHT/COPYLEFT ==========
-REM Bleeding edge
-call MakeCoq_86git_abs_ocaml.bat
-call MakeCoq_86git_installer.bat
-call MakeCoq_86git_installer_32.bat
-call MakeCoq_86git_abs_ocaml_gtksrc.bat
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== RUN REGRESSION TESTS FOR COQ BUILD SCRIPTS ==========
+
+SET COQREGTESTING=Y
REM Current stable
-call MakeCoq_85pl3_abs_ocaml.bat
-call MakeCoq_85pl3_installer.bat
-call MakeCoq_85pl3_installer_32.bat
+call MakeCoq_86git_abs_ocaml.bat || GOTO Error
+call MakeCoq_86git_installer.bat || GOTO Error
+call MakeCoq_86git_installer_32.bat || GOTO Error
REM Old but might still be used
-call MakeCoq_85pl2_abs_ocaml.bat
-call MakeCoq_84pl6_abs_ocaml.bat
+call MakeCoq_85pl3_abs_ocaml.bat || GOTO Error
+call MakeCoq_84pl6_abs_ocaml.bat || GOTO Error
+
+REM Special variants, e.g. for debugging
+call MakeCoq_86git_abs_ocaml_gtksrc.bat || GOTO Error
+call MakeCoq_local_installer.bat || GOTO Error
+call MakeCoq_explicitcachefolders_installer.bat || GOTO Error
+
+REM Bleeding edge
+call MakeCoq_trunk_installer.bat || GOTO Error
+
+ECHO MakeCoq_regtests.bat: All tests finished successfully
+GOTO :EOF
+
+:Error
+ECHO MakeCoq_regtests.bat failed with error code %ERRORLEVEL%
+EXIT /b %ERRORLEVEL%
diff --git a/dev/build/windows/MakeCoq_trunk_installer.bat b/dev/build/windows/MakeCoq_trunk_installer.bat
new file mode 100755
index 00000000..f4f58273
--- /dev/null
+++ b/dev/build/windows/MakeCoq_trunk_installer.bat
@@ -0,0 +1,26 @@
+@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== BUILD COQ ==========
+
+call MakeCoq_SetRootPath
+
+call MakeCoq_MinGW.bat ^
+ -arch=64 ^
+ -installer=Y ^
+ -coqver=git-trunk ^
+ -destcyg="%ROOTPATH%\cygwin_coq64_trunk_inst" ^
+ -destcoq="%ROOTPATH%\coq64_trunk_inst"
+
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO MakeCoq_86git_installer.bat failed with error code %ERRORLEVEL%
+ EXIT /b %ERRORLEVEL%
+)
diff --git a/dev/build/windows/ReadMe.txt b/dev/build/windows/ReadMe.txt
index 0faf5bc5..93851aeb 100644
--- a/dev/build/windows/ReadMe.txt
+++ b/dev/build/windows/ReadMe.txt
@@ -1,3 +1,12 @@
+(C) 2016 Intel Deutschland GmbH
+Author: Michael Soegtrop
+
+Released to the public by Intel under the
+GNU Lesser General Public License Version 2.1 or later
+See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+This license also applies to all files in the patches_coq subfolder.
+
==================== Purpose / Goal ====================
The main purpose of these scripts is to build Coq for Windows in a reproducible
@@ -52,6 +61,7 @@ The Script MakeCoq_MinGW does:
- either installs MinGW GTK via Cygwin or compiles it fom sources
- download, compile and install OCaml, CamlP5, Menhir, lablgtk
- download, compile and install Coq
+- download, compile and install selected addons
- create a Windows installer (NSIS based)
The parameters are described below. Mostly paths and the HTTP proxy need to be
@@ -286,9 +296,16 @@ Default value: <folder of MakeCoq_MinGW.bat>\source_cache
The version of Coq to download and compile.
-Possible values: 8.4pl6, 8.5pl2, 8.5pl3, git-v8.6
- Others might work, but are untested.
+Possible values: 8.4pl6, 8.5pl2, 8.5pl3, 8.6
+ (download from https://coq.inria.fr/distrib/V$COQ_VERSION/files/coq-<version>.tar.gz)
+ Others versions might work, but are untested.
8.4 is only tested in mode=absoloute
+
+ git-v8.6, git-trunk
+ (download from https://github.com/coq/coq/archive/<version without git->.zip)
+
+ /cygdrive/....
+ Use local folder. The sources are archived as coq-local.tar.gz
Default value: 8.5pl3
@@ -319,9 +336,15 @@ Possible values: 1..N.
Should not be more than 1.5x the number of cores.
Should not be more than available RAM/2GB (e.g. 4 for 8GB)
+===== -addon =====
+
+Enable build and installation of selected Coq package (can be repeated for
+selecting more packages)
==================== TODO ====================
+- Check for spaces in destination paths
+- Check for = signs in all paths (DOS commands don't work with pathes with = in it, possibly even when quoted)
- Installer doesn't remove OCAMLLIB environment variables (it is in the script, but doesn't seem to work)
- CoqIDE doesn't find theme files
- Finish / test mingw_in_Cygwin mode (coqide doesn't start, coqc slow cause of scanning complete share folder)
@@ -400,7 +423,6 @@ Binary file ./bin/coqchk.exe matches
Binary file ./bin/coqdep.exe matches
Binary file ./bin/coqdoc.exe matches
Binary file ./bin/coqide.exe matches
-Binary file ./bin/coqmktop.exe matches
Binary file ./bin/coqtop.byte.exe matches
Binary file ./bin/coqtop.exe matches
Binary file ./bin/coqworkmgr.exe matches
@@ -420,7 +442,6 @@ Binary file ./bin/ocamldoc.exe matches
Binary file ./bin/ocamldoc.opt.exe matches
Binary file ./bin/ocamlfind.exe matches
Binary file ./bin/ocamlmklib.exe matches
-Binary file ./bin/ocamlmktop.exe matches
Binary file ./bin/ocamlobjinfo.exe matches
Binary file ./bin/ocamlopt.exe matches
Binary file ./bin/ocamlopt.opt.exe matches
diff --git a/dev/build/windows/configure_profile.sh b/dev/build/windows/configure_profile.sh
index 09a9cf35..16c972e8 100644
--- a/dev/build/windows/configure_profile.sh
+++ b/dev/build/windows/configure_profile.sh
@@ -1,5 +1,16 @@
#!/bin/bash
+###################### COPYRIGHT/COPYLEFT ######################
+
+# (C) 2016 Intel Deutschland GmbH
+# Author: Michael Soegtrop
+#
+# Released to the public by Intel under the
+# GNU Lesser General Public License Version 2.1 or later
+# See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+###################### CONFIGURE CYGWIN USER PROFILE FOR BUILDING COQ ######################
+
rcfile=~/.bash_profile
donefile=~/.bash_profile.upated
@@ -7,7 +18,7 @@ if [ ! -f $donefile ] ; then
echo >> $rcfile
- if [ -n "$1" ]; then
+ if [ "$1" != "" -a "$1" != " " ]; then
echo export http_proxy="http://$1" >> $rcfile
echo export https_proxy="http://$1" >> $rcfile
echo export ftp_proxy="http://$1" >> $rcfile
@@ -29,4 +40,4 @@ if [ ! -f $donefile ] ; then
echo unset OCAMLLIB >> $rcfile
touch $donefile
-fi \ No newline at end of file
+fi
diff --git a/dev/build/windows/difftar-folder.sh b/dev/build/windows/difftar-folder.sh
index 65278d5c..cbcf14ec 100644
--- a/dev/build/windows/difftar-folder.sh
+++ b/dev/build/windows/difftar-folder.sh
@@ -8,35 +8,28 @@
# Released to the public by Intel under the
# GNU Lesser General Public License Version 2.1 or later
# See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
-#
-# With very valuable help on building GTK from
-# https://wiki.gnome.org/Projects/GTK+/Win32/MSVCCompilationOfGTKStack
-# http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html
-###################### Script safety and debugging settings ######################
+###################### DIFF A TAR FILE AND A FOLDER ######################
set -o nounset
# Print usage
-if [ "$#" -lt 1 ] ; then
+if [ "$#" -lt 2 ] ; then
echo 'Diff a tar (or compressed tar) file with a folder'
- echo 'difftar-folder.sh <tarfile> [<folder>] [strip]'
- echo default for folder is .
- echo default for strip is 0.
- echo 'strip must be 0 or 1.'
+ echo 'difftar-folder.sh <tarfile> <folder> [strip]'
+ echo '<tarfile> is the name of the tar file do diff with (required)'
+ echo '<folder> is the name of the folder to diff with (required)'
+ echo '<strip> is the number of path components to strip from tar file (default is 0)'
+ echo 'All files in the tar file must have at least <strip> path components.'
+ echo 'This also adds new files from folder.new, if folder.new exists'
exit 1
fi
# Parse parameters
tarfile=$1
-
-if [ "$#" -ge 2 ] ; then
- folder=$2
-else
- folder=.
-fi
+folder=$2
if [ "$#" -ge 3 ] ; then
strip=$3
@@ -47,27 +40,33 @@ fi
# Get path prefix if --strip is used
if [ "$strip" -gt 0 ] ; then
- prefix=`tar -t -f $tarfile | head -1`
+ # Get the path/name of the first file from teh tar and extract the first $strip path components
+ # This assumes that the first file in the tar file has at least $strip many path components
+ prefix=$(tar -t -f $tarfile | head -1 | cut -d / -f -$strip)/
else
prefix=
fi
# Original folder
-if [ "$strip" -gt 0 ] ; then
- orig=${prefix%/}.orig
-elif [ "$folder" = "." ] ; then
- orig=${tarfile##*/}
- orig=./${orig%%.tar*}.orig
-elif [ "$folder" = "" ] ; then
- orig=${tarfile##*/}
- orig=${orig%%.tar*}.orig
-else
- orig=$folder.orig
-fi
-echo $orig
+orig=$folder.orig
mkdir -p "$orig"
+# New amd empty filefolder
+
+new=$folder.new
+empty=$folder.empty
+mkdir -p "$empty"
+
+# Print information (this is ignored by patch)
+
+echo diff/patch file created on $(date) with:
+echo difftar-folder.sh $@
+echo TARFILE= $tarfile
+echo FOLDER= $folder
+echo TARSTRIP= $strip
+echo TARPREFIX= $prefix
+echo ORIGFOLDER= $orig
# Make sure tar uses english output (for Mod time differs)
export LC_ALL=C
@@ -83,4 +82,8 @@ tar --diff -a -f "$tarfile" --strip $strip --directory "$folder" | grep "Mod tim
# Compute diff
diff -u "$orig/$file" "$folder/$file"
fi
-done \ No newline at end of file
+done
+
+if [ -d "$new" ] ; then
+ diff -u -r --unidirectional-new-file $empty $new
+fi
diff --git a/dev/build/windows/makecoq_mingw.sh b/dev/build/windows/makecoq_mingw.sh
index 52b15887..86cc5f2d 100644..100755
--- a/dev/build/windows/makecoq_mingw.sh
+++ b/dev/build/windows/makecoq_mingw.sh
@@ -2,7 +2,7 @@
###################### COPYRIGHT/COPYLEFT ######################
-# (C) 2016 Intel Deutschland GmbH
+# (C) 2016..2018 Intel Deutschland GmbH
# Author: Michael Soegtrop
#
# Released to the public by Intel under the
@@ -18,6 +18,8 @@
set -o nounset
set -o errexit
set -x
+# Print current wall time as part of the xtrace
+export PS4='+\t '
# Set this to 1 if all module directories shall be removed before build (no incremental make)
RMDIR_BEFORE_BUILD=1
@@ -67,7 +69,7 @@ RMDIR_BEFORE_BUILD=1
###################### ARCHITECTURES #####################
# The OS on which the build of the tool/lib runs
-BUILD=`gcc -dumpmachine`
+BUILD=$(gcc -dumpmachine)
# The OS on which the tool runs
# "`find /bin -name "*mingw32-gcc.exe"`" -dumpmachine
@@ -98,6 +100,8 @@ mkdir -p $TARBALLS
mkdir -p $FILELISTS
cd /build
+# Create source cache folder
+mkdir -p "$SOURCE_LOCAL_CACHE_CFMT"
# sysroot prefix for the above /build/host/target combination
PREFIX=$CYGWIN_INSTALLDIR_MFMT/usr/$TARGET_ARCH/sys-root/mingw
@@ -112,9 +116,16 @@ else
PREFIXOCAML=$PREFIX
fi
-mkdir -p $PREFIX/bin
-mkdir -p $PREFIXCOQ/bin
-mkdir -p $PREFIXOCAML/bin
+mkdir -p "$PREFIX/bin"
+mkdir -p "$PREFIXCOQ/bin"
+mkdir -p "$PREFIXOCAML/bin"
+
+# This is required for building addons and plugins
+# This must be CFMT (/cygdrive/c/...) otherwise coquelicot 3.0.2 configure fails.
+# coquelicot uses which ${COQBIN}/coqc to check if coqc exists. This does not work with COQBIN in MFMT.
+export COQBIN=$RESULT_INSTALLDIR_CFMT/bin/
+# This must be MFMT (C:/) otherwise bignums 68a7a3d7e0b21985913a6c3ee12067f4c5ac4e20 fails
+export COQLIB=$RESULT_INSTALLDIR_MFMT/lib/coq/
###################### Copy Cygwin Setup Info #####################
@@ -128,36 +139,92 @@ CYGWIN_REPO_FOLDER=${CYGWIN_REPO_FOLDER//:/%3a}
CYGWIN_REPO_FOLDER=${CYGWIN_REPO_FOLDER//\//%2f}
# Copy files
-cp $CYGWIN_LOCAL_CACHE_WFMT/$CYGWIN_REPO_FOLDER/$CYGWINARCH/setup.ini $TARBALLS
+cp "$CYGWIN_LOCAL_CACHE_WFMT/$CYGWIN_REPO_FOLDER/$CYGWINARCH/setup.ini" $TARBALLS
cp /etc/setup/installed.db $TARBALLS
-
+
###################### LOGGING #####################
# The folder which receives log files
mkdir -p buildlogs
-LOGS=`pwd`/buildlogs
+LOGS=$(pwd)/buildlogs
# The current log target (first part of the log file name)
LOGTARGET=other
-log1() {
- "$@" > $LOGS/$LOGTARGET-$1.log 2> $LOGS/$LOGTARGET-$1.err
-}
+# For an explanation of ${COQREGTESTING:-N} search for ${parameter:-word} in
+# http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
+
+if [ "${COQREGTESTING:-N}" == "Y" ] ; then
+ # If COQREGTESTING, log to log files only
+ # Log command output - take log target name from command name (like log1 make => log target is "<module>-make")
+ log1() {
+ { local -; set +x; } 2> /dev/null
+ "$@" >"$LOGS/$LOGTARGET-$1.log" 2>"$LOGS/$LOGTARGET-$1.err"
+ }
+
+ # Log command output - take log target name from command name and first argument (like log2 make install => log target is "<module>-make-install")
+ log2() {
+ { local -; set +x; } 2> /dev/null
+ "$@" >"$LOGS/$LOGTARGET-$1-$2.log" 2>"$LOGS/$LOGTARGET-$1-$2.err"
+ }
+
+ # Log command output - take log target name from command name and second argument (like log_1_3 ocaml setup.ml -configure => log target is "<module>-ocaml--configure")
+ log_1_3() {
+ { local -; set +x; } 2> /dev/null
+ "$@" >"$LOGS/$LOGTARGET-$1-$3.log" 2>"$LOGS/$LOGTARGET-$1-$3.err"
+ }
+
+ # Log command output - log target name is first argument (like logn untar tar xvaf ... => log target is "<module>-untar")
+ logn() {
+ { local -; set +x; } 2> /dev/null
+ LOGTARGETEX=$1
+ shift
+ "$@" >"$LOGS/$LOGTARGET-$LOGTARGETEX.log" 2>"$LOGS/$LOGTARGET-$LOGTARGETEX.err"
+ }
+else
+ # If COQREGTESTING, log to log files and console
+ # Log command output - take log target name from command name (like log1 make => log target is "<module>-make")
+ log1() {
+ { local -; set +x; } 2> /dev/null
+ "$@" > >(tee "$LOGS/$LOGTARGET-$1.log" | sed -e "s/^/$LOGTARGET-$1.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1.err" | sed -e "s/^/$LOGTARGET-$1.err: /" 1>&2)
+ }
+
+ # Log command output - take log target name from command name and first argument (like log2 make install => log target is "<module>-make-install")
+ log2() {
+ { local -; set +x; } 2> /dev/null
+ "$@" > >(tee "$LOGS/$LOGTARGET-$1-$2.log" | sed -e "s/^/$LOGTARGET-$1-$2.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$2.err" | sed -e "s/^/$LOGTARGET-$1-$2.err: /" 1>&2)
+ }
+
+ # Log command output - take log target name from command name and second argument (like log_1_3 ocaml setup.ml -configure => log target is "<module>-ocaml--configure")
+ log_1_3() {
+ { local -; set +x; } 2> /dev/null
+ "$@" > >(tee "$LOGS/$LOGTARGET-$1-$3.log" | sed -e "s/^/$LOGTARGET-$1-$3.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$3.err" | sed -e "s/^/$LOGTARGET-$1-$3.err: /" 1>&2)
+ }
+
+ # Log command output - log target name is first argument (like logn untar tar xvaf ... => log target is "<module>-untar")
+ logn() {
+ { local -; set +x; } 2> /dev/null
+ LOGTARGETEX=$1
+ shift
+ "$@" > >(tee "$LOGS/$LOGTARGET-$LOGTARGETEX.log" | sed -e "s/^/$LOGTARGET-$LOGTARGETEX.log: /") 2> >(tee "$LOGS/$LOGTARGET-$LOGTARGETEX.err" | sed -e "s/^/$LOGTARGET-$LOGTARGETEX.err: /" 1>&2)
+ }
+fi
-log2() {
- "$@" > $LOGS/$LOGTARGET-$1-$2.log 2> $LOGS/$LOGTARGET-$1-$2.err
-}
+###################### 'UNFIX' SED #####################
-log_1_3() {
- "$@" > $LOGS/$LOGTARGET-$1-$3.log 2> $LOGS/$LOGTARGET-$1-$3.err
-}
+# In Cygwin SED used to do CR-LF to LF conversion, but since sed 4.4-1 this was changed
+# We replace sed with a shell script which restores the old behavior for piped input
+
+#if [ -f /bin/sed.exe ]
+#then
+# mv /bin/sed.exe /bin/sed_orig.exe
+#fi
+#cat > /bin/sed << EOF
+##!/bin/sh
+#dos2unix | /bin/sed_orig.exe "$@"
+#EOF
+#chmod a+x /bin/sed
-logn() {
- LOGTARGETEX=$1
- shift
- "$@" > $LOGS/$LOGTARGET-$LOGTARGETEX.log 2> $LOGS/$LOGTARGET-$LOGTARGETEX.err
-}
-
###################### UTILITY FUNCTIONS #####################
# ------------------------------------------------------------------------------
@@ -166,7 +233,7 @@ logn() {
# - create build folder
# - extract source archive
# - patch source file if patch exists
-#
+#
# Parameters
# $1 file server name including protocol prefix
# $2 file name (without extension)
@@ -189,62 +256,68 @@ function get_expand_source_tar {
else
name=$2
fi
-
+
if [ "$#" -ge 6 ] ; then
folder=$6
else
folder=$name
fi
-
+
# Set logging target
logtargetold=$LOGTARGET
LOGTARGET=$name
-
+
# Get the source archive either from the source cache or online
- if [ ! -f $TARBALLS/$name.$3 ] ; then
- if [ -f $SOURCE_LOCAL_CACHE_CFMT/$name.$3 ] ; then
- cp $SOURCE_LOCAL_CACHE_CFMT/$name.$3 $TARBALLS
+ if [ ! -f "$TARBALLS/$name.$3" ] ; then
+ if [ -f "$SOURCE_LOCAL_CACHE_CFMT/$name.$3" ] ; then
+ cp "$SOURCE_LOCAL_CACHE_CFMT/$name.$3" "$TARBALLS"
else
- wget $1/$2.$3
+ wget --progress=dot:giga "$1/$2.$3"
+ if file -i "$2.$3" | grep text/html; then
+ echo Download failed: "$1/$2.$3"
+ echo The file wget downloaded is an html file:
+ cat "$2.$3"
+ exit 1
+ fi
if [ ! "$2.$3" == "$name.$3" ] ; then
- mv $2.$3 $name.$3
+ mv "$2.$3" "$name.$3"
fi
- mv $name.$3 $TARBALLS
+ mv "$name.$3" "$TARBALLS"
# Save the source archive in the source cache
- if [ -d $SOURCE_LOCAL_CACHE_CFMT ] ; then
- cp $TARBALLS/$name.$3 $SOURCE_LOCAL_CACHE_CFMT
+ if [ -d "$SOURCE_LOCAL_CACHE_CFMT" ] ; then
+ cp "$TARBALLS/$name.$3" "$SOURCE_LOCAL_CACHE_CFMT"
fi
fi
fi
-
+
# Remove build directory (clean build)
if [ $RMDIR_BEFORE_BUILD -eq 1 ] ; then
- rm -f -r $folder
+ rm -f -r "$folder"
fi
-
+
# Create build directory and cd
- mkdir -p $folder
- cd $folder
-
+ mkdir -p "$folder"
+ cd "$folder"
+
# Extract source archive
if [ "$3" == "zip" ] ; then
- log1 unzip $TARBALLS/$name.$3
+ log1 unzip "$TARBALLS/$name.$3"
if [ "$strip" == "1" ] ; then
- # Ok, this is dirty, but it works and it fails if there are name clashes
- mv */* .
+ # move subfolders of root folders one level up
+ find "$(ls)" -mindepth 1 -maxdepth 1 -exec mv -- "{}" . \;
else
echo "Unzip strip count not supported"
return 1
fi
else
- logn untar tar xvaf $TARBALLS/$name.$3 --strip $strip
+ logn untar tar xvaf "$TARBALLS/$name.$3" --strip $strip
fi
-
+
# Patch if patch file exists
- if [ -f $PATCHES/$name.patch ] ; then
- log1 patch -p1 -i $PATCHES/$name.patch
+ if [ -f "$PATCHES/$name.patch" ] ; then
+ log1 patch -p1 -i "$PATCHES/$name.patch"
fi
-
+
# Go back to base folder
cd ..
@@ -260,7 +333,7 @@ function get_expand_source_tar {
# - cd to build folder and extract source archive
# - create bin_special subfolder and add it to $PATH
# - remember things for build_post
-#
+#
# Parameters
# $1 file server name including protocol prefix
# $2 file name (without extension)
@@ -282,43 +355,102 @@ function build_prep {
else
name=$2
fi
-
+
+ # Set installer section to not set by default
+ installersection=
+
# Check if build is already done
- if [ ! -f flagfiles/$name.finished ] ; then
+ if [ ! -f "$FLAGFILES/$name.finished" ] ; then
BUILD_PACKAGE_NAME=$name
BUILD_OLDPATH=$PATH
- BUILD_OLDPWD=`pwd`
+ BUILD_OLDPWD=$(pwd)
LOGTARGET=$name
- touch flagfiles/$name.started
-
- get_expand_source_tar $1 $2 $3 $strip $name
-
- cd $name
-
+ touch "$FLAGFILES/$name.started"
+
+ get_expand_source_tar "$1" "$2" "$3" "$strip" "$name"
+
+ cd "$name"
+
# Create a folder and add it to path, where we can put special binaries
# The path is restored in build_post
mkdir bin_special
- PATH=`pwd`/bin_special:$PATH
-
+ PATH=$(pwd)/bin_special:$PATH
+
return 0
- else
+ else
return 1
fi
}
# ------------------------------------------------------------------------------
+# Like build_prep, but gets the data from an entry in ci-basic-overlay.sh
+# This assumes the following definitions exist in ci-basic-overlay.sh,
+# or in a file in the user-overlays folder:
+# $1_CI_REF
+# $1_CI_ARCHIVEURL
+# $1_CI_GITURL
+# ATTENTION: variables in ci-basic-overlay.sh are loaded by load_overlay_data.
+# load_overlay_data is is called at the end of make_coq (even if the build is skipped)
+#
+# Parameters
+# $1 base name of module in ci-basic-overlay.sh, e.g. mathcomp, bignums, ...
+# ------------------------------------------------------------------------------
+
+function build_prep_overlay {
+ urlvar=$1_CI_ARCHIVEURL
+ gitvar=$1_CI_GITURL
+ refvar=$1_CI_REF
+ url=${!urlvar}
+ git=${!gitvar}
+ ref=${!refvar}
+ ver=$(git ls-remote "$git" "refs/heads/$ref" | cut -f 1)
+ if [[ "$ver" == "" ]]; then
+ # $1_CI_REF must have been a tag or hash, not a branch
+ ver="$ref"
+ fi
+ build_prep "$url" "$ver" tar.gz 1 "$1-$ver"
+}
+
+# ------------------------------------------------------------------------------
+# Load overlay version variables from ci-basic-overlay.sh and user-overlays/*.sh
+# ------------------------------------------------------------------------------
+
+function load_overlay_data {
+ if [ -n "${GITLAB_CI+}" ]; then
+ export CI_BRANCH="$CI_COMMIT_REF_NAME"
+ if [[ ${CI_BRANCH#pr-} =~ ^[0-9]*$ ]]; then
+ export CI_PULL_REQUEST="${CI_BRANCH#pr-}"
+ else
+ export CI_PULL_REQUEST=""
+ fi
+ else
+ export CI_BRANCH=""
+ export CI_PULL_REQUEST=""
+ # Used when building 8.8.0 with the latest scripts
+ export TRAVIS_BRANCH=""
+ export TRAVIS_PULL_REQUEST=""
+ fi
+
+ for overlay in /build/user-overlays/*.sh; do
+ . "$overlay"
+ done
+ . /build/ci-basic-overlay.sh
+}
+
+# ------------------------------------------------------------------------------
# Finalize a module build
# - create name.finished
# - go back to base folder
# ------------------------------------------------------------------------------
function build_post {
- if [ ! -f flagfiles/$BUILD_PACKAGE_NAME.finished ]; then
- cd $BUILD_OLDPWD
- touch flagfiles/$BUILD_PACKAGE_NAME.finished
+ if [ ! -f "$FLAGFILES/$BUILD_PACKAGE_NAME.finished" ]; then
+ cd "$BUILD_OLDPWD"
+ touch "$FLAGFILES/$BUILD_PACKAGE_NAME.finished"
PATH=$BUILD_OLDPATH
LOGTARGET=other
+ installer_addon_end
fi
}
@@ -339,9 +471,10 @@ function build_post {
# ------------------------------------------------------------------------------
function build_conf_make_inst {
- if build_prep $1 $2 $3 ; then
+ if build_prep "$1" "$2" "$3" ; then
$4
- logn configure ./configure --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIX "${@:5}"
+ logn configure ./configure --build="$BUILD" --host="$HOST" --target="$TARGET" --prefix="$PREFIX" "${@:5}"
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT
log2 make install
log2 make clean
@@ -353,18 +486,17 @@ function build_conf_make_inst {
# Install all files given by a glob pattern to a given folder
#
# parameters
-# $1 glob pattern (in '')
-# $2 target folder
+# $1 source path
+# $2 pattern (in '')
+# $3 target folder
# ------------------------------------------------------------------------------
function install_glob {
- # Check if any files matching the pattern exist
- if [ "$(echo $1)" != "$1" ] ; then
- install -D -t $2 $1
- fi
+ SRCDIR=$(realpath -m $1)
+ DESTDIR=$(realpath -m $3)
+ ( cd "$SRCDIR" && find . -maxdepth 1 -type f -name "$2" -exec install -D -T "$SRCDIR"/{} "$DESTDIR"/{} \; )
}
-
# ------------------------------------------------------------------------------
# Recursively Install all files given by a glob pattern to a given folder
#
@@ -375,12 +507,15 @@ function install_glob {
# ------------------------------------------------------------------------------
function install_rec {
- ( cd $1 && find -type f -name "$2" -exec install -D -T $1/{} $3/{} \; )
+ SRCDIR=$(realpath -m $1)
+ DESTDIR=$(realpath -m $3)
+ ( cd "$SRCDIR" && find . -type f -name "$2" -exec install -D -T "$SRCDIR"/{} "$DESTDIR"/{} \; )
}
# ------------------------------------------------------------------------------
# Write a file list of the target folder
# The file lists are used to create file lists for the windows installer
+# Don't overwrite an existing file list
#
# parameters
# $1 name of file list
@@ -388,11 +523,24 @@ function install_rec {
function list_files {
if [ ! -e "/build/filelists/$1" ] ; then
- ( cd $PREFIXCOQ && find -type f | sort > /build/filelists/$1 )
+ ( cd "$PREFIXCOQ" && find . -type f | sort > /build/filelists/"$1" )
fi
}
# ------------------------------------------------------------------------------
+# Write a file list of the target folder
+# The file lists are used to create file lists for the windows installer
+# Do overwrite an existing file list
+#
+# parameters
+# $1 name of file list
+# ------------------------------------------------------------------------------
+
+function list_files_always {
+ ( cd "$PREFIXCOQ" && find . -type f | sort > /build/filelists/"$1" )
+}
+
+# ------------------------------------------------------------------------------
# Compute the set difference of two file lists
#
# parameters
@@ -416,7 +564,7 @@ function diff_files {
# ------------------------------------------------------------------------------
function filter_files {
- egrep "$3" "/build/filelists/$2" > "/build/filelists/$1"
+ grep -E "$3" "/build/filelists/$2" > "/build/filelists/$1"
}
# ------------------------------------------------------------------------------
@@ -430,28 +578,124 @@ function files_to_nsis {
# Split the path in the file list into path and filename and create SetOutPath and File instructions
# Note: File /oname cannot be used, because it does not create the paths as SetOutPath does
# Note: I didn't check if the redundant SetOutPath instructions have a bad impact on installer size or install time
- cat "/build/filelists/$1" | tr '/' '\\' | sed -r 's/^\.(.*)\\([^\\]+)$/SetOutPath $INSTDIR\\\1\nFile ${COQ_SRC_PATH}\\\1\\\2/' > "/build/filelists/$1.nsh"
+ tr '/' '\\' < "/build/filelists/$1" | sed -r 's/^\.(.*)\\([^\\]+)$/SetOutPath $INSTDIR\\\1\nFile ${COQ_SRC_PATH}\\\1\\\2/' > "/build/filelists/$1.nsh"
}
+# ------------------------------------------------------------------------------
+# Create an nsis installer addon section
+#
+# parameters
+# $1 identifier of installer section and base name of file list files
+# $2 human readable name of section
+# $3 description of section
+# $4 flags (space separated list of keywords): off = default off
+#
+# $1 must be a valid NSIS identifier!
+# ------------------------------------------------------------------------------
+
+function installer_addon_section {
+ installersection=$1
+ list_files "addon_pre_$installersection"
+
+ echo 'LangString' "DESC_$1" '${LANG_ENGLISH}' "\"$3\"" >> "/build/filelists/addon_strings.nsh"
+
+ echo '!insertmacro MUI_DESCRIPTION_TEXT' '${'"Sec_$1"'}' '$('"DESC_$1"')' >> "/build/filelists/addon_descriptions.nsh"
+
+ local sectionoptions=
+ if [[ "$4" == *off* ]] ; then sectionoptions+=" /o" ; fi
+
+ echo "Section $sectionoptions \"$2\" Sec_$1" >> "/build/filelists/addon_sections.nsh"
+ echo 'SetOutPath "$INSTDIR\"' >> "/build/filelists/addon_sections.nsh"
+ echo '!include "..\..\..\filelists\addon_'"$1"'.nsh"' >> "/build/filelists/addon_sections.nsh"
+ echo 'SectionEnd' >> "/build/filelists/addon_sections.nsh"
+}
+
+# ------------------------------------------------------------------------------
+# Start an installer addon dependency group
+#
+# parameters
+# $1 identifier of the section which depends on other sections
+# The parameters must match the $1 parameter of a installer_addon_section call
+# ------------------------------------------------------------------------------
+
+dependencysections=
+
+function installer_addon_dependency_beg {
+ installer_addon_dependency "$1"
+ dependencysections="$1 $dependencysections"
+}
+
+# ------------------------------------------------------------------------------
+# End an installer addon dependency group
+# ------------------------------------------------------------------------------
+
+function installer_addon_dependency_end {
+ set -- $dependencysections
+ shift
+ dependencysections="$*"
+}
+
+# ------------------------------------------------------------------------------
+# Create an nsis installer addon dependency entry
+# This needs to be bracketed with installer_addon_dependencies_beg/end
+#
+# parameters
+# $1 identifier of the section on which other sections might depend
+# The parameters must match the $1 parameter of a installer_addon_section call
+# ------------------------------------------------------------------------------
+
+function installer_addon_dependency {
+ for section in $dependencysections ; do
+ echo '${CheckSectionDependency} ${Sec_'"$section"'} ${Sec_'"$1"'} '"'$section' '$1'" >> "/build/filelists/addon_dependencies.nsh"
+ done
+}
+
+# ------------------------------------------------------------------------------
+# Finish an installer section after an addon build
+#
+# This creates the file list files
+#
+# parameters: none
+# ------------------------------------------------------------------------------
+
+function installer_addon_end {
+ if [ -n "$installersection" ]; then
+ list_files "addon_post_$installersection"
+ diff_files "addon_$installersection" "addon_post_$installersection" "addon_pre_$installersection"
+ files_to_nsis "addon_$installersection"
+ fi
+}
###################### MODULE BUILD FUNCTIONS #####################
+##### SED #####
+
+function make_sed {
+ if build_prep https://ftp.gnu.org/gnu/sed/ sed-4.2.2 tar.gz ; then
+ logn configure ./configure
+ log1 make
+ log2 make install
+ log2 make clean
+ build_post
+ fi
+}
+
##### LIBPNG #####
function make_libpng {
- build_conf_make_inst http://prdownloads.sourceforge.net/libpng libpng-1.6.18 tar.gz true
+ build_conf_make_inst http://prdownloads.sourceforge.net/libpng libpng-1.6.34 tar.gz true
}
##### PIXMAN #####
function make_pixman {
- build_conf_make_inst http://cairographics.org/releases pixman-0.32.8 tar.gz true
+ build_conf_make_inst http://cairographics.org/releases pixman-0.34.0 tar.gz true
}
##### FREETYPE #####
function make_freetype {
- build_conf_make_inst http://sourceforge.net/projects/freetype/files/freetype2/2.6.1 freetype-2.6.1 tar.bz2 true
+ build_conf_make_inst http://sourceforge.net/projects/freetype/files/freetype2/2.9.1 freetype-2.9.1 tar.bz2 true
}
##### EXPAT #####
@@ -466,8 +710,8 @@ function make_fontconfig {
make_freetype
make_expat
# CONFIGURE PARAMETERS
- # build/install fails without --disable-docs
- build_conf_make_inst http://www.freedesktop.org/software/fontconfig/release fontconfig-2.11.94 tar.gz true --disable-docs
+ # build/install fails without --disable-docs
+ build_conf_make_inst http://www.freedesktop.org/software/fontconfig/release fontconfig-2.12.93 tar.gz true --disable-docs
}
##### ICONV #####
@@ -497,7 +741,7 @@ function make_ncurses {
#
# CONFIGURE PARAMETERS
# --enable-term-driver --enable-sp-funcs is rewuired for mingw (see README.MinGW)
- # additional changes
+ # additional changes
# ADD --with-pkg-config
# ADD --enable-pc-files
# ADD --without-manpages
@@ -547,8 +791,7 @@ function make_glib {
make_gettext
make_libffi
make_libpcre
- # build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/glib/2.46 glib-2.46.0 tar.xz true
- build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/glib/2.47 glib-2.47.5 tar.xz true
+ build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/glib/2.57 glib-2.57.1 tar.xz true
}
##### ATK #####
@@ -556,7 +799,7 @@ function make_glib {
function make_atk {
make_gettext
make_glib
- build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/atk/2.18 atk-2.18.0 tar.xz true
+ build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/atk/2.29 atk-2.29.1 tar.xz true
}
##### PIXBUF #####
@@ -569,7 +812,7 @@ function make_gdk-pixbuf {
# CONFIGURE PARAMETERS
# --with-included-loaders=yes statically links the image file format handlers
# This avoids "Cannot open pixbuf loader module file '/usr/x86_64-w64-mingw32/sys-root/mingw/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory"
- build_conf_make_inst http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.32 gdk-pixbuf-2.32.1 tar.xz true --with-included-loaders=yes
+ build_conf_make_inst http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.36 gdk-pixbuf-2.36.12 tar.xz true --with-included-loaders=yes
}
##### CAIRO #####
@@ -580,7 +823,7 @@ function make_cairo {
make_glib
make_pixman
make_fontconfig
- build_conf_make_inst http://cairographics.org/releases cairo-1.14.2 tar.xz true
+ build_conf_make_inst http://cairographics.org/releases rcairo-1.15.13 tar.xz true
}
##### PANGO #####
@@ -589,7 +832,7 @@ function make_pango {
make_cairo
make_glib
make_fontconfig
- build_conf_make_inst http://ftp.gnome.org/pub/GNOME/sources/pango/1.38 pango-1.38.0 tar.xz true
+ build_conf_make_inst http://ftp.gnome.org/pub/GNOME/sources/pango/1.42 pango-1.42.1 tar.xz true
}
##### GTK2 #####
@@ -606,7 +849,7 @@ function make_gtk2 {
make_pango
make_gdk-pixbuf
make_cairo
- build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24 gtk+-2.24.28 tar.xz patch_gtk2
+ build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24 gtk+-2.24.32 tar.xz patch_gtk2
fi
}
@@ -619,11 +862,11 @@ function make_gtk3 {
make_gdk-pixbuf
make_cairo
make_libepoxy
- build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/gtk+/3.16 gtk+-3.16.7 tar.xz true
+ build_conf_make_inst http://ftp.gnome.org/pub/gnome/sources/gtk+/3.22 gtk+-3.22.30 tar.xz true
# make all incl. tests and examples runs through fine
- # make install fails with issue with
- #
+ # make install fails with issue with
+ #
# make[5]: Entering directory '/home/soegtrop/GTK/gtk+-3.16.7/demos/gtk-demo'
# test -n "" || ../../gtk/gtk-update-icon-cache --ignore-theme-index --force "/usr/x86_64-w64-mingw32/sys-root/mingw/share/icons/hicolor"
# gtk-update-icon-cache.exe: Failed to open file /usr/x86_64-w64-mingw32/sys-root/mingw/share/icons/hicolor/.icon-theme.cache : No such file or directory
@@ -639,9 +882,10 @@ function make_libxml2 {
# Note: latest release version 2.9.2 fails during configuring lzma, so using 2.9.1
# Note: python binding requires <sys/select.h> which doesn't exist on cygwin
if build_prep https://git.gnome.org/browse/libxml2/snapshot libxml2-2.9.1 tar.xz ; then
- # ./autogen.sh --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIX --disable-shared --without-python
+ # ./autogen.sh --build=$BUILD --host=$HOST --target=$TARGET --prefix="$PREFIX" --disable-shared --without-python
# shared library required by gtksourceview
- ./autogen.sh --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIX --without-python
+ ./autogen.sh --build="$BUILD" --host="$HOST" --target="$TARGET" --prefix="$PREFIX" --without-python
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT all
log2 make install
log2 make clean
@@ -673,13 +917,13 @@ function make_gtk_sourceview2 {
# Install flexdll objects
function install_flexdll {
- cp flexdll.h /usr/$TARGET_ARCH/sys-root/mingw/include
+ cp flexdll.h "/usr/$TARGET_ARCH/sys-root/mingw/include"
if [ "$TARGET_ARCH" == "i686-w64-mingw32" ]; then
- cp flexdll*_mingw.o /usr/$TARGET_ARCH/bin
- cp flexdll*_mingw.o $PREFIXOCAML/bin
+ cp flexdll*_mingw.o "/usr/$TARGET_ARCH/bin"
+ cp flexdll*_mingw.o "$PREFIXOCAML/bin"
elif [ "$TARGET_ARCH" == "x86_64-w64-mingw32" ]; then
- cp flexdll*_mingw64.o /usr/$TARGET_ARCH/bin
- cp flexdll*_mingw64.o $PREFIXOCAML/bin
+ cp flexdll*_mingw64.o "/usr/$TARGET_ARCH/bin"
+ cp flexdll*_mingw64.o "$PREFIXOCAML/bin"
else
echo "Unknown target architecture"
return 1
@@ -689,16 +933,16 @@ function install_flexdll {
# Install flexlink
function install_flexlink {
- cp flexlink.exe /usr/$TARGET_ARCH/bin
-
- cp flexlink.exe $PREFIXOCAML/bin
+ cp flexlink.exe "/usr/$TARGET_ARCH/bin"
+
+ cp flexlink.exe "$PREFIXOCAML/bin"
}
# Get binary flexdll flexlink for building OCaml
# An alternative is to first build an OCaml without shared library support and build flexlink with it
function get_flex_dll_link_bin {
- if build_prep http://alain.frisch.fr/flexdll flexdll-bin-0.34 zip 1 ; then
+ if build_prep https://github.com/alainfrisch/flexdll/releases/download/0.37/ flexdll-bin-0.37 zip 1 ; then
install_flexdll
install_flexlink
build_post
@@ -708,10 +952,12 @@ function get_flex_dll_link_bin {
# Build flexdll and flexlink from sources after building OCaml
function make_flex_dll_link {
- if build_prep http://alain.frisch.fr/flexdll flexdll-0.34 tar.gz ; then
+ if build_prep https://github.com/alainfrisch/flexdll/releases/download/0.37/ flexdll-bin-0.37 zip ; then
if [ "$TARGET_ARCH" == "i686-w64-mingw32" ]; then
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT build_mingw flexlink.exe
elif [ "$TARGET_ARCH" == "x86_64-w64-mingw32" ]; then
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT build_mingw64 flexlink.exe
else
echo "Unknown target architecture"
@@ -731,15 +977,15 @@ function make_flex_dll_link {
# For this purpose hard links are better.
function make_ln {
- if [ ! -f flagfiles/myln.finished ] ; then
- touch flagfiles/myln.started
+ if [ ! -f $FLAGFILES/myln.finished ] ; then
+ touch $FLAGFILES/myln.started
mkdir -p myln
- cd myln
+ ( cd myln
cp $PATCHES/ln.c .
- $TARGET_ARCH-gcc -DUNICODE -D_UNICODE -DIGNORE_SYMBOLIC -mconsole -o ln.exe ln.c
- install -D ln.exe $PREFIXCOQ/bin/ln.exe
- cd ..
- touch flagfiles/myln.finished
+ "$TARGET_ARCH-gcc" -DUNICODE -D_UNICODE -DIGNORE_SYMBOLIC -mconsole -o ln.exe ln.c
+ install -D ln.exe "$PREFIXCOQ/bin/ln.exe"
+ )
+ touch $FLAGFILES/myln.finished
fi
}
@@ -747,11 +993,10 @@ function make_ln {
function make_ocaml {
get_flex_dll_link_bin
- if build_prep http://caml.inria.fr/pub/distrib/ocaml-4.02 ocaml-4.02.3 tar.gz 1 ; then
- # if build_prep http://caml.inria.fr/pub/distrib/ocaml-4.01 ocaml-4.01.0 tar.gz 1 ; then
- # See README.win32
- cp config/m-nt.h config/m.h
- cp config/s-nt.h config/s.h
+ if build_prep https://github.com/ocaml/ocaml/archive 4.07.0 tar.gz 1 ocaml-4.07.0 ; then
+ # See README.win32.adoc
+ cp config/m-nt.h byterun/caml/m.h
+ cp config/s-nt.h byterun/caml/s.h
if [ "$TARGET_ARCH" == "i686-w64-mingw32" ]; then
cp config/Makefile.mingw config/Makefile
elif [ "$TARGET_ARCH" == "x86_64-w64-mingw32" ]; then
@@ -762,15 +1007,16 @@ function make_ocaml {
fi
# Prefix is fixed in make file - replace it with the real one
+ # TODO: this might not work if PREFIX contains spaces
sed -i "s|^PREFIX=.*|PREFIX=$PREFIXOCAML|" config/Makefile
-
- # We don't want to mess up Coq's dirctory structure so put the OCaml library in a separate folder
- # If we refer to the make variable ${PREFIX} below, camlp4 ends up having a wrong path:
+
+ # We don't want to mess up Coq's directory structure so put the OCaml library in a separate folder
+ # If we refer to the make variable ${PREFIX} below, camlp5 ends up having the wrong path:
# D:\bin\coq64_buildtest_abs_ocaml4\bin>ocamlc -where => D:/bin/coq64_buildtest_abs_ocaml4/libocaml
# D:\bin\coq64_buildtest_abs_ocaml4\bin>camlp4 -where => ${PREFIX}/libocaml\camlp4
# So we put an explicit path in there
sed -i "s|^LIBDIR=.*|LIBDIR=$PREFIXOCAML/libocaml|" config/Makefile
-
+
# Note: ocaml doesn't support -j 8, so don't pass MAKE_OPT
# I verified that 4.02.3 still doesn't support parallel build
log2 make world -f Makefile.nt
@@ -779,18 +1025,18 @@ function make_ocaml {
log2 make opt.opt -f Makefile.nt
log2 make install -f Makefile.nt
# TODO log2 make clean -f Makefile.nt Temporarily disabled for ocamlbuild development
-
+
# Move license files and other into into special folder
if [ "$INSTALLMODE" == "absolute" ] || [ "$INSTALLMODE" == "relocatable" ]; then
- mkdir -p $PREFIXOCAML/license_readme/ocaml
+ mkdir -p "$PREFIXOCAML/license_readme/ocaml"
# 4.01 installs these files, 4.02 doesn't. So delete them and copy them from the sources.
- rm -f *.txt
- cp LICENSE $PREFIXOCAML/license_readme/ocaml/License.txt
- cp INSTALL $PREFIXOCAML/license_readme/ocaml/Install.txt
- cp README $PREFIXOCAML/license_readme/ocaml/ReadMe.txt
- cp README.win32 $PREFIXOCAML/license_readme/ocaml/ReadMeWin32.txt
- cp VERSION $PREFIXOCAML/license_readme/ocaml/Version.txt
- cp Changes $PREFIXOCAML/license_readme/ocaml/Changes.txt
+ rm -f ./*.txt
+ cp LICENSE "$PREFIXOCAML/license_readme/ocaml/License.txt"
+ cp INSTALL.adoc "$PREFIXOCAML/license_readme/ocaml/Install.txt"
+ cp README.adoc "$PREFIXOCAML/license_readme/ocaml/ReadMe.txt"
+ cp README.win32.adoc "$PREFIXOCAML/license_readme/ocaml/ReadMeWin32.txt"
+ cp VERSION "$PREFIXOCAML/license_readme/ocaml/Version.txt"
+ cp Changes "$PREFIXOCAML/license_readme/ocaml/Changes.txt"
fi
build_post
@@ -798,17 +1044,63 @@ function make_ocaml {
make_flex_dll_link
}
+##### OCAML EXTRA TOOLS #####
+
+function make_ocaml_tools {
+ make_findlib
+ make_camlp5
+}
+
+##### OCAML EXTRA LIBRARIES #####
+
+function make_ocaml_libs {
+ make_num
+ make_findlib
+ make_lablgtk
+ # make_stdint
+}
+
+##### Ocaml num library #####
+function make_num {
+ make_ocaml
+ # We need this commit due to windows fixed, IMHO this is better than patching v1.1.
+ if build_prep https://github.com/ocaml/num/archive 7dd5e935aaa2b902585b3b2d0e55ad9b2442fff0 zip 1 num-1.1-7d; then
+ log2 make all
+ # log2 make test
+ log2 make install
+ log2 make clean
+ build_post
+ fi
+}
+
+##### OCAMLBUILD #####
+
+function make_ocamlbuild {
+ make_ocaml
+ if build_prep https://github.com/ocaml/ocamlbuild/archive 0.12.0 tar.gz 1 ocamlbuild-0.12.0; then
+ log2 make configure OCAML_NATIVE=true OCAMLBUILD_PREFIX=$PREFIXOCAML OCAMLBUILD_BINDIR=$PREFIXOCAML/bin OCAMLBUILD_LIBDIR=$PREFIXOCAML/lib
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
##### FINDLIB Ocaml library manager #####
function make_findlib {
make_ocaml
- if build_prep http://download.camlcity.org/download findlib-1.5.6 tar.gz 1 ; then
- ./configure -bindir $PREFIXOCAML\\bin -sitelib $PREFIXOCAML\\libocaml\\site-lib -config $PREFIXOCAML\\etc\\findlib.conf
+ make_ocamlbuild
+ if build_prep https://opam.ocaml.org/1.2.2/archives ocamlfind.1.8.0+opam tar.gz 1 ; then
+ logn configure ./configure -bindir "$PREFIXOCAML\\bin" -sitelib "$PREFIXOCAML\\libocaml\\site-lib" -config "$PREFIXOCAML\\etc\\findlib.conf"
# Note: findlib doesn't support -j 8, so don't pass MAKE_OPT
log2 make all
log2 make opt
log2 make install
log2 make clean
+ # Add Coq install library path to ocamlfind config file
+ # $(ocamlfind printconf conf | tr -d '\r') is the name of the config file
+ # printf "%q" "$PREFIXCOQ/lib" | sed -e 's/\\/\\\\/g' is the coq lib path double escaped for sed
+ sed -i -e 's|path="\(.*\)"|path="\1;'$(printf "%q" "$PREFIXCOQ/lib" | sed -e 's/\\/\\\\/g')'"|' $(ocamlfind printconf conf | tr -d '\r')
build_post
fi
}
@@ -818,15 +1110,11 @@ function make_findlib {
function make_menhir {
make_ocaml
make_findlib
- # if build_prep http://gallium.inria.fr/~fpottier/menhir menhir-20151112 tar.gz 1 ; then
- # For Ocaml 4.02
- # if build_prep http://gallium.inria.fr/~fpottier/menhir menhir-20151012 tar.gz 1 ; then
- # For Ocaml 4.01
- if build_prep http://gallium.inria.fr/~fpottier/menhir menhir-20140422 tar.gz 1 ; then
+ make_ocamlbuild
+ if build_prep http://gallium.inria.fr/~fpottier/menhir menhir-20180530 tar.gz 1 ; then
# Note: menhir doesn't support -j 8, so don't pass MAKE_OPT
- log2 make all PREFIX=$PREFIXOCAML
- log2 make install PREFIX=$PREFIXOCAML
- mv $PREFIXOCAML/bin/menhir $PREFIXOCAML/bin/menhir.exe
+ log2 make all PREFIX="$PREFIXOCAML"
+ log2 make install PREFIX="$PREFIXOCAML"
build_post
fi
}
@@ -839,7 +1127,7 @@ function make_camlp4 {
if ! command camlp4 ; then
make_ocaml
make_findlib
- if build_prep https://github.com/ocaml/camlp4/archive 4.02+6 tar.gz 1 camlp4-4.02+6 ; then
+ if build_prep https://github.com/ocaml/camlp4/archive 4.06+2 tar.gz 1 camlp4-4.06+2 ; then
# See https://github.com/ocaml/camlp4/issues/41#issuecomment-112018910
logn configure ./configure
# Note: camlp4 doesn't support -j 8, so don't pass MAKE_OPT
@@ -856,14 +1144,20 @@ function make_camlp4 {
function make_camlp5 {
make_ocaml
make_findlib
- if build_prep http://camlp5.gforge.inria.fr/distrib/src camlp5-6.14 tgz 1 ; then
- logn configure ./configure
+
+ if build_prep https://github.com/camlp5/camlp5/archive rel706 tar.gz 1 camlp5-rel706; then
+ logn configure ./configure
# Somehow my virus scanner has the boot.new/SAVED directory locked after the move for a second => repeat until success
sed -i 's/mv boot.new boot/until mv boot.new boot; do sleep 1; done/' Makefile
+ # shellcheck disable=SC2086
log1 make world.opt $MAKE_OPT
log2 make install
# For some reason gramlib.a is not copied, but it is required by Coq
- cp lib/gramlib.a $PREFIXOCAML/libocaml/camlp5/
+ cp lib/gramlib.a "$PREFIXOCAML/libocaml/camlp5/"
+ # For some reason META is not copied, but it is required by coq_makefile
+ log2 make -C etc META
+ mkdir -p "$PREFIXOCAML/libocaml/site-lib/camlp5/"
+ cp etc/META "$PREFIXOCAML/libocaml/site-lib/camlp5/"
log2 make clean
build_post
fi
@@ -878,19 +1172,36 @@ function make_camlp5 {
function make_lablgtk {
make_ocaml
make_findlib
- make_camlp4
- if build_prep https://forge.ocamlcore.org/frs/download.php/1479 lablgtk-2.18.3 tar.gz 1 ; then
+ # make_camlp4 # required by lablgtk-2.18.3 and lablgtk-2.18.5
+ make_gtk2
+ make_gtk_sourceview2
+ if build_prep https://forge.ocamlcore.org/frs/download.php/1726 lablgtk-2.18.6 tar.gz 1 ; then
# configure should be fixed to search for $TARGET_ARCH-pkg-config.exe
- cp /bin/$TARGET_ARCH-pkg-config.exe bin_special/pkg-config.exe
- logn configure ./configure --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIXOCAML
-
+ cp "/bin/$TARGET_ARCH-pkg-config.exe" bin_special/pkg-config.exe
+ logn configure ./configure --build="$BUILD" --host="$HOST" --target="$TARGET" --prefix="$PREFIXOCAML"
+
# lablgtk shows occasional errors with -j, so don't pass $MAKE_OPT
-
- # See https://sympa.inria.fr/sympa/arc/caml-list/2015-10/msg00204.html for the make || true + strip
- logn make-world-pre make world || true
- $TARGET_ARCH-strip.exe --strip-unneeded src/dlllablgtk2.dll
-
+
+ # lablgtk binary needs to be stripped - otherwise flexdll goes wild
+ # Fix version 1: explicit strip after failed build - this randomly fails in CI
+ # See https://sympa.inria.fr/sympa/arc/caml-list/2015-10/msg00204.html
+ # logn make-world-pre make world || true
+ # $TARGET_ARCH-strip.exe --strip-unneeded src/dlllablgtk2.dll
+
+ # Fix version 2: Strip by passing linker argument rather than explicit call to strip
+ # See https://github.com/alainfrisch/flexdll/issues/6
+ # Argument to ocamlmklib: -ldopt "-link -Wl,-s"
+ # -ldopt is the okamlmklib linker prefix option
+ # -link is the flexlink linker prefix option
+ # -Wl, is the gcc (linker driver) linker prefix option
+ # -s is the gnu linker option for stripping symbols
+ # These changes are included in dev/build/windows/patches_coq/lablgtk-2.18.3.patch
+
log2 make world
+
+ # lablgtk does not escape FINDLIBDIR path, which can contain backslashes
+ sed -i "s|^FINDLIBDIR=.*|FINDLIBDIR=$PREFIXOCAML/libocaml/site-lib|" config.make
+
log2 make install
log2 make clean
build_post
@@ -920,7 +1231,7 @@ function make_stdint {
function copy_coq_dll {
if [ "$INSTALLMODE" == "absolute" ] || [ "$INSTALLMODE" == "relocatable" ]; then
- cp /usr/${ARCH}-w64-mingw32/sys-root/mingw/bin/$1 $PREFIXCOQ/bin/$1
+ cp "/usr/${ARCH}-w64-mingw32/sys-root/mingw/bin/$1" "$PREFIXCOQ/bin/$1"
fi
}
@@ -936,7 +1247,7 @@ function copy_coq_dlls {
# Do this recursively until there are no further missing DLLs (File close + reopen)
# For running this quickly, just do "cd coq-<ver> ; call copy_coq_dlls ; cd .." at the end of this script.
# Do the same for coqc and ocamlc (usually doesn't result in additional files)
-
+
copy_coq_dll LIBATK-1.0-0.DLL
copy_coq_dll LIBCAIRO-2.DLL
copy_coq_dll LIBEXPAT-1.DLL
@@ -954,15 +1265,15 @@ function copy_coq_dlls {
copy_coq_dll LIBPANGO-1.0-0.DLL
copy_coq_dll LIBPANGOCAIRO-1.0-0.DLL
copy_coq_dll LIBPANGOWIN32-1.0-0.DLL
+ copy_coq_dll libpcre-1.dll
copy_coq_dll LIBPIXMAN-1-0.DLL
copy_coq_dll LIBPNG16-16.DLL
copy_coq_dll LIBXML2-2.DLL
copy_coq_dll ZLIB1.DLL
- # Depends on if GTK is built from sources
+ # Depends on if GTK is built from sources
if [ "$GTK_FROM_SOURCES" == "Y" ]; then
copy_coq_dll libiconv-2.dll
- copy_coq_dll libpcre-1.dll
else
copy_coq_dll ICONV.DLL
copy_coq_dll LIBBZ2-1.DLL
@@ -978,21 +1289,21 @@ function copy_coq_dlls {
i686) copy_coq_dll LIBGCC_S_SJLJ-1.DLL ;;
*) false ;;
esac
-
+
# Win pthread version change
copy_coq_dll LIBWINPTHREAD-1.DLL
}
function copy_coq_objects {
# copy objects only from folders which exist in the target lib directory
- find . -type d | while read FOLDER ; do
- if [ -e $PREFIXCOQ/lib/$FOLDER ] ; then
- install_glob $FOLDER/'*.cmxa' $PREFIXCOQ/lib/$FOLDER
- install_glob $FOLDER/'*.cmi' $PREFIXCOQ/lib/$FOLDER
- install_glob $FOLDER/'*.cma' $PREFIXCOQ/lib/$FOLDER
- install_glob $FOLDER/'*.cmo' $PREFIXCOQ/lib/$FOLDER
- install_glob $FOLDER/'*.a' $PREFIXCOQ/lib/$FOLDER
- install_glob $FOLDER/'*.o' $PREFIXCOQ/lib/$FOLDER
+ find . -type d | while read -r FOLDER ; do
+ if [ -e "$PREFIXCOQ/lib/coq/$FOLDER" ] ; then
+ install_glob "$FOLDER" '*.cmxa' "$PREFIXCOQ/lib/coq/$FOLDER"
+ install_glob "$FOLDER" '*.cmi' "$PREFIXCOQ/lib/coq/$FOLDER"
+ install_glob "$FOLDER" '*.cma' "$PREFIXCOQ/lib/coq/$FOLDER"
+ install_glob "$FOLDER" '*.cmo' "$PREFIXCOQ/lib/coq/$FOLDER"
+ install_glob "$FOLDER" '*.a' "$PREFIXCOQ/lib/coq/$FOLDER"
+ install_glob "$FOLDER" '*.o' "$PREFIXCOQ/lib/coq/$FOLDER"
fi
done
}
@@ -1000,23 +1311,28 @@ function copy_coq_objects {
# Copy required GTK config and suport files
function copq_coq_gtk {
- echo 'gtk-theme-name = "MS-Windows"' > $PREFIX/etc/gtk-2.0/gtkrc
- echo 'gtk-fallback-icon-theme = "Tango"' >> $PREFIX/etc/gtk-2.0/gtkrc
+ echo 'gtk-theme-name = "MS-Windows"' > "$PREFIX/etc/gtk-2.0/gtkrc"
+ echo 'gtk-fallback-icon-theme = "Tango"' >> "$PREFIX/etc/gtk-2.0/gtkrc"
if [ "$INSTALLMODE" == "absolute" ] || [ "$INSTALLMODE" == "relocatable" ]; then
- install_glob $PREFIX/etc/gtk-2.0/'*' $PREFIXCOQ/gtk-2.0
- install_glob $PREFIX/share/gtksourceview-2.0/language-specs/'*' $PREFIXCOQ/share/gtksourceview-2.0/language-specs
- install_glob $PREFIX/share/gtksourceview-2.0/styles/'*' $PREFIXCOQ/share/gtksourceview-2.0/styles
- install_rec $PREFIX/share/themes/ '*' $PREFIXCOQ/share/themes
-
+ install_glob "$PREFIX/etc/gtk-2.0" '*' "$PREFIXCOQ/gtk-2.0"
+ install_glob "$PREFIX/share/gtksourceview-2.0/language-specs" '*' "$PREFIXCOQ/share/gtksourceview-2.0/language-specs"
+ install_glob "$PREFIX/share/gtksourceview-2.0/styles" '*' "$PREFIXCOQ/share/gtksourceview-2.0/styles"
+ install_rec "$PREFIX/share/themes" '*' "$PREFIXCOQ/share/themes"
+
# This below item look like a bug in make install
+ if [ -d "$PREFIXCOQ/share/coq/" ] ; then
+ COQSHARE="$PREFIXCOQ/share/coq/"
+ else
+ COQSHARE="$PREFIXCOQ/share/"
+ fi
if [[ ! $COQ_VERSION == 8.4* ]] ; then
- mv $PREFIXCOQ/share/coq/*.lang $PREFIXCOQ/share/gtksourceview-2.0/language-specs
- mv $PREFIXCOQ/share/coq/*.xml $PREFIXCOQ/share/gtksourceview-2.0/styles
+ mv "$COQSHARE"*.lang "$PREFIXCOQ/share/gtksourceview-2.0/language-specs"
+ mv "$COQSHARE"*.xml "$PREFIXCOQ/share/gtksourceview-2.0/styles"
fi
- mkdir -p $PREFIXCOQ/ide
- mv $PREFIXCOQ/share/coq/*.png $PREFIXCOQ/ide
- rmdir $PREFIXCOQ/share/coq
+ mkdir -p "$PREFIXCOQ/ide"
+ mv "$COQSHARE"*.png "$PREFIXCOQ/ide"
+ rmdir "$PREFIXCOQ/share/coq" || true
fi
}
@@ -1024,16 +1340,16 @@ function copq_coq_gtk {
function copy_coq_license {
if [ "$INSTALLMODE" == "absolute" ] || [ "$INSTALLMODE" == "relocatable" ]; then
- install -D doc/LICENSE $PREFIXCOQ/license_readme/coq/LicenseDoc.txt
- install -D LICENSE $PREFIXCOQ/license_readme/coq/License.txt
- install -D plugins/micromega/LICENSE.sos $PREFIXCOQ/license_readme/coq/LicenseMicromega.txt
- install -D README $PREFIXCOQ/license_readme/coq/ReadMe.txt || true
- install -D README.md $PREFIXCOQ/license_readme/coq/ReadMe.md || true
- install -D README.doc $PREFIXCOQ/license_readme/coq/ReadMeDoc.txt
- install -D CHANGES $PREFIXCOQ/license_readme/coq/Changes.txt
- install -D INSTALL $PREFIXCOQ/license_readme/coq/Install.txt
- install -D INSTALL.doc $PREFIXCOQ/license_readme/coq/InstallDoc.txt
- install -D INSTALL.ide $PREFIXCOQ/license_readme/coq/InstallIde.txt
+ install -D doc/LICENSE "$PREFIXCOQ/license_readme/coq/LicenseDoc.txt"
+ install -D LICENSE "$PREFIXCOQ/license_readme/coq/License.txt"
+ install -D plugins/micromega/LICENSE.sos "$PREFIXCOQ/license_readme/coq/LicenseMicromega.txt"
+ install -D README "$PREFIXCOQ/license_readme/coq/ReadMe.txt" || true
+ install -D README.md "$PREFIXCOQ/license_readme/coq/ReadMe.md" || true
+ install -D README.win "$PREFIXCOQ/license_readme/coq/ReadMeWindows.txt" || true
+ install -D README.doc "$PREFIXCOQ/license_readme/coq/ReadMeDoc.txt" || true
+ install -D CHANGES "$PREFIXCOQ/license_readme/coq/Changes.txt"
+ install -D INSTALL "$PREFIXCOQ/license_readme/coq/Install.txt"
+ install -D doc/README.md "$PREFIXCOQ/license_readme/coq/ReadMeDoc.md" || true
fi
}
@@ -1041,54 +1357,82 @@ function copy_coq_license {
function make_coq {
make_ocaml
- make_lablgtk
+ make_num
+ make_findlib
make_camlp5
- if
+ make_lablgtk
+ if
case $COQ_VERSION in
- git-*) build_prep https://github.com/coq/coq/archive ${COQ_VERSION##git-} zip 1 coq-${COQ_VERSION} ;;
- *) build_prep https://coq.inria.fr/distrib/V$COQ_VERSION/files coq-$COQ_VERSION tar.gz ;;
+ # e.g. git-v8.6 => download from https://github.com/coq/coq/archive/v8.6.zip
+ # e.g. git-trunk => download from https://github.com/coq/coq/archive/trunk.zip
+ git-*)
+ COQ_BUILD_PATH=/build/coq-${COQ_VERSION}
+ build_prep https://github.com/coq/coq/archive "${COQ_VERSION##git-}" zip 1 "coq-${COQ_VERSION}"
+ ;;
+
+ # e.g. /cygdrive/d/coqgit
+ /*)
+ # Todo: --exclude-vcs-ignores doesn't work because tools/coqdoc/coqdoc.sty is excluded => fix .gitignore
+ # But this is not a big deal, only 2 files are removed with --exclude-vcs-ignores from a fresch clone
+ COQ_BUILD_PATH=/build/coq-local
+ tar -zcf $TARBALLS/coq-local.tar.gz --exclude-vcs -C "${COQ_VERSION%/*}" "${COQ_VERSION##*/}"
+ build_prep NEVER-DOWNLOADED coq-local tar.gz
+ ;;
+
+ # e.g. 8.6 => https://coq.inria.fr/distrib/8.6/files/coq-8.6.tar.gz
+ *)
+ COQ_BUILD_PATH=/build/coq-$COQ_VERSION
+ build_prep "https://coq.inria.fr/distrib/V$COQ_VERSION/files" "coq-$COQ_VERSION" tar.gz
+ ;;
esac
then
if [ "$INSTALLMODE" == "relocatable" ]; then
# HACK: for relocatable builds, first configure with ./, then build but before install reconfigure with the real target path
- logn configure ./configure -debug -with-doc no -prefix ./ -libdir ./lib -mandir ./man
+ logn configure ./configure -with-doc no -prefix ./ -libdir ./lib/coq -mandir ./man
elif [ "$INSTALLMODE" == "absolute" ]; then
- logn configure ./configure -debug -with-doc no -prefix $PREFIXCOQ -libdir $PREFIXCOQ/lib -mandir $PREFIXCOQ/man
+ logn configure ./configure -with-doc no -prefix "$PREFIXCOQ" -libdir "$PREFIXCOQ/lib/coq" -mandir "$PREFIXCOQ/man"
else
- logn configure ./configure -debug -with-doc no -prefix $PREFIXCOQ
+ logn configure ./configure -with-doc no -prefix "$PREFIXCOQ"
fi
# The windows resource compiler binary name is hard coded
- sed -i "s/i686-w64-mingw32-windres/$TARGET_ARCH-windres/" Makefile.build
+ sed -i "s/i686-w64-mingw32-windres/$TARGET_ARCH-windres/" Makefile.build
sed -i "s/i686-w64-mingw32-windres/$TARGET_ARCH-windres/" Makefile.ide || true
# 8.4x doesn't support parallel make
if [[ $COQ_VERSION == 8.4* ]] ; then
log1 make
else
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT
fi
-
+
if [ "$INSTALLMODE" == "relocatable" ]; then
- ./configure -debug -with-doc no -prefix $PREFIXCOQ -libdir $PREFIXCOQ/lib -mandir $PREFIXCOQ/man
+ logn reconfigure ./configure -with-doc no -prefix "$PREFIXCOQ" -libdir "$PREFIXCOQ/lib/coq" -mandir "$PREFIXCOQ/man"
fi
log2 make install
log1 copy_coq_dlls
if [ "$INSTALLOCAML" == "Y" ]; then
- log1 copy_coq_objects
+ copy_coq_objects
fi
-
- copq_coq_gtk
- copy_coq_license
- # make clean seems to br broken for 8.5pl2
+ log1 copq_coq_gtk
+ log1 copy_coq_license
+
+ # make clean seems to be broken for 8.5pl2
# 1.) find | xargs fails on cygwin, can be fixed by sed -i 's|\| xargs rm -f|-exec rm -fv \{\} \+|' Makefile
# 2.) clean of test suites fails with "cannot run complexity tests (no bogomips found)"
# make clean
-
+
+ # Copy these files somewhere the plugin builds can find them
+ logn copy-basic-overlays cp dev/ci/ci-basic-overlay.sh /build/
+ logn copy-user-overlays cp -r dev/ci/user-overlays /build/
+
build_post
fi
+
+ load_overlay_data
}
##### GNU Make for MinGW #####
@@ -1097,11 +1441,11 @@ function make_mingw_make {
if build_prep http://ftp.gnu.org/gnu/make make-4.2 tar.bz2 ; then
# The config.h.win32 file is fine - don't edit it
# We need to copy the mingw gcc here as "gcc" - then the batch file will use it
- cp /usr/bin/${ARCH}-w64-mingw32-gcc-5.4.0.exe ./gcc.exe
+ cp "/usr/bin/${ARCH}-w64-mingw32-gcc-6.4.0.exe" ./gcc.exe
# By some magic cygwin bash can run batch files
logn build ./build_w32.bat gcc
# Copy make to Coq folder
- cp GccRel/gnumake.exe $PREFIXCOQ/bin/make.exe
+ cp GccRel/gnumake.exe "$PREFIXCOQ/bin/make.exe"
build_post
fi
}
@@ -1110,7 +1454,8 @@ function make_mingw_make {
function make_binutils {
if build_prep http://ftp.gnu.org/gnu/binutils binutils-2.27 tar.gz ; then
- logn configure ./configure --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIXCOQ --program-prefix=$TARGET-
+ logn configure ./configure --build="$BUILD" --host="$HOST" --target="$TARGET" --prefix="$PREFIXCOQ" --program-prefix="$TARGET-"
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT
log2 make install
# log2 make clean
@@ -1133,15 +1478,16 @@ function make_gcc {
# For whatever reason gcc needs this (although it never puts anything into it)
# Error: "The directory that should contain system headers does not exist:"
# mkdir -p /mingw/include without --with-sysroot
- mkdir -p $PREFIXCOQ/mingw/include
+ mkdir -p "$PREFIXCOQ/mingw/include"
# See https://gcc.gnu.org/install/configure.html
- logn configure ./configure --build=$BUILD --host=$HOST --target=$TARGET \
- --prefix=$PREFIXCOQ --program-prefix=$TARGET- --disable-win32-registry --with-sysroot=$PREFIXCOQ \
+ logn configure ./configure --build="$BUILD" --host="$HOST" --target="$TARGET" \
+ --prefix="$PREFIXCOQ" --program-prefix="$TARGET-" --disable-win32-registry --with-sysroot="$PREFIXCOQ" \
--enable-languages=c --disable-nls \
--disable-libsanitizer --disable-libssp --disable-libquadmath --disable-libgomp --disable-libvtv --disable-lto
# --disable-decimal-float seems to be required
- # --with-sysroot=$PREFIX results in configure error that this is not an absolute path
+ # --with-sysroot="$PREFIX" results in configure error that this is not an absolute path
+ # shellcheck disable=SC2086
log1 make $MAKE_OPT
log2 make install
# log2 make clean
@@ -1152,8 +1498,8 @@ function make_gcc {
##### Get sources for Cygwin MinGW packages #####
function get_cygwin_mingw_sources {
- if [ ! -f flagfiles/cygwin_mingw_sources.finished ] ; then
- touch flagfiles/cygwin_mingw_sources.started
+ if [ ! -f $FLAGFILES/cygwin_mingw_sources.finished ] ; then
+ touch $FLAGFILES/cygwin_mingw_sources.started
# Find all installed files with mingw in the name and download the corresponding source code file from cygwin
# Steps:
@@ -1169,28 +1515,29 @@ function get_cygwin_mingw_sources {
# Take the 2nd field of the last line => ${SOURCE} = x86_64/release/mingw64-x86_64-gcc/mingw64-x86_64-gcc-5.4.0-2-src.tar.xz
# Remove that path part => ${SOURCEFILE} = mingw64-x86_64-gcc-5.4.0-2-src.tar.xz
- grep "mingw" /etc/setup/installed.db | sed 's/\.tar\.bz2 [0-1]$//' | sed 's/ /\//' | while read ARCHIVE ; do
+ grep "mingw" /etc/setup/installed.db | sed 's/\.tar\.bz2 [0-1]$//' | sed 's/ /\//' | while read -r ARCHIVE ; do
local ARCHIVEESC=${ARCHIVE//+/\\+}
- local SOURCE=`egrep -A 1 "install: ($CYGWINARCH|noarch)/release/[-+_/a-z0-9]*$ARCHIVEESC" $TARBALLS/setup.ini | tail -1 | cut -d " " -f 2`
+ local SOURCE
+ SOURCE=$(grep -E -A 1 "install: ($CYGWINARCH|noarch)/release/[-+_/a-z0-9]*$ARCHIVEESC" $TARBALLS/setup.ini | tail -1 | cut -d " " -f 2)
local SOURCEFILE=${SOURCE##*/}
# Get the source file (either from the source cache or online)
- if [ ! -f $TARBALLS/$SOURCEFILE ] ; then
- if [ -f $SOURCE_LOCAL_CACHE_CFMT/$SOURCEFILE ] ; then
- cp $SOURCE_LOCAL_CACHE_CFMT/$SOURCEFILE $TARBALLS
+ if [ ! -f "$TARBALLS/$SOURCEFILE" ] ; then
+ if [ -f "$SOURCE_LOCAL_CACHE_CFMT/$SOURCEFILE" ] ; then
+ cp "$SOURCE_LOCAL_CACHE_CFMT/$SOURCEFILE" $TARBALLS
else
- wget "$CYGWIN_REPOSITORY/$SOURCE"
- mv $SOURCEFILE $TARBALLS
+ wget --progress=dot:giga "$CYGWIN_REPOSITORY/$SOURCE"
+ mv "$SOURCEFILE" "$TARBALLS"
# Save the source archive in the source cache
- if [ -d $SOURCE_LOCAL_CACHE_CFMT ] ; then
- cp $TARBALLS/$SOURCEFILE $SOURCE_LOCAL_CACHE_CFMT
+ if [ -d "$SOURCE_LOCAL_CACHE_CFMT" ] ; then
+ cp "$TARBALLS/$SOURCEFILE" "$SOURCE_LOCAL_CACHE_CFMT"
fi
fi
fi
done
- touch flagfiles/cygwin_mingw_sources.finished
+ touch $FLAGFILES/cygwin_mingw_sources.finished
fi
}
@@ -1198,64 +1545,355 @@ function get_cygwin_mingw_sources {
function make_coq_installer {
make_coq
- make_mingw_make
get_cygwin_mingw_sources
# Prepare the file lists for the installer. We created to file list dumps of the target folder during the build:
# ocaml: ocaml + menhir + camlp5 + findlib
- # ocal_coq: as above + coq
-
+ # ocaml_coq: as above + coq
+ # ocaml_coq_addons: as above + lib/user-contrib/*
+
# Create coq file list as ocaml_coq / ocaml
diff_files coq ocaml_coq ocaml
-
+
# Filter out object files
- filter_files coq_objects coq '\.(cmxa|cmi|cma|cmo|a|o)$'
-
+ filter_files coq_objects coq '\.(cmxa|cmi|cma|cmo|a|o)$'
+
# Filter out plugin object files
- filter_files coq_objects_plugins coq_objects '/lib/plugins/.*\.(cmxa|cmi|cma|cmo|a|o)$'
-
+ filter_files coq_objects_plugins coq_objects '/lib/coq/plugins/.*\.(cmxa|cmi|cma|cmo|a|o)$'
+
# Coq objects objects required for plugin development = coq objects except those for pre installed plugins
diff_files coq_plugindev coq_objects coq_objects_plugins
-
+
+ # Addons (TODO: including objects that could go to the plugindev thing, but
+ # then one would have to make that package depend on this one, so not
+ # implemented yet)
+ diff_files coq_addons ocaml_coq_addons ocaml_coq
+
# Coq files, except objects needed only for plugin development
diff_files coq_base coq coq_plugindev
-
+
# Convert section files to NSIS format
files_to_nsis coq_base
+ files_to_nsis coq_addons
files_to_nsis coq_plugindev
files_to_nsis ocaml
-
+
# Get and extract NSIS Binaries
if build_prep http://downloads.sourceforge.net/project/nsis/NSIS%202/2.51 nsis-2.51 zip ; then
- NSIS=`pwd`/makensis.exe
+ NSIS=$(pwd)/makensis.exe
chmod u+x "$NSIS"
# Change to Coq folder
- cd ../coq-${COQ_VERSION}
+ cd "$COQ_BUILD_PATH"
# Copy patched nsi file
cp ../patches/coq_new.nsi dev/nsis
cp ../patches/StrRep.nsh dev/nsis
cp ../patches/ReplaceInFile.nsh dev/nsis
- VERSION=`grep ^VERSION= config/Makefile | cut -d = -f 2`
+ VERSION=$(grep '^VERSION=' config/Makefile | cut -d = -f 2 | tr -d '\r')
cd dev/nsis
- logn nsis-installer "$NSIS" -DVERSION=$VERSION -DARCH=$ARCH -DCOQ_SRC_PATH=$PREFIXCOQ -DCOQ_ICON=..\\..\\ide\\coq.ico coq_new.nsi
-
+ logn nsis-installer "$NSIS" -DVERSION="$VERSION" -DARCH="$ARCH" -DCOQ_SRC_PATH="$PREFIXCOQ" -DCOQ_ICON=..\\..\\ide\\coq.ico -DCOQ_ADDONS="$COQ_ADDONS" coq_new.nsi
+
build_post
fi
}
+###################### ADDON COQ LIBRARIES / PLUGINS / TOOLS #####################
+
+# The bignums library
+# Provides BigN, BigZ, BigQ that used to be part of Coq standard library
+
+function make_addon_bignums {
+ installer_addon_dependency bignums
+ if build_prep_overlay bignums; then
+ installer_addon_section bignums "Bignums" "Coq library for fast arbitrary size numbers" ""
+ # To make command lines shorter :-(
+ echo 'COQ_SRC_SUBDIRS:=$(filter-out plugins/%,$(COQ_SRC_SUBDIRS)) plugins/syntax' >> Makefile.coq.local
+ log1 make all
+ log2 make install
+ build_post
+ fi
+}
+
+# Equations plugin
+# A function definition plugin
+
+function make_addon_equations {
+ installer_addon_dependency equations
+ if build_prep_overlay Equations; then
+ installer_addon_section equations "Equations" "Coq plugin for defining functions by equations" ""
+ # Note: PATH is autmatically saved/restored by build_prep / build_post
+ PATH=$COQBIN:$PATH
+ logn coq_makefile ${COQBIN}coq_makefile -f _CoqProject -o Makefile
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
+# mathcomp - ssreflect and mathematical components library
+
+function make_addon_mathcomp {
+ installer_addon_dependency mathcomp
+ if build_prep_overlay mathcomp; then
+ installer_addon_section mathcomp "Math-Components" "Coq library with mathematical components" ""
+ cd mathcomp
+ log1 make $MAKE_OPT
+ log2 make install
+ build_post
+ fi
+}
+
+# ssreflect part of mathcomp
+
+function make_addon_ssreflect {
+ # if mathcomp addon is requested, build this instead
+ if [[ "$COQ_ADDONS" == *mathcomp* ]]; then
+ make_addon_mathcomp
+ else
+ # Note: since either mathcomp or ssreflect is defined, it is fine to name both mathcomp
+ installer_addon_dependency ssreflect
+ if build_prep_overlay mathcomp; then
+ installer_addon_section ssreflect "SSReflect" "Coq support library for small scale reflection plugin" ""
+ cd mathcomp
+ logn make-makefile make Makefile.coq
+ logn make-ssreflect make $MAKE_OPT -f Makefile.coq ssreflect/all_ssreflect.vo
+ logn make-install make -f Makefile.coq install
+ build_post
+ fi
+ fi
+}
+
+# Ltac-2 plugin
+# A new (experimental) tactic language
+
+function make_addon_ltac2 {
+ installer_addon_dependency ltac2
+ if build_prep_overlay ltac2; then
+ installer_addon_section ltac2 "Ltac-2" "Coq plugin with the Ltac-2 enhanced tactics language" ""
+ log1 make all
+ log2 make install
+ build_post
+ fi
+}
+
+# UniCoq plugin
+# An alternative unification algorithm
+function make_addon_unicoq {
+ installer_addon_dependency unicoq
+ if build_prep_overlay unicoq; then
+ log1 coq_makefile -f Make -o Makefile
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
+# Mtac2 plugin
+# An alternative typed tactic language
+function make_addon_mtac2 {
+ installer_addon_dependency_beg mtac2
+ make_addon_unicoq
+ installer_addon_dependency_end
+ if build_prep_overlay mtac2; then
+ log1 coq_makefile -f _CoqProject -o Makefile
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
+# Menhir parser generator
+
+function make_addon_menhir {
+ make_menhir
+ # If COQ and OCaml are installed to the same folder, there is nothing to do
+ installer_addon_dependency menhir
+ if [ "$PREFIXOCAML" != "$PREFIXCOQ" ] ; then
+ # Just install menhir files required for COQ to COQ target folder
+ if [ ! -f "$FLAGFILES/menhir-addon.finished" ] ; then
+ installer_addon_section menhir "Menhir" "Menhir parser generator windows executable and libraries" ""
+ LOGTARGET=menhir-addon
+ touch "$FLAGFILES/menhir-addon.started"
+ # Menhir executable
+ install_glob "$PREFIXOCAML/bin" 'menhir.exe' "$PREFIXCOQ/bin/"
+ # Menhir Standard library
+ install_glob "$PREFIXOCAML/share/menhir/" '*.mly' "$PREFIXCOQ/share/menhir/"
+ # Menhir PDF doc
+ install_glob "$PREFIXOCAML/share/doc/menhir/" '*.pdf' "$PREFIXCOQ/doc/menhir/"
+ touch "$FLAGFILES/menhir-addon.finished"
+ LOGTARGET=other
+ installer_addon_end
+ fi
+ fi
+}
+
+# COQ library for Menhir
+
+function make_addon_menhirlib {
+ installer_addon_dependency menhirlib
+ if build_prep_overlay menhirlib; then
+ installer_addon_section menhirlib "Menhirlib" "Coq support library for using Menhir generated parsers in Coq" ""
+ # The supplied makefiles don't work in any way on cygwin
+ cd src
+ echo -R . MenhirLib > _CoqProject
+ ls -1 *.v >> _CoqProject
+ log1 coq_makefile -f _CoqProject -o Makefile.coq
+ log1 make -f Makefile.coq all
+ logn make-install make -f Makefile.coq install
+ build_post
+ fi
+}
+
+# CompCert
+
+function make_addon_compcert {
+ installer_addon_dependency_beg compcert
+ make_menhir
+ make_addon_menhirlib
+ installer_addon_dependency_end
+ if build_prep_overlay CompCert; then
+ installer_addon_section compcert "CompCert" "ATTENTION: THIS IS NOT OPEN SOURCE! CompCert verified C compiler and Clightgen (required for using VST for your own code)" "off"
+ logn configure ./configure -ignore-coq-version -clightgen -prefix "$PREFIXCOQ" -coqdevdir "$PREFIXCOQ/lib/coq/user-contrib/compcert" x86_32-cygwin
+ log1 make
+ log2 make install
+ logn install-license-1 install -D -T "LICENSE" "$PREFIXCOQ/lib/coq/user-contrib/compcert/LICENSE"
+ logn install-license-2 install -D -T "LICENSE" "$PREFIXCOQ/lib/compcert/LICENSE"
+ build_post
+ fi
+}
+
+# Princeton VST
+
+function install_addon_vst {
+ VSTDEST="$PREFIXCOQ/lib/coq/user-contrib/VST"
+
+ # Install VST .v, .vo, .c and .h files
+ install_rec compcert '*.v' "$VSTDEST/compcert/"
+ install_rec compcert '*.vo' "$VSTDEST/compcert/"
+ install_glob "msl" '*.v' "$VSTDEST/msl/"
+ install_glob "msl" '*.vo' "$VSTDEST/msl/"
+ install_glob "sepcomp" '*.v' "$VSTDEST/sepcomp/"
+ install_glob "sepcomp" '*.vo' "$VSTDEST/sepcomp/"
+ install_glob "floyd" '*.v' "$VSTDEST/floyd/"
+ install_glob "floyd" '*.vo' "$VSTDEST/floyd/"
+ install_glob "progs" '*.v' "$VSTDEST/progs/"
+ install_glob "progs" '*.c' "$VSTDEST/progs/"
+ install_glob "progs" '*.h' "$VSTDEST/progs/"
+ install_glob "veric" '*.v' "$VSTDEST/msl/"
+ install_glob "veric" '*.vo' "$VSTDEST/msl/"
+
+ # Install VST documentation files
+ install_glob "." 'LICENSE' "$VSTDEST"
+ install_glob "." '*.md' "$VSTDEST"
+ install_glob "compcert" '*' "$VSTDEST/compcert"
+ install_glob "doc" '*.pdf' "$VSTDEST/doc"
+
+ # Install VST _CoqProject files
+ install_glob "." '_CoqProject*' "$VSTDEST"
+ install_glob "." '_CoqProject-export' "$VSTDEST/progs"
+}
+
+function make_addon_vst {
+ installer_addon_dependency vst
+ if build_prep_overlay VST; then
+ installer_addon_section vst "VST" "ATTENTION: SOME INCLUDED COMPCERT PARTS ARE NOT OPEN SOURCE! Verified Software Toolchain for verifying C code" "off"
+ log1 make IGNORECOQVERSION=true $MAKE_OPT
+ log1 install_addon_vst
+ build_post
+ fi
+}
+
+# coquelicot Real analysis
+
+function make_addon_coquelicot {
+ installer_addon_dependency_beg coquelicot
+ make_addon_ssreflect
+ installer_addon_dependency_end
+ if build_prep_overlay Coquelicot; then
+ installer_addon_section coquelicot "Coquelicot" "Coq library for real analysis" ""
+ logn configure ./configure --libdir="$PREFIXCOQ/lib/coq/user-contrib/Coquelicot"
+ logn remake ./remake
+ logn remake-install ./remake install
+ build_post
+ fi
+}
+
+# AAC associative / commutative rewriting
+
+function make_addon_aactactics {
+ installer_addon_dependency aac
+ if build_prep_overlay aactactis; then
+ installer_addon_section aac "AAC" "Coq plugin for extensible associative and commutative rewriting" ""
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
+# extlib
+
+function make_addon_extlib {
+ installer_addon_dependency extlib
+ if build_prep_overlay ext_lib; then
+ installer_addon_section extlib "Ext-Lib" "Coq library with many reusable general purpose components" ""
+ log1 make $MAKE_OPT
+ log2 make install
+ build_post
+ fi
+}
+
+# SimpleIO
+
+function make_addon_simple_io {
+ installer_addon_dependency simpleIO
+ if build_prep_overlay simple_io; then
+ installer_addon_section simpleIO "SimpleIO" "Coq plugin for reading and writing files directly from Coq code" ""
+ log1 make $MAKE_OPT
+ log2 make install
+ build_post
+ fi
+}
+
+# Quickchick Randomized Property-Based Testing Plugin for Coq
+
+function make_addon_quickchick {
+ installer_addon_dependency_beg quickchick
+ make_addon_ssreflect
+ make_addon_extlib
+ make_addon_simple_io
+ make_ocamlbuild
+ installer_addon_dependency_end
+ if build_prep_overlay quickchick; then
+ installer_addon_section quickchick "QuickChick" "Coq plugin for randomized testing and counter example search" ""
+ log1 make
+ log2 make install
+ build_post
+ fi
+}
+
+# Main function for building addons
+
+function make_addons {
+ # Note: ':' is the empty command, which does not produce any output
+ : > "/build/filelists/addon_dependencies.nsh"
+
+ for addon in $COQ_ADDONS; do
+ "make_addon_$addon"
+ done
+
+ sort -u -o "/build/filelists/addon_dependencies.nsh" "/build/filelists/addon_dependencies.nsh"
+}
+
###################### TOP LEVEL BUILD #####################
-make_gtk2
-make_gtk_sourceview2
+ocamlfind list || true
+make_sed
make_ocaml
-make_findlib
-make_lablgtk
-make_camlp4
-make_camlp5
-make_menhir
-make_stdint
+make_ocaml_tools
+make_ocaml_libs
+
list_files ocaml
+
make_coq
if [ "$INSTALLMAKE" == "Y" ] ; then
@@ -1264,7 +1902,10 @@ fi
list_files ocaml_coq
+make_addons
+
+list_files_always ocaml_coq_addons
+
if [ "$MAKEINSTALLER" == "Y" ] ; then
make_coq_installer
fi
-
diff --git a/dev/build/windows/patches_coq/ReplaceInFile.nsh b/dev/build/windows/patches_coq/ReplaceInFile.nsh
deleted file mode 100644
index 27c7eb2f..00000000
--- a/dev/build/windows/patches_coq/ReplaceInFile.nsh
+++ /dev/null
@@ -1,67 +0,0 @@
-; From NSIS Wiki http://nsis.sourceforge.net/ReplaceInFile
-; Modifications:
-; - Replace only once per line
-; - Don't keep original as .old
-; - Use StrRep instead of StrReplace (seems to be cleaner)
-
-Function Func_ReplaceInFile
- ClearErrors
-
- Exch $0 ; REPLACEMENT
- Exch
- Exch $1 ; SEARCH_TEXT
- Exch 2
- Exch $2 ; SOURCE_FILE
-
- Push $R0 ; SOURCE_FILE file handle
- Push $R1 ; temporary file handle
- Push $R2 ; unique temporary file name
- Push $R3 ; a line to search and replace / save
- Push $R4 ; shift puffer
-
- IfFileExists $2 +1 error ; Check if file exists and open it
- FileOpen $R0 $2 "r"
-
- GetTempFileName $R2 ; Create temporary output file
- FileOpen $R1 $R2 "w"
-
- loop: ; Loop over lines of file
- FileRead $R0 $R3 ; Read line
- IfErrors finished
- Push "$R3" ; Replacine string in line once
- Push "$1"
- Push "$0"
- Call Func_StrRep
- Pop $R3
- FileWrite $R1 "$R3" ; Write result
- Goto loop
-
- finished:
- FileClose $R1 ; Close files
- FileClose $R0
- Delete "$2" ; Delete original file and rename temporary file to target
- Rename "$R2" "$2"
- ClearErrors
- Goto out
-
- error:
- SetErrors
-
- out:
- Pop $R4
- Pop $R3
- Pop $R2
- Pop $R1
- Pop $R0
- Pop $2
- Pop $0
- Pop $1
-FunctionEnd
-
-!macro ReplaceInFile SOURCE_FILE SEARCH_TEXT REPLACEMENT
- Push "${SOURCE_FILE}"
- Push "${SEARCH_TEXT}"
- Push "${REPLACEMENT}"
- Call Func_ReplaceInFile
-!macroend
-
diff --git a/dev/build/windows/patches_coq/StrRep.nsh b/dev/build/windows/patches_coq/StrRep.nsh
deleted file mode 100644
index d94a9f88..00000000
--- a/dev/build/windows/patches_coq/StrRep.nsh
+++ /dev/null
@@ -1,60 +0,0 @@
-; From NSIS Wiki http://nsis.sourceforge.net/StrRep
-; Slightly modified
-
-Function Func_StrRep
- Exch $R2 ;new
- Exch 1
- Exch $R1 ;old
- Exch 2
- Exch $R0 ;string
- Push $R3
- Push $R4
- Push $R5
- Push $R6
- Push $R7
- Push $R8
- Push $R9
-
- StrCpy $R3 0
- StrLen $R4 $R1
- StrLen $R6 $R0
- StrLen $R9 $R2
- loop:
- StrCpy $R5 $R0 $R4 $R3
- StrCmp $R5 $R1 found
- StrCmp $R3 $R6 done
- IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character
- Goto loop
- found:
- StrCpy $R5 $R0 $R3
- IntOp $R8 $R3 + $R4
- StrCpy $R7 $R0 "" $R8
- StrCpy $R0 $R5$R2$R7
- StrLen $R6 $R0
- IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string
- Goto loop
- done:
-
- Pop $R9
- Pop $R8
- Pop $R7
- Pop $R6
- Pop $R5
- Pop $R4
- Pop $R3
- Push $R0
- Push $R1
- Pop $R0
- Pop $R1
- Pop $R0
- Pop $R2
- Exch $R1
-FunctionEnd
-
-!macro StrRep output string old new
- Push `${string}`
- Push `${old}`
- Push `${new}`
- Call Func_StrRep
- Pop ${output}
-!macroend
diff --git a/dev/build/windows/patches_coq/aactactis-86ac28259030649ef51460e4de2441c8a1017751.patch b/dev/build/windows/patches_coq/aactactis-86ac28259030649ef51460e4de2441c8a1017751.patch
new file mode 100644
index 00000000..d9b134b2
--- /dev/null
+++ b/dev/build/windows/patches_coq/aactactis-86ac28259030649ef51460e4de2441c8a1017751.patch
@@ -0,0 +1,21 @@
+--- aac-tactics-v8.8.orig\Tutorial.v 2018-05-30 16:09:06.000000000 +0200
++++ aac-tactics-v8.8\Tutorial.v 2018-08-24 19:47:25.000000000 +0200
+@@ -9,16 +9,14 @@
+ (** * Tutorial for using the [aac_tactics] library.
+
+ Depending on your installation, either modify the following two
+ lines, or add them to your .coqrc files, replacing "." with the
+ path to the [aac_tactics] library. *)
+
+-Add Rec LoadPath "." as AAC_tactics.
+-Add ML Path ".".
+-Require Import AAC.
+-Require Instances.
++Require Import AAC_tactics.AAC.
++Require AAC_tactics.Instances.
+ Require Arith ZArith.
+
+ (** ** Introductory example
+
+ Here is a first example with relative numbers ([Z]): one can
+ rewrite an universally quantified hypothesis modulo the
diff --git a/dev/build/windows/patches_coq/coq_new.nsi b/dev/build/windows/patches_coq/coq_new.nsi
index b88aa066..9947965c 100644
--- a/dev/build/windows/patches_coq/coq_new.nsi
+++ b/dev/build/windows/patches_coq/coq_new.nsi
@@ -9,13 +9,14 @@
; ARCH The target architecture, either x86_64 or i686
; COQ_SRC_PATH path of Coq installation in Windows or MinGW format (either \\ or /, but with drive letter)
; COQ_ICON path of Coq icon file in Windows or MinGW format
+; COQ_ADDONS list of addons that are shipped
; Enable compression after debugging.
; SetCompress off
SetCompressor lzma
!define MY_PRODUCT "Coq" ;Define your own software name here
-!define OUTFILE "coq-installer-${VERSION}-${ARCH}.exe"
+!define OUTFILE "coq-${VERSION}-installer-windows-${ARCH}.exe"
!include "MUI2.nsh"
!include "FileAssociation.nsh"
@@ -37,42 +38,20 @@ Var INSTDIR_DBS ; INSTDIR with \\ instead of \
;Folder selection page
InstallDir "C:\${MY_PRODUCT}"
-
+
;Remember install folder
InstallDirRegKey HKCU "Software\${MY_PRODUCT}" ""
;--------------------------------
-;Modern UI Configuration
-
- !define MUI_ICON "${COQ_ICON}"
-
- !insertmacro MUI_PAGE_WELCOME
- !insertmacro MUI_PAGE_LICENSE "${COQ_SRC_PATH}/license_readme/coq/License.txt"
- !insertmacro MUI_PAGE_COMPONENTS
- !define MUI_DIRECTORYPAGE_TEXT_TOP "Select where to install Coq. The path MUST NOT include spaces."
- !insertmacro MUI_PAGE_DIRECTORY
- !insertmacro MUI_PAGE_INSTFILES
- !insertmacro MUI_PAGE_FINISH
-
- !insertmacro MUI_UNPAGE_WELCOME
- !insertmacro MUI_UNPAGE_CONFIRM
- !insertmacro MUI_UNPAGE_INSTFILES
- !insertmacro MUI_UNPAGE_FINISH
-
-;--------------------------------
-;Languages
-
- !insertmacro MUI_LANGUAGE "English"
-
-;--------------------------------
-;Language Strings
+;Extra license pages
- ;Description
- LangString DESC_1 ${LANG_ENGLISH} "This package contains Coq and CoqIDE."
- LangString DESC_2 ${LANG_ENGLISH} "This package contains an OCaml compiler for Coq native compute and plugin development."
- LangString DESC_3 ${LANG_ENGLISH} "This package contains the development files needed in order to build a plugin for Coq."
- LangString DESC_4 ${LANG_ENGLISH} "Set the OCAMLLIB environment variable for the current user."
- LangString DESC_5 ${LANG_ENGLISH} "Set the OCAMLLIB environment variable for all users."
+!macro MUI_PAGE_LICENSE_EXTRA Licensefile Header Subheader Bottom SelFunc
+ !define MUI_PAGE_HEADER_TEXT "${Header}"
+ !define MUI_PAGE_HEADER_SUBTEXT "${Subheader}"
+ !define MUI_LICENSEPAGE_TEXT_BOTTOM "${Bottom}"
+ !define MUI_PAGE_CUSTOMFUNCTION_PRE ${SelFunc}
+ !insertmacro MUI_PAGE_LICENSE "${Licensefile}"
+!macroend
;--------------------------------
; Check for white spaces
@@ -93,7 +72,6 @@ FunctionEnd
;--------------------------------
;Installer Sections
-
Section "Coq" Sec1
SetOutPath "$INSTDIR\"
@@ -103,7 +81,7 @@ Section "Coq" Sec1
;Store install folder
WriteRegStr HKCU "Software\${MY_PRODUCT}" "" $INSTDIR
-
+
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Coq" \
@@ -121,7 +99,7 @@ Section "Coq" Sec1
; Create start menu entries
; SetOutPath is required for the path in the .lnk files
- SetOutPath "$INSTDIR"
+ SetOutPath "$INSTDIR"
CreateDirectory "$SMPROGRAMS\Coq"
; The first shortcut set here is treated as main application by Windows 7/8.
; Use CoqIDE as main application
@@ -136,20 +114,24 @@ SectionEnd
;OCAML Section "Ocaml for native compute and plugin development" Sec2
;OCAML SetOutPath "$INSTDIR\"
;OCAML !include "..\..\..\filelists\ocaml.nsh"
-;OCAML
+;OCAML
;OCAML ; Create a few slash / backslash variants of the source and install path
;OCAML ; Note: NSIS has variables, written as $VAR and defines, written as ${VAR}
;OCAML !insertmacro StrRep $COQ_SRC_PATH_BS ${COQ_SRC_PATH} "/" "\"
;OCAML !insertmacro StrRep $COQ_SRC_PATH_DBS ${COQ_SRC_PATH} "/" "\\"
;OCAML !insertmacro StrRep $INSTDIR_DBS $INSTDIR "\" "\\"
-;OCAML
+;OCAML
;OCAML ; Replace absolute paths in some OCaml config files
;OCAML ; These are not all, see ReadMe.txt
;OCAML !insertmacro ReplaceInFile "$INSTDIR\libocaml\ld.conf" "/" "\"
;OCAML !insertmacro ReplaceInFile "$INSTDIR\libocaml\ld.conf" "$COQ_SRC_PATH_BS" "$INSTDIR"
;OCAML !insertmacro ReplaceInFile "$INSTDIR\etc\findlib.conf" "$COQ_SRC_PATH_DBS" "$INSTDIR_DBS"
;OCAML SectionEnd
-
+
+SectionGroup "Coq addons" Sec2
+ !include "..\..\..\filelists\addon_sections.nsh"
+SectionGroupEnd
+
Section "Coq files for plugin developers" Sec3
SetOutPath "$INSTDIR\"
!include "..\..\..\filelists\coq_plugindev.nsh"
@@ -172,23 +154,148 @@ SectionEnd
;OCAML SectionEnd
;--------------------------------
+;Section dependencies
+
+; Parameters on the stack:
+; top-0 : section B on which section A dependencies
+; top-1 : section A, which depends on section B
+; top-2 : name of section B
+; top-3 : name of section A
+
+Function CheckSectionDependency
+ ; stack=nameB nameA secB secA rest
+ Exch $R3 ; stack=$R3 nameA secB secA rest; $R3=nameB
+ Exch ; stack=nameA $R3 secB secA rest
+ Exch $R2 ; stack=$R2 $R3 secB secA rest; $R2=nameA
+ Exch 2 ; stack=secB $R3 $R2 secA rest
+ Exch $R1 ; stack=$R1 $R3 $R2 secA rest; $R1=secB
+ Exch 3 ; stack=secA $R3 $R2 $R1 rest;
+ Exch $R0 ; stack=$R0 $R3 $R2 $R1 rest; $R0=secA
+ ; Take care of save order when popping the stack!
+ Push $R4
+ Push $R5
+
+ SectionGetFlags $R0 $R0
+ IntOp $R0 $R0 & ${SF_SELECTED}
+
+ SectionGetFlags $R1 $R4
+ IntOp $R5 $R4 & ${SF_SELECTED}
+
+ ${If} $R0 == ${SF_SELECTED}
+ ${AndIf} $R5 != ${SF_SELECTED}
+
+ IntOp $R5 $R4 | ${SF_SELECTED}
+ SectionSetFlags $R1 $R5
+ MessageBox MB_OK '"$R3" has been selected, because "$R2" depends on it'
+
+ ${EndIf}
+
+ Pop $R5
+ Pop $R4
+ Pop $R0
+ Pop $R3
+ Pop $R2
+ Pop $R1
+FunctionEnd
+
+!macro CheckSectionDependency secA secB nameA nameB
+ Push "${secA}"
+ Push "${secB}"
+ Push "${nameA}"
+ Push "${nameB}"
+ Call CheckSectionDependency
+!macroend
+
+!define CheckSectionDependency "!insertmacro CheckSectionDependency"
+
+Function .onSelChange
+ !include "..\..\..\filelists\addon_dependencies.nsh"
+FunctionEnd
+
+;--------------------------------
+;Modern UI Configuration
+
+; Note: this must be placed after the sections, because below we need to check at compile time
+; if sections exist (by !ifdef <section_index_var>) to decide if the license page must be included.
+; The section index variables are only defined after the section definitions.
+
+ !define MUI_ICON "${COQ_ICON}"
+
+ !insertmacro MUI_PAGE_WELCOME
+ !insertmacro MUI_PAGE_LICENSE "${COQ_SRC_PATH}/license_readme/coq/License.txt"
+ !insertmacro MUI_PAGE_COMPONENTS
+
+ !ifdef Sec_compcert
+ !define LicCompCert_Title "CompCert License Agreement"
+ !define LicCompCert_SubTitle "You selected the CompCert addon. CompCert is not open source. Please review the license terms before installing CompCert!"
+ !define LicCompCert_Bottom "If you accept the terms of the agreement, click I Agree to continue. Otherwise go back and unselect the CompCert addon."
+ !insertmacro MUI_PAGE_LICENSE_EXTRA "${COQ_SRC_PATH}/lib/coq/user-contrib/compcert/LICENSE" "${LicCompCert_Title}" "${LicCompCert_SubTitle}" "${LicCompCert_Bottom}" SelFuncCompCert
+
+ Function SelFuncCompCert
+ ${Unless} ${SectionIsSelected} ${Sec_compcert}
+ Abort
+ ${EndUnless}
+ FunctionEnd
+ !endif
+
+ !ifdef Sec_vst
+ !define LicVST_Title "Princeton VST License Agreement"
+ !define LicVST_SubTitle "You selected the VST addon. VST contains parts of CompCert which are not open source. Please review the license terms before installing VST!"
+ !define LicVST_Bottom "If you accept the terms of the agreement, click I Agree to continue. Otherwise go back and unselect the VST addon."
+ !insertmacro MUI_PAGE_LICENSE_EXTRA "${COQ_SRC_PATH}/lib/coq/user-contrib/VST/LICENSE" "${LicVST_Title}" "${LicVST_SubTitle}" "${LicVST_Bottom}" SelFuncVST
+
+ Function SelFuncVST
+ ${Unless} ${SectionIsSelected} ${Sec_vst}
+ Abort
+ ${EndUnless}
+ FunctionEnd
+ !endif
+
+ !define MUI_DIRECTORYPAGE_TEXT_TOP "Select where to install Coq. The path MUST NOT include spaces."
+ !insertmacro MUI_PAGE_DIRECTORY
+ !insertmacro MUI_PAGE_INSTFILES
+ !insertmacro MUI_PAGE_FINISH
+
+ !insertmacro MUI_UNPAGE_WELCOME
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+ !insertmacro MUI_UNPAGE_FINISH
+
+;--------------------------------
+;Languages
+
+ !insertmacro MUI_LANGUAGE "English"
+
+;--------------------------------
+;Language Strings
+
+ ;Description
+ LangString DESC_1 ${LANG_ENGLISH} "This package contains Coq and CoqIDE."
+ LangString DESC_2 ${LANG_ENGLISH} "This package contains the following extra Coq packages: ${COQ_ADDONS}"
+ LangString DESC_3 ${LANG_ENGLISH} "This package contains the development files needed in order to build a plugin for Coq."
+ ; LangString DESC_4 ${LANG_ENGLISH} "Set the OCAMLLIB environment variable for the current user."
+ ; LangString DESC_5 ${LANG_ENGLISH} "Set the OCAMLLIB environment variable for all users."
+ !include "..\..\..\filelists\addon_strings.nsh"
+
+;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Sec1} $(DESC_1)
- ;OCAML !insertmacro MUI_DESCRIPTION_TEXT ${Sec2} $(DESC_2)
+ !insertmacro MUI_DESCRIPTION_TEXT ${Sec2} $(DESC_2)
!insertmacro MUI_DESCRIPTION_TEXT ${Sec3} $(DESC_3)
;OCAML !insertmacro MUI_DESCRIPTION_TEXT ${Sec4} $(DESC_4)
;OCAML !insertmacro MUI_DESCRIPTION_TEXT ${Sec5} $(DESC_5)
+ !include "..\..\..\filelists\addon_descriptions.nsh"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
-
+
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; Files and folders
RMDir /r "$INSTDIR\bin"
- RMDir /r "$INSTDIR\dev"
+ RMDir /r "$INSTDIR\doc"
RMDir /r "$INSTDIR\etc"
RMDir /r "$INSTDIR\lib"
RMDir /r "$INSTDIR\libocaml"
@@ -207,7 +314,7 @@ Section "Uninstall"
Delete "$SMPROGRAMS\Coq\The Coq HomePage.url"
Delete "$SMPROGRAMS\Coq\The Coq Standard Library.url"
Delete "$INSTDIR\Uninstall.exe"
-
+
; Registry keys
DeleteRegKey HKCU "Software\${MY_PRODUCT}"
DeleteRegKey HKLM "SOFTWARE\Coq"
diff --git a/dev/build/windows/patches_coq/lablgtk-2.18.3.patch b/dev/build/windows/patches_coq/lablgtk-2.18.3.patch
index 0691c1fc..23c30313 100644
--- a/dev/build/windows/patches_coq/lablgtk-2.18.3.patch
+++ b/dev/build/windows/patches_coq/lablgtk-2.18.3.patch
@@ -1,6 +1,12 @@
-diff -u -r lablgtk-2.18.3/configure lablgtk-2.18.3.patched/configure
---- lablgtk-2.18.3/configure 2014-10-29 08:51:05.000000000 +0100
-+++ lablgtk-2.18.3.patched/configure 2015-10-29 08:58:08.543985500 +0100
+diff/patch file created on Wed, Apr 25, 2018 11:08:05 AM with:
+difftar-folder.sh ../coq-msoegtrop/dev/build/windows/source_cache/lablgtk-2.18.3.tar.gz lablgtk-2.18.3 1
+TARFILE= ../coq-msoegtrop/dev/build/windows/source_cache/lablgtk-2.18.3.tar.gz
+FOLDER= lablgtk-2.18.3
+TARSTRIP= 1
+TARPREFIX= lablgtk-2.18.3/
+ORIGFOLDER= lablgtk-2.18.3.orig
+--- lablgtk-2.18.3.orig/configure 2014-10-29 08:51:05.000000000 +0100
++++ lablgtk-2.18.3/configure 2018-04-25 10:58:54.454501600 +0200
@@ -2667,7 +2667,7 @@
fi
@@ -10,10 +16,8 @@ diff -u -r lablgtk-2.18.3/configure lablgtk-2.18.3.patched/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring ocamlfind" >&5
$as_echo "$as_me: WARNING: Ignoring ocamlfind" >&2;}
OCAMLFIND=no
-
-diff -u -r lablgtk-2.18.3/src/glib.mli lablgtk-2.18.3.patched/src/glib.mli
---- lablgtk-2.18.3/src/glib.mli 2014-10-29 08:51:06.000000000 +0100
-+++ lablgtk-2.18.3.patched/src/glib.mli 2016-01-25 09:50:59.884715200 +0100
+--- lablgtk-2.18.3.orig/src/glib.mli 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/glib.mli 2018-04-25 10:58:54.493555500 +0200
@@ -75,6 +75,7 @@
type condition = [ `ERR | `HUP | `IN | `NVAL | `OUT | `PRI]
type id
@@ -22,10 +26,8 @@ diff -u -r lablgtk-2.18.3/src/glib.mli lablgtk-2.18.3.patched/src/glib.mli
val add_watch :
cond:condition list -> callback:(condition list -> bool) -> ?prio:int -> channel -> id
val remove : id -> unit
-
-diff -u -r lablgtk-2.18.3/src/glib.ml lablgtk-2.18.3.patched/src/glib.ml
---- lablgtk-2.18.3/src/glib.ml 2014-10-29 08:51:06.000000000 +0100
-+++ lablgtk-2.18.3.patched/src/glib.ml 2016-01-25 09:50:59.891715900 +0100
+--- lablgtk-2.18.3.orig/src/glib.ml 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/glib.ml 2018-04-25 10:58:54.479543500 +0200
@@ -72,6 +72,8 @@
type id
external channel_of_descr : Unix.file_descr -> channel
@@ -35,10 +37,22 @@ diff -u -r lablgtk-2.18.3/src/glib.ml lablgtk-2.18.3.patched/src/glib.ml
external remove : id -> unit = "ml_g_source_remove"
external add_watch :
cond:condition list -> callback:(condition list -> bool) -> ?prio:int -> channel -> id
-
-diff -u -r lablgtk-2.18.3/src/ml_glib.c lablgtk-2.18.3.patched/src/ml_glib.c
---- lablgtk-2.18.3/src/ml_glib.c 2014-10-29 08:51:06.000000000 +0100
-+++ lablgtk-2.18.3.patched/src/ml_glib.c 2016-01-25 09:50:59.898716600 +0100
+--- lablgtk-2.18.3.orig/src/Makefile 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/Makefile 2018-04-25 10:58:54.506522500 +0200
+@@ -461,9 +461,9 @@
+ do rm -f "$(BINDIR)"/$$f; done
+
+ lablgtk.cma liblablgtk2$(XA): $(COBJS) $(MLOBJS)
+- $(LIBRARIAN) -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
++ $(LIBRARIAN) -ldopt "-link -Wl,-s" -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
+ lablgtk.cmxa: $(COBJS) $(MLOBJS:.cmo=.cmx)
+- $(LIBRARIAN) -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
++ $(LIBRARIAN) -ldopt "-link -Wl,-s" -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
+ lablgtk.cmxs: DYNLINKLIBS=$(GTK_LIBS)
+
+ lablgtkgl.cma liblablgtkgl2$(XA): $(GLCOBJS) $(GLMLOBJS)
+--- lablgtk-2.18.3.orig/src/ml_glib.c 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/ml_glib.c 2018-04-25 10:58:54.539535600 +0200
@@ -25,6 +25,8 @@
#include <string.h>
#include <locale.h>
diff --git a/dev/build/windows/patches_coq/lablgtk-2.18.6.patch b/dev/build/windows/patches_coq/lablgtk-2.18.6.patch
new file mode 100644
index 00000000..23c30313
--- /dev/null
+++ b/dev/build/windows/patches_coq/lablgtk-2.18.6.patch
@@ -0,0 +1,101 @@
+diff/patch file created on Wed, Apr 25, 2018 11:08:05 AM with:
+difftar-folder.sh ../coq-msoegtrop/dev/build/windows/source_cache/lablgtk-2.18.3.tar.gz lablgtk-2.18.3 1
+TARFILE= ../coq-msoegtrop/dev/build/windows/source_cache/lablgtk-2.18.3.tar.gz
+FOLDER= lablgtk-2.18.3
+TARSTRIP= 1
+TARPREFIX= lablgtk-2.18.3/
+ORIGFOLDER= lablgtk-2.18.3.orig
+--- lablgtk-2.18.3.orig/configure 2014-10-29 08:51:05.000000000 +0100
++++ lablgtk-2.18.3/configure 2018-04-25 10:58:54.454501600 +0200
+@@ -2667,7 +2667,7 @@
+ fi
+
+
+-if test "`$OCAMLFIND printconf stdlib`" != "`$CAMLC -where`"; then
++if test "`$OCAMLFIND printconf stdlib | tr '\\' '/'`" != "`$CAMLC -where | tr '\\' '/'`"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring ocamlfind" >&5
+ $as_echo "$as_me: WARNING: Ignoring ocamlfind" >&2;}
+ OCAMLFIND=no
+--- lablgtk-2.18.3.orig/src/glib.mli 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/glib.mli 2018-04-25 10:58:54.493555500 +0200
+@@ -75,6 +75,7 @@
+ type condition = [ `ERR | `HUP | `IN | `NVAL | `OUT | `PRI]
+ type id
+ val channel_of_descr : Unix.file_descr -> channel
++ val channel_of_descr_socket : Unix.file_descr -> channel
+ val add_watch :
+ cond:condition list -> callback:(condition list -> bool) -> ?prio:int -> channel -> id
+ val remove : id -> unit
+--- lablgtk-2.18.3.orig/src/glib.ml 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/glib.ml 2018-04-25 10:58:54.479543500 +0200
+@@ -72,6 +72,8 @@
+ type id
+ external channel_of_descr : Unix.file_descr -> channel
+ = "ml_g_io_channel_unix_new"
++ external channel_of_descr_socket : Unix.file_descr -> channel
++ = "ml_g_io_channel_unix_new_socket"
+ external remove : id -> unit = "ml_g_source_remove"
+ external add_watch :
+ cond:condition list -> callback:(condition list -> bool) -> ?prio:int -> channel -> id
+--- lablgtk-2.18.3.orig/src/Makefile 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/Makefile 2018-04-25 10:58:54.506522500 +0200
+@@ -461,9 +461,9 @@
+ do rm -f "$(BINDIR)"/$$f; done
+
+ lablgtk.cma liblablgtk2$(XA): $(COBJS) $(MLOBJS)
+- $(LIBRARIAN) -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
++ $(LIBRARIAN) -ldopt "-link -Wl,-s" -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
+ lablgtk.cmxa: $(COBJS) $(MLOBJS:.cmo=.cmx)
+- $(LIBRARIAN) -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
++ $(LIBRARIAN) -ldopt "-link -Wl,-s" -o lablgtk -oc lablgtk2 $^ $(GTKLIBS)
+ lablgtk.cmxs: DYNLINKLIBS=$(GTK_LIBS)
+
+ lablgtkgl.cma liblablgtkgl2$(XA): $(GLCOBJS) $(GLMLOBJS)
+--- lablgtk-2.18.3.orig/src/ml_glib.c 2014-10-29 08:51:06.000000000 +0100
++++ lablgtk-2.18.3/src/ml_glib.c 2018-04-25 10:58:54.539535600 +0200
+@@ -25,6 +25,8 @@
+ #include <string.h>
+ #include <locale.h>
+ #ifdef _WIN32
++/* to kill a #warning: include winsock2.h before windows.h */
++#include <winsock2.h>
+ #include "win32.h"
+ #include <wtypes.h>
+ #include <io.h>
+@@ -38,6 +40,11 @@
+ #include <caml/callback.h>
+ #include <caml/threads.h>
+
++#ifdef _WIN32
++/* for Socket_val */
++#include <caml/unixsupport.h>
++#endif
++
+ #include "wrappers.h"
+ #include "ml_glib.h"
+ #include "glib_tags.h"
+@@ -325,14 +332,23 @@
+
+ #ifndef _WIN32
+ ML_1 (g_io_channel_unix_new, Int_val, Val_GIOChannel_noref)
++CAMLprim value ml_g_io_channel_unix_new_socket (value arg1) {
++ return Val_GIOChannel_noref (g_io_channel_unix_new (Int_val (arg1)));
++}
+
+ #else
+ CAMLprim value ml_g_io_channel_unix_new(value wh)
+ {
+ return Val_GIOChannel_noref
+- (g_io_channel_unix_new
++ (g_io_channel_win32_new_fd
+ (_open_osfhandle((long)*(HANDLE*)Data_custom_val(wh), O_BINARY)));
+ }
++
++CAMLprim value ml_g_io_channel_unix_new_socket(value wh)
++{
++ return Val_GIOChannel_noref
++ (g_io_channel_win32_new_socket(Socket_val(wh)));
++}
+ #endif
+
+ static gboolean ml_g_io_channel_watch(GIOChannel *s, GIOCondition c,
diff --git a/dev/build/windows/patches_coq/ln.c b/dev/build/windows/patches_coq/ln.c
index 5e02c72b..41f64f98 100644
--- a/dev/build/windows/patches_coq/ln.c
+++ b/dev/build/windows/patches_coq/ln.c
@@ -134,4 +134,4 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
// Everything is fine
return 0;
-} \ No newline at end of file
+}
diff --git a/dev/build/windows/patches_coq/quickchick-v1.0.2.patch b/dev/build/windows/patches_coq/quickchick-v1.0.2.patch
new file mode 100644
index 00000000..d03749ba
--- /dev/null
+++ b/dev/build/windows/patches_coq/quickchick-v1.0.2.patch
@@ -0,0 +1,38 @@
+diff/patch file created on Mon, Aug 27, 2018 9:21:52 AM with:
+difftar-folder.sh tarballs/quickchick-v1.0.2.tar.gz quickchick-v1.0.2 1
+TARFILE= tarballs/quickchick-v1.0.2.tar.gz
+FOLDER= quickchick-v1.0.2
+TARSTRIP= 1
+TARPREFIX= QuickChick-1.0.2/
+ORIGFOLDER= quickchick-v1.0.2.orig
+--- quickchick-v1.0.2.orig/Makefile 2018-08-22 18:21:39.000000000 +0200
++++ quickchick-v1.0.2/Makefile 2018-08-27 09:21:04.710461100 +0200
+@@ -2,7 +2,7 @@
+ .PHONY: plugin install install-plugin clean quickChickTool
+
+ QCTOOL_DIR=quickChickTool
+-QCTOOL_EXE=quickChickTool.byte
++QCTOOL_EXE=quickChickTool.native
+ QCTOOL_SRC=$(QCTOOL_DIR)/quickChickTool.ml \
+ $(QCTOOL_DIR)/quickChickToolTypes.ml \
+ $(QCTOOL_DIR)/quickChickToolLexer.mll \
+@@ -32,7 +32,7 @@
+ install: all
+ $(V)$(MAKE) -f Makefile.coq install > $(TEMPFILE)
+ # Manually copying the remaining files
+- $(V)cp $(QCTOOL_EXE) $(shell opam config var bin)/quickChick
++ $(V)cp $(QCTOOL_EXE) "$(COQBIN)/quickChick"
+ # $(V)cp src/quickChickLib.cmx $(COQLIB)/user-contrib/QuickChick
+ # $(V)cp src/quickChickLib.o $(COQLIB)/user-contrib/QuickChick
+
+--- quickchick-v1.0.2.orig/src/Show.v 2018-08-22 18:21:39.000000000 +0200
++++ quickchick-v1.0.2/src/Show.v 2018-08-27 09:21:35.893961900 +0200
+@@ -228,7 +228,7 @@
+ match s with
+ | EmptyString => (if b then ")" else "", b)
+ | String a s =>
+- let (s', b) := aux s (orb b (nat_of_ascii a =? 32)) in
++ let (s', b) := aux s (orb b (nat_of_ascii a =? 32)%nat) in
+ (String a s', b)
+ end in
+ let (s', b) := aux s false in
diff --git a/dev/build/windows/patches_coq/sed-4.2.2-3.src.patch b/dev/build/windows/patches_coq/sed-4.2.2-3.src.patch
new file mode 100755
index 00000000..d210a041
--- /dev/null
+++ b/dev/build/windows/patches_coq/sed-4.2.2-3.src.patch
@@ -0,0 +1,1301 @@
+--- origsrc/sed-4.2.2/doc/sed.1 2012-12-22 15:27:13.000000000 +0100
++++ src/sed-4.2.2/doc/sed.1 2013-06-27 18:10:47.974060492 +0200
+@@ -1,5 +1,5 @@
+ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
+-.TH SED "1" "December 2012" "sed 4.2.2" "User Commands"
++.TH SED "1" "June 2013" "sed 4.2.2" "User Commands"
+ .SH NAME
+ sed \- stream editor for filtering and transforming text
+ .SH SYNOPSIS
+@@ -40,6 +40,10 @@ follow symlinks when processing in place
+ .IP
+ edit files in place (makes backup if SUFFIX supplied)
+ .HP
++\fB\-b\fR, \fB\-\-binary\fR
++.IP
++open files in binary mode (CR+LFs are not processed specially)
++.HP
+ \fB\-l\fR N, \fB\-\-line\-length\fR=\fIN\fR
+ .IP
+ specify the desired line-wrap length for the `l' command
+--- origsrc/sed-4.2.2/lib/regcomp.c 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regcomp.c 2013-06-27 18:05:27.044448044 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
+ size_t length, reg_syntax_t syntax);
+@@ -95,20 +94,20 @@ static reg_errcode_t build_charclass (RE
+ bitset_t sbcset,
+ re_charset_t *mbcset,
+ Idx *char_class_alloc,
+- const unsigned char *class_name,
++ const char *class_name,
+ reg_syntax_t syntax);
+ #else /* not RE_ENABLE_I18N */
+ static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ const unsigned char *name);
+ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+- const unsigned char *class_name,
++ const char *class_name,
+ reg_syntax_t syntax);
+ #endif /* not RE_ENABLE_I18N */
+ static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
+ RE_TRANSLATE_TYPE trans,
+- const unsigned char *class_name,
+- const unsigned char *extra,
++ const char *class_name,
++ const char *extra,
+ bool non_match, reg_errcode_t *err);
+ static bin_tree_t *create_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+@@ -293,7 +292,7 @@ weak_alias (__re_compile_fastmap, re_com
+ #endif
+
+ static inline void
+-__attribute ((always_inline))
++__attribute__ ((always_inline))
+ re_set_fastmap (char *fastmap, bool icase, int ch)
+ {
+ fastmap[ch] = 1;
+@@ -587,7 +586,7 @@ weak_alias (__regerror, regerror)
+ static const bitset_t utf8_sb_map =
+ {
+ /* Set the first 128 bits. */
+-# ifdef __GNUC__
++# if defined __GNUC__ && !defined __STRICT_ANSI__
+ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
+ # else
+ # if 4 * BITSET_WORD_BITS < ASCII_CHARS
+@@ -664,7 +663,10 @@ regfree (preg)
+ {
+ re_dfa_t *dfa = preg->buffer;
+ if (BE (dfa != NULL, 1))
+- free_dfa_content (dfa);
++ {
++ lock_fini (dfa->lock);
++ free_dfa_content (dfa);
++ }
+ preg->buffer = NULL;
+ preg->allocated = 0;
+
+@@ -785,6 +787,8 @@ re_compile_internal (regex_t *preg, cons
+ preg->used = sizeof (re_dfa_t);
+
+ err = init_dfa (dfa, length);
++ if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0))
++ err = REG_ESPACE;
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_dfa_content (dfa);
+@@ -798,8 +802,6 @@ re_compile_internal (regex_t *preg, cons
+ strncpy (dfa->re_str, pattern, length + 1);
+ #endif
+
+- __libc_lock_init (dfa->lock);
+-
+ err = re_string_construct (&regexp, pattern, length, preg->translate,
+ (syntax & RE_ICASE) != 0, dfa);
+ if (BE (err != REG_NOERROR, 0))
+@@ -807,6 +809,7 @@ re_compile_internal (regex_t *preg, cons
+ re_compile_internal_free_return:
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
++ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+@@ -839,6 +842,7 @@ re_compile_internal (regex_t *preg, cons
+
+ if (BE (err != REG_NOERROR, 0))
+ {
++ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+@@ -954,10 +958,10 @@ static void
+ internal_function
+ init_word_char (re_dfa_t *dfa)
+ {
+- dfa->word_ops_used = 1;
+ int i = 0;
+ int j;
+ int ch = 0;
++ dfa->word_ops_used = 1;
+ if (BE (dfa->map_notascii == 0, 1))
+ {
+ bitset_word_t bits0 = 0x00000000;
+@@ -2423,8 +2427,8 @@ parse_expression (re_string_t *regexp, r
+ case OP_WORD:
+ case OP_NOTWORD:
+ tree = build_charclass_op (dfa, regexp->trans,
+- (const unsigned char *) "alnum",
+- (const unsigned char *) "_",
++ "alnum",
++ "_",
+ token->type == OP_NOTWORD, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+@@ -2432,8 +2436,8 @@ parse_expression (re_string_t *regexp, r
+ case OP_SPACE:
+ case OP_NOTSPACE:
+ tree = build_charclass_op (dfa, regexp->trans,
+- (const unsigned char *) "space",
+- (const unsigned char *) "",
++ "space",
++ "",
+ token->type == OP_NOTSPACE, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+@@ -2713,7 +2717,6 @@ build_range_exp (const reg_syntax_t synt
+ wchar_t wc;
+ wint_t start_wc;
+ wint_t end_wc;
+- wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+
+ start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+@@ -2727,11 +2730,7 @@ build_range_exp (const reg_syntax_t synt
+ ? __btowc (end_ch) : end_elem->opr.wch);
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
+- cmp_buf[0] = start_wc;
+- cmp_buf[4] = end_wc;
+-
+- if (BE ((syntax & RE_NO_EMPTY_RANGES)
+- && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0))
++ else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+@@ -2772,9 +2771,7 @@ build_range_exp (const reg_syntax_t synt
+ /* Build the table for single byte characters. */
+ for (wc = 0; wc < SBC_MAX; ++wc)
+ {
+- cmp_buf[2] = wc;
+- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
++ if (start_wc <= wc && wc <= end_wc)
+ bitset_set (sbcset, wc);
+ }
+ }
+@@ -2843,40 +2840,29 @@ parse_bracket_exp (re_string_t *regexp,
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Seek the collating symbol entry corresponding to NAME.
+- Return the index of the symbol in the SYMB_TABLE. */
++ Return the index of the symbol in the SYMB_TABLE,
++ or -1 if not found. */
+
+ auto inline int32_t
+- __attribute ((always_inline))
+- seek_collating_symbol_entry (name, name_len)
+- const unsigned char *name;
+- size_t name_len;
+- {
+- int32_t hash = elem_hash ((const char *) name, name_len);
+- int32_t elem = hash % table_size;
+- if (symb_table[2 * elem] != 0)
+- {
+- int32_t second = hash % (table_size - 2) + 1;
+-
+- do
+- {
+- /* First compare the hashing value. */
+- if (symb_table[2 * elem] == hash
+- /* Compare the length of the name. */
+- && name_len == extra[symb_table[2 * elem + 1]]
+- /* Compare the name. */
+- && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
+- name_len) == 0)
+- {
+- /* Yep, this is the entry. */
+- break;
+- }
++ __attribute__ ((always_inline))
++ seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
++ {
++ int32_t elem;
+
+- /* Next entry. */
+- elem += second;
+- }
+- while (symb_table[2 * elem] != 0);
+- }
+- return elem;
++ for (elem = 0; elem < table_size; elem++)
++ if (symb_table[2 * elem] != 0)
++ {
++ int32_t idx = symb_table[2 * elem + 1];
++ /* Skip the name of collating element name. */
++ idx += 1 + extra[idx];
++ if (/* Compare the length of the name. */
++ name_len == extra[idx]
++ /* Compare the name. */
++ && memcmp (name, &extra[idx + 1], name_len) == 0)
++ /* Yep, this is the entry. */
++ return elem;
++ }
++ return -1;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+@@ -2884,9 +2870,8 @@ parse_bracket_exp (re_string_t *regexp,
+ Return the value if succeeded, UINT_MAX otherwise. */
+
+ auto inline unsigned int
+- __attribute ((always_inline))
+- lookup_collation_sequence_value (br_elem)
+- bracket_elem_t *br_elem;
++ __attribute__ ((always_inline))
++ lookup_collation_sequence_value (bracket_elem_t *br_elem)
+ {
+ if (br_elem->type == SB_CHAR)
+ {
+@@ -2914,7 +2899,7 @@ parse_bracket_exp (re_string_t *regexp,
+ int32_t elem, idx;
+ elem = seek_collating_symbol_entry (br_elem->opr.name,
+ sym_name_len);
+- if (symb_table[2 * elem] != 0)
++ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+@@ -2932,7 +2917,7 @@ parse_bracket_exp (re_string_t *regexp,
+ /* Return the collation sequence value. */
+ return *(unsigned int *) (extra + idx);
+ }
+- else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
++ else if (sym_name_len == 1)
+ {
+ /* No valid character. Match it as a single byte
+ character. */
+@@ -2953,12 +2938,9 @@ parse_bracket_exp (re_string_t *regexp,
+ update it. */
+
+ auto inline reg_errcode_t
+- __attribute ((always_inline))
+- build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
+- re_charset_t *mbcset;
+- Idx *range_alloc;
+- bitset_t sbcset;
+- bracket_elem_t *start_elem, *end_elem;
++ __attribute__ ((always_inline))
++ build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
++ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
+ {
+ unsigned int ch;
+ uint32_t start_collseq;
+@@ -2971,6 +2953,7 @@ parse_bracket_exp (re_string_t *regexp,
+ 0))
+ return REG_ERANGE;
+
++ /* FIXME: Implement rational ranges here, too. */
+ start_collseq = lookup_collation_sequence_value (start_elem);
+ end_collseq = lookup_collation_sequence_value (end_elem);
+ /* Check start/end collation sequence values. */
+@@ -3036,26 +3019,23 @@ parse_bracket_exp (re_string_t *regexp,
+ pointer argument since we may update it. */
+
+ auto inline reg_errcode_t
+- __attribute ((always_inline))
+- build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
+- re_charset_t *mbcset;
+- Idx *coll_sym_alloc;
+- bitset_t sbcset;
+- const unsigned char *name;
++ __attribute__ ((always_inline))
++ build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
++ Idx *coll_sym_alloc, const unsigned char *name)
+ {
+ int32_t elem, idx;
+ size_t name_len = strlen ((const char *) name);
+ if (nrules != 0)
+ {
+ elem = seek_collating_symbol_entry (name, name_len);
+- if (symb_table[2 * elem] != 0)
++ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ }
+- else if (symb_table[2 * elem] == 0 && name_len == 1)
++ else if (name_len == 1)
+ {
+ /* No valid character, treat it as a normal
+ character. */
+@@ -3298,7 +3278,8 @@ parse_bracket_exp (re_string_t *regexp,
+ #ifdef RE_ENABLE_I18N
+ mbcset, &char_class_alloc,
+ #endif /* RE_ENABLE_I18N */
+- start_elem.opr.name, syntax);
++ (const char *) start_elem.opr.name,
++ syntax);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ break;
+@@ -3578,14 +3559,14 @@ static reg_errcode_t
+ #ifdef RE_ENABLE_I18N
+ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ re_charset_t *mbcset, Idx *char_class_alloc,
+- const unsigned char *class_name, reg_syntax_t syntax)
++ const char *class_name, reg_syntax_t syntax)
+ #else /* not RE_ENABLE_I18N */
+ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+- const unsigned char *class_name, reg_syntax_t syntax)
++ const char *class_name, reg_syntax_t syntax)
+ #endif /* not RE_ENABLE_I18N */
+ {
+ int i;
+- const char *name = (const char *) class_name;
++ const char *name = class_name;
+
+ /* In case of REG_ICASE "upper" and "lower" match the both of
+ upper and lower cases. */
+@@ -3659,8 +3640,8 @@ build_charclass (RE_TRANSLATE_TYPE trans
+
+ static bin_tree_t *
+ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+- const unsigned char *class_name,
+- const unsigned char *extra, bool non_match,
++ const char *class_name,
++ const char *extra, bool non_match,
+ reg_errcode_t *err)
+ {
+ re_bitset_ptr_t sbcset;
+--- origsrc/sed-4.2.2/lib/regex-quote.c 1970-01-01 01:00:00.000000000 +0100
++++ src/sed-4.2.2/lib/regex-quote.c 2013-06-27 18:05:27.081447884 +0200
+@@ -0,0 +1,216 @@
++/* Construct a regular expression from a literal string.
++ Copyright (C) 1995, 2010-2013 Free Software Foundation, Inc.
++ Written by Bruno Haible <haible@clisp.cons.org>, 2010.
++
++ This program 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 3 of the License, or
++ (at your option) any later version.
++
++ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include <config.h>
++
++/* Specification. */
++#include "regex-quote.h"
++
++#include <string.h>
++
++#include "mbuiter.h"
++#include "xalloc.h"
++
++/* Characters that are special in a BRE. */
++static const char bre_special[] = "$^.*[]\\";
++
++/* Characters that are special in an ERE. */
++static const char ere_special[] = "$^.*[]\\+?{}()|";
++
++struct regex_quote_spec
++regex_quote_spec_posix (int cflags, bool anchored)
++{
++ struct regex_quote_spec result;
++
++ strcpy (result.special, cflags != 0 ? ere_special : bre_special);
++ result.multibyte = true;
++ result.anchored = anchored;
++
++ return result;
++}
++
++/* Syntax bit values, defined in GNU <regex.h>. We don't include it here,
++ otherwise this module would need to depend on gnulib module 'regex'. */
++#define RE_BK_PLUS_QM 0x00000002
++#define RE_INTERVALS 0x00000200
++#define RE_LIMITED_OPS 0x00000400
++#define RE_NEWLINE_ALT 0x00000800
++#define RE_NO_BK_BRACES 0x00001000
++#define RE_NO_BK_PARENS 0x00002000
++#define RE_NO_BK_VBAR 0x00008000
++
++struct regex_quote_spec
++regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored)
++{
++ struct regex_quote_spec result;
++ char *p;
++
++ p = result.special;
++ memcpy (p, bre_special, sizeof (bre_special) - 1);
++ p += sizeof (bre_special) - 1;
++ if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_BK_PLUS_QM) == 0)
++ {
++ *p++ = '+';
++ *p++ = '?';
++ }
++ if ((syntax & RE_INTERVALS) != 0 && (syntax & RE_NO_BK_BRACES) != 0)
++ {
++ *p++ = '{';
++ *p++ = '}';
++ }
++ if ((syntax & RE_NO_BK_PARENS) != 0)
++ {
++ *p++ = '(';
++ *p++ = ')';
++ }
++ if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_NO_BK_VBAR) != 0)
++ *p++ = '|';
++ if ((syntax & RE_NEWLINE_ALT) != 0)
++ *p++ = '\n';
++ *p = '\0';
++
++ result.multibyte = true;
++ result.anchored = anchored;
++
++ return result;
++}
++
++/* Characters that are special in a PCRE. */
++static const char pcre_special[] = "$^.*[]\\+?{}()|";
++
++/* Options bit values, defined in <pcre.h>. We don't include it here, because
++ it is not a standard header. */
++#define PCRE_ANCHORED 0x00000010
++#define PCRE_EXTENDED 0x00000008
++
++struct regex_quote_spec
++regex_quote_spec_pcre (int options, bool anchored)
++{
++ struct regex_quote_spec result;
++ char *p;
++
++ p = result.special;
++ memcpy (p, bre_special, sizeof (pcre_special) - 1);
++ p += sizeof (pcre_special) - 1;
++ if (options & PCRE_EXTENDED)
++ {
++ *p++ = ' ';
++ *p++ = '\t';
++ *p++ = '\n';
++ *p++ = '\v';
++ *p++ = '\f';
++ *p++ = '\r';
++ *p++ = '#';
++ }
++ *p = '\0';
++
++ /* PCRE regular expressions consist of UTF-8 characters of options contains
++ PCRE_UTF8 and of single bytes otherwise. */
++ result.multibyte = false;
++ /* If options contains PCRE_ANCHORED, the anchoring is implicit. */
++ result.anchored = (options & PCRE_ANCHORED ? 0 : anchored);
++
++ return result;
++}
++
++size_t
++regex_quote_length (const char *string, const struct regex_quote_spec *spec)
++{
++ const char *special = spec->special;
++ size_t length;
++
++ length = 0;
++ if (spec->anchored)
++ length += 2; /* for '^' at the beginning and '$' at the end */
++ if (spec->multibyte)
++ {
++ mbui_iterator_t iter;
++
++ for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
++ {
++ /* We know that special contains only ASCII characters. */
++ if (mb_len (mbui_cur (iter)) == 1
++ && strchr (special, * mbui_cur_ptr (iter)))
++ length += 1;
++ length += mb_len (mbui_cur (iter));
++ }
++ }
++ else
++ {
++ const char *iter;
++
++ for (iter = string; *iter != '\0'; iter++)
++ {
++ if (strchr (special, *iter))
++ length += 1;
++ length += 1;
++ }
++ }
++
++ return length;
++}
++
++char *
++regex_quote_copy (char *p, const char *string, const struct regex_quote_spec *spec)
++{
++ const char *special = spec->special;
++
++ if (spec->anchored)
++ *p++ = '^';
++ if (spec->multibyte)
++ {
++ mbui_iterator_t iter;
++
++ for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
++ {
++ /* We know that special contains only ASCII characters. */
++ if (mb_len (mbui_cur (iter)) == 1
++ && strchr (special, * mbui_cur_ptr (iter)))
++ *p++ = '\\';
++ memcpy (p, mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
++ p += mb_len (mbui_cur (iter));
++ }
++ }
++ else
++ {
++ const char *iter;
++
++ for (iter = string; *iter != '\0'; iter++)
++ {
++ if (strchr (special, *iter))
++ *p++ = '\\';
++ *p++ = *iter++;
++ }
++ }
++ if (spec->anchored)
++ *p++ = '$';
++
++ return p;
++}
++
++char *
++regex_quote (const char *string, const struct regex_quote_spec *spec)
++{
++ size_t length = regex_quote_length (string, spec);
++ char *result = XNMALLOC (length + 1, char);
++ char *p;
++
++ p = result;
++ p = regex_quote_copy (p, string, spec);
++ *p = '\0';
++ return result;
++}
+--- origsrc/sed-4.2.2/lib/regex-quote.h 1970-01-01 01:00:00.000000000 +0100
++++ src/sed-4.2.2/lib/regex-quote.h 2013-06-27 18:05:27.112447751 +0200
+@@ -0,0 +1,88 @@
++/* Construct a regular expression from a literal string.
++ Copyright (C) 1995, 2010-2013 Free Software Foundation, Inc.
++ Written by Bruno Haible <haible@clisp.cons.org>, 2010.
++
++ This program 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 3 of the License, or
++ (at your option) any later version.
++
++ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#ifndef _REGEX_QUOTE_H
++#define _REGEX_QUOTE_H
++
++#include <stddef.h>
++#include <stdbool.h>
++
++
++/* Specifies a quotation task for converting a fixed string to a regular
++ expression pattern. */
++struct regex_quote_spec
++{
++ /* True if the regular expression pattern consists of multibyte characters
++ (in the encoding given by the LC_CTYPE category of the locale),
++ false if it consists of single bytes or UTF-8 characters. */
++ unsigned int /*bool*/ multibyte : 1;
++ /* True if the regular expression pattern shall match only entire lines. */
++ unsigned int /*bool*/ anchored : 1;
++ /* Set of characters that need to be escaped (all ASCII), as a
++ NUL-terminated string. */
++ char special[30 + 1];
++};
++
++
++/* Creates a quotation task that produces a POSIX regular expression, that is,
++ a pattern that can be compiled with regcomp().
++ CFLAGS can be 0 or REG_EXTENDED.
++ If it is 0, the result is a Basic Regular Expression (BRE)
++ <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03>.
++ If it is REG_EXTENDED, the result is an Extended Regular Expression (ERE)
++ <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04>.
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_posix (int cflags, bool anchored);
++
++/* Creates a quotation task that produces a regular expression that can be
++ compiled with the GNU API function re_compile_pattern().
++ SYNTAX describes the syntax of the regular expression (such as
++ RE_SYNTAX_POSIX_BASIC, RE_SYNTAX_POSIX_EXTENDED, RE_SYNTAX_EMACS, all
++ defined in <regex.h>). It must be the same value as 're_syntax_options'
++ at the moment of the re_compile_pattern() call.
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored);
++
++/* Creates a quotation task that produces a PCRE regular expression, that is,
++ a pattern that can be compiled with pcre_compile().
++ OPTIONS is the same value as the second argument passed to pcre_compile().
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_pcre (int options, bool anchored);
++
++
++/* Returns the number of bytes needed for the quoted string. */
++extern size_t
++ regex_quote_length (const char *string, const struct regex_quote_spec *spec);
++
++/* Copies the quoted string to p and returns the incremented p.
++ There must be room for regex_quote_length (string, spec) + 1 bytes at p. */
++extern char *
++ regex_quote_copy (char *p,
++ const char *string, const struct regex_quote_spec *spec);
++
++/* Returns the freshly allocated quoted string. */
++extern char *
++ regex_quote (const char *string, const struct regex_quote_spec *spec);
++
++
++#endif /* _REGEX_QUOTE_H */
+--- origsrc/sed-4.2.2/lib/regex.c 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regex.c 2013-06-27 18:05:27.138447639 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _LIBC
+ # include <config.h>
+@@ -25,6 +24,7 @@
+ # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+ # endif
+ # if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
++# pragma GCC diagnostic ignored "-Wold-style-definition"
+ # pragma GCC diagnostic ignored "-Wtype-limits"
+ # endif
+ #endif
+--- origsrc/sed-4.2.2/lib/regex.h 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regex.h 2013-06-27 18:05:27.168447509 +0200
+@@ -1,23 +1,22 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Definitions for data structures and routines for the regular
+ expression library.
+- Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2012
+- Free Software Foundation, Inc.
++ Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software
++ Foundation, Inc.
+ This file is part of the GNU C Library.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _REGEX_H
+ #define _REGEX_H 1
+--- origsrc/sed-4.2.2/lib/regex_internal.c 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regex_internal.c 2013-06-27 18:05:27.199447375 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static void re_string_construct_common (const char *str, Idx len,
+ re_string_t *pstr,
+@@ -835,7 +834,7 @@ re_string_reconstruct (re_string_t *pstr
+ }
+
+ static unsigned char
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
+ {
+ int ch;
+@@ -975,7 +974,7 @@ re_node_set_alloc (re_node_set *set, Idx
+ set->alloc = size;
+ set->nelem = 0;
+ set->elems = re_malloc (Idx, size);
+- if (BE (set->elems == NULL, 0))
++ if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
+ return REG_ESPACE;
+ return REG_NOERROR;
+ }
+@@ -1355,7 +1354,7 @@ re_node_set_insert_last (re_node_set *se
+ Return true if SET1 and SET2 are equivalent. */
+
+ static bool
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
+ {
+ Idx i;
+@@ -1370,7 +1369,7 @@ re_node_set_compare (const re_node_set *
+ /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
+
+ static Idx
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_node_set_contains (const re_node_set *set, Idx elem)
+ {
+ __re_size_t idx, right, mid;
+@@ -1444,11 +1443,9 @@ re_dfa_add_node (re_dfa_t *dfa, re_token
+ dfa->nodes[dfa->nodes_len] = token;
+ dfa->nodes[dfa->nodes_len].constraint = 0;
+ #ifdef RE_ENABLE_I18N
+- {
+- int type = token.type;
+ dfa->nodes[dfa->nodes_len].accept_mb =
+- (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
+- }
++ ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
++ || token.type == COMPLEX_BRACKET);
+ #endif
+ dfa->nexts[dfa->nodes_len] = REG_MISSING;
+ re_node_set_init_empty (dfa->edests + dfa->nodes_len);
+--- origsrc/sed-4.2.2/lib/regex_internal.h 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regex_internal.h 2013-06-27 18:05:27.230447242 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _REGEX_INTERNAL_H
+ #define _REGEX_INTERNAL_H 1
+@@ -28,21 +27,54 @@
+ #include <string.h>
+
+ #include <langinfo.h>
+-#ifndef _LIBC
+-# include "localcharset.h"
+-#endif
+ #include <locale.h>
+ #include <wchar.h>
+ #include <wctype.h>
+ #include <stdbool.h>
+ #include <stdint.h>
+-#if defined _LIBC
++
++#ifdef _LIBC
+ # include <bits/libc-lock.h>
++# define lock_define(name) __libc_lock_define (, name)
++# define lock_init(lock) (__libc_lock_init (lock), 0)
++# define lock_fini(lock) 0
++# define lock_lock(lock) __libc_lock_lock (lock)
++# define lock_unlock(lock) __libc_lock_unlock (lock)
++#elif defined GNULIB_LOCK
++# include "glthread/lock.h"
++ /* Use gl_lock_define if empty macro arguments are known to work.
++ Otherwise, fall back on less-portable substitutes. */
++# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
++ || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
++# define lock_define(name) gl_lock_define (, name)
++# elif USE_POSIX_THREADS
++# define lock_define(name) pthread_mutex_t name;
++# elif USE_PTH_THREADS
++# define lock_define(name) pth_mutex_t name;
++# elif USE_SOLARIS_THREADS
++# define lock_define(name) mutex_t name;
++# elif USE_WINDOWS_THREADS
++# define lock_define(name) gl_lock_t name;
++# else
++# define lock_define(name)
++# endif
++# define lock_init(lock) glthread_lock_init (&(lock))
++# define lock_fini(lock) glthread_lock_destroy (&(lock))
++# define lock_lock(lock) glthread_lock_lock (&(lock))
++# define lock_unlock(lock) glthread_lock_unlock (&(lock))
++#elif defined GNULIB_PTHREAD
++# include <pthread.h>
++# define lock_define(name) pthread_mutex_t name;
++# define lock_init(lock) pthread_mutex_init (&(lock), 0)
++# define lock_fini(lock) pthread_mutex_destroy (&(lock))
++# define lock_lock(lock) pthread_mutex_lock (&(lock))
++# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
+ #else
+-# define __libc_lock_define(CLASS,NAME)
+-# define __libc_lock_init(NAME) do { } while (0)
+-# define __libc_lock_lock(NAME) do { } while (0)
+-# define __libc_lock_unlock(NAME) do { } while (0)
++# define lock_define(name)
++# define lock_init(lock) 0
++# define lock_fini(lock) 0
++# define lock_lock(lock) ((void) 0)
++# define lock_unlock(lock) ((void) 0)
+ #endif
+
+ /* In case that the system doesn't have isblank(). */
+@@ -65,7 +97,7 @@
+ # ifdef _LIBC
+ # undef gettext
+ # define gettext(msgid) \
+- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
++ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
+ # endif
+ #else
+ # define gettext(msgid) (msgid)
+@@ -101,6 +133,8 @@
+
+ /* Rename to standard API for using out of glibc. */
+ #ifndef _LIBC
++# undef __wctype
++# undef __iswctype
+ # define __wctype wctype
+ # define __iswctype iswctype
+ # define __btowc btowc
+@@ -110,10 +144,8 @@
+ # define attribute_hidden
+ #endif /* not _LIBC */
+
+-#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+-# define __attribute(arg) __attribute__ (arg)
+-#else
+-# define __attribute(arg)
++#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
++# define __attribute__(arg)
+ #endif
+
+ typedef __re_idx_t Idx;
+@@ -429,7 +461,7 @@ static void build_upper_buffer (re_strin
+ static void re_string_translate_buffer (re_string_t *pstr) internal_function;
+ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
+ int eflags)
+- internal_function __attribute ((pure));
++ internal_function __attribute__ ((pure));
+ #endif
+ #define re_string_peek_byte(pstr, offset) \
+ ((pstr)->mbs[(pstr)->cur_idx + offset])
+@@ -448,7 +480,9 @@ static unsigned int re_string_context_at
+ #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+ #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
+-#include <alloca.h>
++#if defined _LIBC || HAVE_ALLOCA
++# include <alloca.h>
++#endif
+
+ #ifndef _LIBC
+ # if HAVE_ALLOCA
+@@ -465,6 +499,12 @@ static unsigned int re_string_context_at
+ # endif
+ #endif
+
++#ifdef _LIBC
++# define MALLOC_0_IS_NONNULL 1
++#elif !defined MALLOC_0_IS_NONNULL
++# define MALLOC_0_IS_NONNULL 0
++#endif
++
+ #ifndef MAX
+ # define MAX(a,b) ((a) < (b) ? (b) : (a))
+ #endif
+@@ -695,7 +735,7 @@ struct re_dfa_t
+ #ifdef DEBUG
+ char* re_str;
+ #endif
+- __libc_lock_define (, lock)
++ lock_define (lock)
+ };
+
+ #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
+@@ -767,7 +807,7 @@ bitset_copy (bitset_t dest, const bitset
+ memcpy (dest, src, sizeof (bitset_t));
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_not (bitset_t set)
+ {
+ int bitset_i;
+@@ -779,7 +819,7 @@ bitset_not (bitset_t set)
+ & ~set[BITSET_WORDS - 1]);
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_merge (bitset_t dest, const bitset_t src)
+ {
+ int bitset_i;
+@@ -787,7 +827,7 @@ bitset_merge (bitset_t dest, const bitse
+ dest[bitset_i] |= src[bitset_i];
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_mask (bitset_t dest, const bitset_t src)
+ {
+ int bitset_i;
+@@ -798,7 +838,7 @@ bitset_mask (bitset_t dest, const bitset
+ #ifdef RE_ENABLE_I18N
+ /* Functions for re_string. */
+ static int
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_char_size_at (const re_string_t *pstr, Idx idx)
+ {
+ int byte_idx;
+@@ -811,7 +851,7 @@ re_string_char_size_at (const re_string_
+ }
+
+ static wint_t
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_wchar_at (const re_string_t *pstr, Idx idx)
+ {
+ if (pstr->mb_cur_max == 1)
+@@ -821,7 +861,7 @@ re_string_wchar_at (const re_string_t *p
+
+ # ifndef NOT_IN_libc
+ static int
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+ {
+ # ifdef _LIBC
+--- origsrc/sed-4.2.2/lib/regexec.c 2012-12-22 14:21:52.000000000 +0100
++++ src/sed-4.2.2/lib/regexec.c 2013-06-27 18:05:27.268447078 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
+ Idx n) internal_function;
+@@ -200,7 +199,7 @@ static Idx group_nodes_into_DFAstates (c
+ static bool check_node_accept (const re_match_context_t *mctx,
+ const re_token_t *node, Idx idx)
+ internal_function;
+-static reg_errcode_t extend_buffers (re_match_context_t *mctx)
++static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
+ internal_function;
+
+ /* Entry point for POSIX code. */
+@@ -229,9 +228,7 @@ regexec (preg, string, nmatch, pmatch, e
+ {
+ reg_errcode_t err;
+ Idx start, length;
+-#ifdef _LIBC
+ re_dfa_t *dfa = preg->buffer;
+-#endif
+
+ if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+ return REG_BADPAT;
+@@ -247,14 +244,14 @@ regexec (preg, string, nmatch, pmatch, e
+ length = strlen (string);
+ }
+
+- __libc_lock_lock (dfa->lock);
++ lock_lock (dfa->lock);
+ if (preg->no_sub)
+ err = re_search_internal (preg, string, length, start, length,
+ length, 0, NULL, eflags);
+ else
+ err = re_search_internal (preg, string, length, start, length,
+ length, nmatch, pmatch, eflags);
+- __libc_lock_unlock (dfa->lock);
++ lock_unlock (dfa->lock);
+ return err != REG_NOERROR;
+ }
+
+@@ -422,9 +419,7 @@ re_search_stub (struct re_pattern_buffer
+ Idx nregs;
+ regoff_t rval;
+ int eflags = 0;
+-#ifdef _LIBC
+ re_dfa_t *dfa = bufp->buffer;
+-#endif
+ Idx last_start = start + range;
+
+ /* Check for out-of-range. */
+@@ -435,7 +430,7 @@ re_search_stub (struct re_pattern_buffer
+ else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+ last_start = 0;
+
+- __libc_lock_lock (dfa->lock);
++ lock_lock (dfa->lock);
+
+ eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
+ eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+@@ -499,7 +494,7 @@ re_search_stub (struct re_pattern_buffer
+ }
+ re_free (pmatch);
+ out:
+- __libc_lock_unlock (dfa->lock);
++ lock_unlock (dfa->lock);
+ return rval;
+ }
+
+@@ -1065,7 +1060,7 @@ prune_impossible_nodes (re_match_context
+ since initial states may have constraints like "\<", "^", etc.. */
+
+ static inline re_dfastate_t *
+-__attribute ((always_inline)) internal_function
++__attribute__ ((always_inline)) internal_function
+ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+ Idx idx)
+ {
+@@ -1177,7 +1172,7 @@ check_matching (re_match_context_t *mctx
+ || (BE (next_char_idx >= mctx->input.valid_len, 0)
+ && mctx->input.valid_len < mctx->input.len))
+ {
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, next_char_idx + 1);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ assert (err == REG_ESPACE);
+@@ -1757,7 +1752,7 @@ clean_state_log_if_needed (re_match_cont
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ reg_errcode_t err;
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, next_state_log_idx + 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+@@ -2814,7 +2809,7 @@ get_subexp (re_match_context_t *mctx, Id
+ if (bkref_str_off >= mctx->input.len)
+ break;
+
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, bkref_str_off + 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+@@ -3937,6 +3932,7 @@ check_node_accept_bytes (const re_dfa_t
+ in_collseq = find_collation_sequence_value (pin, elem_len);
+ }
+ /* match with range expression? */
++ /* FIXME: Implement rational ranges here, too. */
+ for (i = 0; i < cset->nranges; ++i)
+ if (cset->range_starts[i] <= in_collseq
+ && in_collseq <= cset->range_ends[i])
+@@ -3988,18 +3984,9 @@ check_node_accept_bytes (const re_dfa_t
+ # endif /* _LIBC */
+ {
+ /* match with range expression? */
+-#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined __STRICT_ANSI__)
+- wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
+-#else
+- wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+- cmp_buf[2] = wc;
+-#endif
+ for (i = 0; i < cset->nranges; ++i)
+ {
+- cmp_buf[0] = cset->range_starts[i];
+- cmp_buf[4] = cset->range_ends[i];
+- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
++ if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+@@ -4137,7 +4124,7 @@ check_node_accept (const re_match_contex
+
+ static reg_errcode_t
+ internal_function __attribute_warn_unused_result__
+-extend_buffers (re_match_context_t *mctx)
++extend_buffers (re_match_context_t *mctx, int min_len)
+ {
+ reg_errcode_t ret;
+ re_string_t *pstr = &mctx->input;
+@@ -4147,8 +4134,10 @@ extend_buffers (re_match_context_t *mctx
+ <= pstr->bufs_len, 0))
+ return REG_ESPACE;
+
+- /* Double the lengths of the buffers. */
+- ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2));
++ /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
++ ret = re_string_realloc_buffers (pstr,
++ MAX (min_len,
++ MIN (pstr->len, pstr->bufs_len * 2)));
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+
+--- origsrc/sed-4.2.2/sed/sed.c 2012-03-16 10:13:31.000000000 +0100
++++ src/sed-4.2.2/sed/sed.c 2013-06-27 18:06:25.592195456 +0200
+@@ -57,7 +57,11 @@ bool follow_symlinks = false;
+ char *in_place_extension = NULL;
+
+ /* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
++#ifdef HAVE_FOPEN_RT
++char *read_mode = "rt";
++#else
+ char *read_mode = "r";
++#endif
+ char *write_mode = "w";
+
+ /* Do we need to be pedantically POSIX compliant? */
diff --git a/dev/build/windows/patches_coq/sed-4.2.2.patch b/dev/build/windows/patches_coq/sed-4.2.2.patch
new file mode 100755
index 00000000..c7ccd53c
--- /dev/null
+++ b/dev/build/windows/patches_coq/sed-4.2.2.patch
@@ -0,0 +1,1301 @@
+--- origsrc/doc/sed.1 2012-12-22 15:27:13.000000000 +0100
++++ src/doc/sed.1 2013-06-27 18:10:47.974060492 +0200
+@@ -1,5 +1,5 @@
+ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
+-.TH SED "1" "December 2012" "sed 4.2.2" "User Commands"
++.TH SED "1" "June 2013" "sed 4.2.2" "User Commands"
+ .SH NAME
+ sed \- stream editor for filtering and transforming text
+ .SH SYNOPSIS
+@@ -40,6 +40,10 @@ follow symlinks when processing in place
+ .IP
+ edit files in place (makes backup if SUFFIX supplied)
+ .HP
++\fB\-b\fR, \fB\-\-binary\fR
++.IP
++open files in binary mode (CR+LFs are not processed specially)
++.HP
+ \fB\-l\fR N, \fB\-\-line\-length\fR=\fIN\fR
+ .IP
+ specify the desired line-wrap length for the `l' command
+--- origsrc/lib/regcomp.c 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regcomp.c 2013-06-27 18:05:27.044448044 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
+ size_t length, reg_syntax_t syntax);
+@@ -95,20 +94,20 @@ static reg_errcode_t build_charclass (RE
+ bitset_t sbcset,
+ re_charset_t *mbcset,
+ Idx *char_class_alloc,
+- const unsigned char *class_name,
++ const char *class_name,
+ reg_syntax_t syntax);
+ #else /* not RE_ENABLE_I18N */
+ static reg_errcode_t build_equiv_class (bitset_t sbcset,
+ const unsigned char *name);
+ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+ bitset_t sbcset,
+- const unsigned char *class_name,
++ const char *class_name,
+ reg_syntax_t syntax);
+ #endif /* not RE_ENABLE_I18N */
+ static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
+ RE_TRANSLATE_TYPE trans,
+- const unsigned char *class_name,
+- const unsigned char *extra,
++ const char *class_name,
++ const char *extra,
+ bool non_match, reg_errcode_t *err);
+ static bin_tree_t *create_tree (re_dfa_t *dfa,
+ bin_tree_t *left, bin_tree_t *right,
+@@ -293,7 +292,7 @@ weak_alias (__re_compile_fastmap, re_com
+ #endif
+
+ static inline void
+-__attribute ((always_inline))
++__attribute__ ((always_inline))
+ re_set_fastmap (char *fastmap, bool icase, int ch)
+ {
+ fastmap[ch] = 1;
+@@ -587,7 +586,7 @@ weak_alias (__regerror, regerror)
+ static const bitset_t utf8_sb_map =
+ {
+ /* Set the first 128 bits. */
+-# ifdef __GNUC__
++# if defined __GNUC__ && !defined __STRICT_ANSI__
+ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
+ # else
+ # if 4 * BITSET_WORD_BITS < ASCII_CHARS
+@@ -664,7 +663,10 @@ regfree (preg)
+ {
+ re_dfa_t *dfa = preg->buffer;
+ if (BE (dfa != NULL, 1))
+- free_dfa_content (dfa);
++ {
++ lock_fini (dfa->lock);
++ free_dfa_content (dfa);
++ }
+ preg->buffer = NULL;
+ preg->allocated = 0;
+
+@@ -785,6 +787,8 @@ re_compile_internal (regex_t *preg, cons
+ preg->used = sizeof (re_dfa_t);
+
+ err = init_dfa (dfa, length);
++ if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0))
++ err = REG_ESPACE;
+ if (BE (err != REG_NOERROR, 0))
+ {
+ free_dfa_content (dfa);
+@@ -798,8 +802,6 @@ re_compile_internal (regex_t *preg, cons
+ strncpy (dfa->re_str, pattern, length + 1);
+ #endif
+
+- __libc_lock_init (dfa->lock);
+-
+ err = re_string_construct (&regexp, pattern, length, preg->translate,
+ (syntax & RE_ICASE) != 0, dfa);
+ if (BE (err != REG_NOERROR, 0))
+@@ -807,6 +809,7 @@ re_compile_internal (regex_t *preg, cons
+ re_compile_internal_free_return:
+ free_workarea_compile (preg);
+ re_string_destruct (&regexp);
++ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+@@ -839,6 +842,7 @@ re_compile_internal (regex_t *preg, cons
+
+ if (BE (err != REG_NOERROR, 0))
+ {
++ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ preg->buffer = NULL;
+ preg->allocated = 0;
+@@ -954,10 +958,10 @@ static void
+ internal_function
+ init_word_char (re_dfa_t *dfa)
+ {
+- dfa->word_ops_used = 1;
+ int i = 0;
+ int j;
+ int ch = 0;
++ dfa->word_ops_used = 1;
+ if (BE (dfa->map_notascii == 0, 1))
+ {
+ bitset_word_t bits0 = 0x00000000;
+@@ -2423,8 +2427,8 @@ parse_expression (re_string_t *regexp, r
+ case OP_WORD:
+ case OP_NOTWORD:
+ tree = build_charclass_op (dfa, regexp->trans,
+- (const unsigned char *) "alnum",
+- (const unsigned char *) "_",
++ "alnum",
++ "_",
+ token->type == OP_NOTWORD, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+@@ -2432,8 +2436,8 @@ parse_expression (re_string_t *regexp, r
+ case OP_SPACE:
+ case OP_NOTSPACE:
+ tree = build_charclass_op (dfa, regexp->trans,
+- (const unsigned char *) "space",
+- (const unsigned char *) "",
++ "space",
++ "",
+ token->type == OP_NOTSPACE, err);
+ if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ return NULL;
+@@ -2713,7 +2717,6 @@ build_range_exp (const reg_syntax_t synt
+ wchar_t wc;
+ wint_t start_wc;
+ wint_t end_wc;
+- wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+
+ start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
+ : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+@@ -2727,11 +2730,7 @@ build_range_exp (const reg_syntax_t synt
+ ? __btowc (end_ch) : end_elem->opr.wch);
+ if (start_wc == WEOF || end_wc == WEOF)
+ return REG_ECOLLATE;
+- cmp_buf[0] = start_wc;
+- cmp_buf[4] = end_wc;
+-
+- if (BE ((syntax & RE_NO_EMPTY_RANGES)
+- && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0))
++ else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
+ return REG_ERANGE;
+
+ /* Got valid collation sequence values, add them as a new entry.
+@@ -2772,9 +2771,7 @@ build_range_exp (const reg_syntax_t synt
+ /* Build the table for single byte characters. */
+ for (wc = 0; wc < SBC_MAX; ++wc)
+ {
+- cmp_buf[2] = wc;
+- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
++ if (start_wc <= wc && wc <= end_wc)
+ bitset_set (sbcset, wc);
+ }
+ }
+@@ -2843,40 +2840,29 @@ parse_bracket_exp (re_string_t *regexp,
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+ Seek the collating symbol entry corresponding to NAME.
+- Return the index of the symbol in the SYMB_TABLE. */
++ Return the index of the symbol in the SYMB_TABLE,
++ or -1 if not found. */
+
+ auto inline int32_t
+- __attribute ((always_inline))
+- seek_collating_symbol_entry (name, name_len)
+- const unsigned char *name;
+- size_t name_len;
+- {
+- int32_t hash = elem_hash ((const char *) name, name_len);
+- int32_t elem = hash % table_size;
+- if (symb_table[2 * elem] != 0)
+- {
+- int32_t second = hash % (table_size - 2) + 1;
+-
+- do
+- {
+- /* First compare the hashing value. */
+- if (symb_table[2 * elem] == hash
+- /* Compare the length of the name. */
+- && name_len == extra[symb_table[2 * elem + 1]]
+- /* Compare the name. */
+- && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
+- name_len) == 0)
+- {
+- /* Yep, this is the entry. */
+- break;
+- }
++ __attribute__ ((always_inline))
++ seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
++ {
++ int32_t elem;
+
+- /* Next entry. */
+- elem += second;
+- }
+- while (symb_table[2 * elem] != 0);
+- }
+- return elem;
++ for (elem = 0; elem < table_size; elem++)
++ if (symb_table[2 * elem] != 0)
++ {
++ int32_t idx = symb_table[2 * elem + 1];
++ /* Skip the name of collating element name. */
++ idx += 1 + extra[idx];
++ if (/* Compare the length of the name. */
++ name_len == extra[idx]
++ /* Compare the name. */
++ && memcmp (name, &extra[idx + 1], name_len) == 0)
++ /* Yep, this is the entry. */
++ return elem;
++ }
++ return -1;
+ }
+
+ /* Local function for parse_bracket_exp used in _LIBC environment.
+@@ -2884,9 +2870,8 @@ parse_bracket_exp (re_string_t *regexp,
+ Return the value if succeeded, UINT_MAX otherwise. */
+
+ auto inline unsigned int
+- __attribute ((always_inline))
+- lookup_collation_sequence_value (br_elem)
+- bracket_elem_t *br_elem;
++ __attribute__ ((always_inline))
++ lookup_collation_sequence_value (bracket_elem_t *br_elem)
+ {
+ if (br_elem->type == SB_CHAR)
+ {
+@@ -2914,7 +2899,7 @@ parse_bracket_exp (re_string_t *regexp,
+ int32_t elem, idx;
+ elem = seek_collating_symbol_entry (br_elem->opr.name,
+ sym_name_len);
+- if (symb_table[2 * elem] != 0)
++ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+@@ -2932,7 +2917,7 @@ parse_bracket_exp (re_string_t *regexp,
+ /* Return the collation sequence value. */
+ return *(unsigned int *) (extra + idx);
+ }
+- else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
++ else if (sym_name_len == 1)
+ {
+ /* No valid character. Match it as a single byte
+ character. */
+@@ -2953,12 +2938,9 @@ parse_bracket_exp (re_string_t *regexp,
+ update it. */
+
+ auto inline reg_errcode_t
+- __attribute ((always_inline))
+- build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
+- re_charset_t *mbcset;
+- Idx *range_alloc;
+- bitset_t sbcset;
+- bracket_elem_t *start_elem, *end_elem;
++ __attribute__ ((always_inline))
++ build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
++ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
+ {
+ unsigned int ch;
+ uint32_t start_collseq;
+@@ -2971,6 +2953,7 @@ parse_bracket_exp (re_string_t *regexp,
+ 0))
+ return REG_ERANGE;
+
++ /* FIXME: Implement rational ranges here, too. */
+ start_collseq = lookup_collation_sequence_value (start_elem);
+ end_collseq = lookup_collation_sequence_value (end_elem);
+ /* Check start/end collation sequence values. */
+@@ -3036,26 +3019,23 @@ parse_bracket_exp (re_string_t *regexp,
+ pointer argument since we may update it. */
+
+ auto inline reg_errcode_t
+- __attribute ((always_inline))
+- build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
+- re_charset_t *mbcset;
+- Idx *coll_sym_alloc;
+- bitset_t sbcset;
+- const unsigned char *name;
++ __attribute__ ((always_inline))
++ build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
++ Idx *coll_sym_alloc, const unsigned char *name)
+ {
+ int32_t elem, idx;
+ size_t name_len = strlen ((const char *) name);
+ if (nrules != 0)
+ {
+ elem = seek_collating_symbol_entry (name, name_len);
+- if (symb_table[2 * elem] != 0)
++ if (elem != -1)
+ {
+ /* We found the entry. */
+ idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ }
+- else if (symb_table[2 * elem] == 0 && name_len == 1)
++ else if (name_len == 1)
+ {
+ /* No valid character, treat it as a normal
+ character. */
+@@ -3298,7 +3278,8 @@ parse_bracket_exp (re_string_t *regexp,
+ #ifdef RE_ENABLE_I18N
+ mbcset, &char_class_alloc,
+ #endif /* RE_ENABLE_I18N */
+- start_elem.opr.name, syntax);
++ (const char *) start_elem.opr.name,
++ syntax);
+ if (BE (*err != REG_NOERROR, 0))
+ goto parse_bracket_exp_free_return;
+ break;
+@@ -3578,14 +3559,14 @@ static reg_errcode_t
+ #ifdef RE_ENABLE_I18N
+ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+ re_charset_t *mbcset, Idx *char_class_alloc,
+- const unsigned char *class_name, reg_syntax_t syntax)
++ const char *class_name, reg_syntax_t syntax)
+ #else /* not RE_ENABLE_I18N */
+ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+- const unsigned char *class_name, reg_syntax_t syntax)
++ const char *class_name, reg_syntax_t syntax)
+ #endif /* not RE_ENABLE_I18N */
+ {
+ int i;
+- const char *name = (const char *) class_name;
++ const char *name = class_name;
+
+ /* In case of REG_ICASE "upper" and "lower" match the both of
+ upper and lower cases. */
+@@ -3659,8 +3640,8 @@ build_charclass (RE_TRANSLATE_TYPE trans
+
+ static bin_tree_t *
+ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+- const unsigned char *class_name,
+- const unsigned char *extra, bool non_match,
++ const char *class_name,
++ const char *extra, bool non_match,
+ reg_errcode_t *err)
+ {
+ re_bitset_ptr_t sbcset;
+--- origsrc/lib/regex-quote.c 1970-01-01 01:00:00.000000000 +0100
++++ src/lib/regex-quote.c 2013-06-27 18:05:27.081447884 +0200
+@@ -0,0 +1,216 @@
++/* Construct a regular expression from a literal string.
++ Copyright (C) 1995, 2010-2013 Free Software Foundation, Inc.
++ Written by Bruno Haible <haible@clisp.cons.org>, 2010.
++
++ This program 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 3 of the License, or
++ (at your option) any later version.
++
++ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include <config.h>
++
++/* Specification. */
++#include "regex-quote.h"
++
++#include <string.h>
++
++#include "mbuiter.h"
++#include "xalloc.h"
++
++/* Characters that are special in a BRE. */
++static const char bre_special[] = "$^.*[]\\";
++
++/* Characters that are special in an ERE. */
++static const char ere_special[] = "$^.*[]\\+?{}()|";
++
++struct regex_quote_spec
++regex_quote_spec_posix (int cflags, bool anchored)
++{
++ struct regex_quote_spec result;
++
++ strcpy (result.special, cflags != 0 ? ere_special : bre_special);
++ result.multibyte = true;
++ result.anchored = anchored;
++
++ return result;
++}
++
++/* Syntax bit values, defined in GNU <regex.h>. We don't include it here,
++ otherwise this module would need to depend on gnulib module 'regex'. */
++#define RE_BK_PLUS_QM 0x00000002
++#define RE_INTERVALS 0x00000200
++#define RE_LIMITED_OPS 0x00000400
++#define RE_NEWLINE_ALT 0x00000800
++#define RE_NO_BK_BRACES 0x00001000
++#define RE_NO_BK_PARENS 0x00002000
++#define RE_NO_BK_VBAR 0x00008000
++
++struct regex_quote_spec
++regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored)
++{
++ struct regex_quote_spec result;
++ char *p;
++
++ p = result.special;
++ memcpy (p, bre_special, sizeof (bre_special) - 1);
++ p += sizeof (bre_special) - 1;
++ if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_BK_PLUS_QM) == 0)
++ {
++ *p++ = '+';
++ *p++ = '?';
++ }
++ if ((syntax & RE_INTERVALS) != 0 && (syntax & RE_NO_BK_BRACES) != 0)
++ {
++ *p++ = '{';
++ *p++ = '}';
++ }
++ if ((syntax & RE_NO_BK_PARENS) != 0)
++ {
++ *p++ = '(';
++ *p++ = ')';
++ }
++ if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_NO_BK_VBAR) != 0)
++ *p++ = '|';
++ if ((syntax & RE_NEWLINE_ALT) != 0)
++ *p++ = '\n';
++ *p = '\0';
++
++ result.multibyte = true;
++ result.anchored = anchored;
++
++ return result;
++}
++
++/* Characters that are special in a PCRE. */
++static const char pcre_special[] = "$^.*[]\\+?{}()|";
++
++/* Options bit values, defined in <pcre.h>. We don't include it here, because
++ it is not a standard header. */
++#define PCRE_ANCHORED 0x00000010
++#define PCRE_EXTENDED 0x00000008
++
++struct regex_quote_spec
++regex_quote_spec_pcre (int options, bool anchored)
++{
++ struct regex_quote_spec result;
++ char *p;
++
++ p = result.special;
++ memcpy (p, bre_special, sizeof (pcre_special) - 1);
++ p += sizeof (pcre_special) - 1;
++ if (options & PCRE_EXTENDED)
++ {
++ *p++ = ' ';
++ *p++ = '\t';
++ *p++ = '\n';
++ *p++ = '\v';
++ *p++ = '\f';
++ *p++ = '\r';
++ *p++ = '#';
++ }
++ *p = '\0';
++
++ /* PCRE regular expressions consist of UTF-8 characters of options contains
++ PCRE_UTF8 and of single bytes otherwise. */
++ result.multibyte = false;
++ /* If options contains PCRE_ANCHORED, the anchoring is implicit. */
++ result.anchored = (options & PCRE_ANCHORED ? 0 : anchored);
++
++ return result;
++}
++
++size_t
++regex_quote_length (const char *string, const struct regex_quote_spec *spec)
++{
++ const char *special = spec->special;
++ size_t length;
++
++ length = 0;
++ if (spec->anchored)
++ length += 2; /* for '^' at the beginning and '$' at the end */
++ if (spec->multibyte)
++ {
++ mbui_iterator_t iter;
++
++ for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
++ {
++ /* We know that special contains only ASCII characters. */
++ if (mb_len (mbui_cur (iter)) == 1
++ && strchr (special, * mbui_cur_ptr (iter)))
++ length += 1;
++ length += mb_len (mbui_cur (iter));
++ }
++ }
++ else
++ {
++ const char *iter;
++
++ for (iter = string; *iter != '\0'; iter++)
++ {
++ if (strchr (special, *iter))
++ length += 1;
++ length += 1;
++ }
++ }
++
++ return length;
++}
++
++char *
++regex_quote_copy (char *p, const char *string, const struct regex_quote_spec *spec)
++{
++ const char *special = spec->special;
++
++ if (spec->anchored)
++ *p++ = '^';
++ if (spec->multibyte)
++ {
++ mbui_iterator_t iter;
++
++ for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
++ {
++ /* We know that special contains only ASCII characters. */
++ if (mb_len (mbui_cur (iter)) == 1
++ && strchr (special, * mbui_cur_ptr (iter)))
++ *p++ = '\\';
++ memcpy (p, mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
++ p += mb_len (mbui_cur (iter));
++ }
++ }
++ else
++ {
++ const char *iter;
++
++ for (iter = string; *iter != '\0'; iter++)
++ {
++ if (strchr (special, *iter))
++ *p++ = '\\';
++ *p++ = *iter++;
++ }
++ }
++ if (spec->anchored)
++ *p++ = '$';
++
++ return p;
++}
++
++char *
++regex_quote (const char *string, const struct regex_quote_spec *spec)
++{
++ size_t length = regex_quote_length (string, spec);
++ char *result = XNMALLOC (length + 1, char);
++ char *p;
++
++ p = result;
++ p = regex_quote_copy (p, string, spec);
++ *p = '\0';
++ return result;
++}
+--- origsrc/lib/regex-quote.h 1970-01-01 01:00:00.000000000 +0100
++++ src/lib/regex-quote.h 2013-06-27 18:05:27.112447751 +0200
+@@ -0,0 +1,88 @@
++/* Construct a regular expression from a literal string.
++ Copyright (C) 1995, 2010-2013 Free Software Foundation, Inc.
++ Written by Bruno Haible <haible@clisp.cons.org>, 2010.
++
++ This program 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 3 of the License, or
++ (at your option) any later version.
++
++ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#ifndef _REGEX_QUOTE_H
++#define _REGEX_QUOTE_H
++
++#include <stddef.h>
++#include <stdbool.h>
++
++
++/* Specifies a quotation task for converting a fixed string to a regular
++ expression pattern. */
++struct regex_quote_spec
++{
++ /* True if the regular expression pattern consists of multibyte characters
++ (in the encoding given by the LC_CTYPE category of the locale),
++ false if it consists of single bytes or UTF-8 characters. */
++ unsigned int /*bool*/ multibyte : 1;
++ /* True if the regular expression pattern shall match only entire lines. */
++ unsigned int /*bool*/ anchored : 1;
++ /* Set of characters that need to be escaped (all ASCII), as a
++ NUL-terminated string. */
++ char special[30 + 1];
++};
++
++
++/* Creates a quotation task that produces a POSIX regular expression, that is,
++ a pattern that can be compiled with regcomp().
++ CFLAGS can be 0 or REG_EXTENDED.
++ If it is 0, the result is a Basic Regular Expression (BRE)
++ <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03>.
++ If it is REG_EXTENDED, the result is an Extended Regular Expression (ERE)
++ <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04>.
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_posix (int cflags, bool anchored);
++
++/* Creates a quotation task that produces a regular expression that can be
++ compiled with the GNU API function re_compile_pattern().
++ SYNTAX describes the syntax of the regular expression (such as
++ RE_SYNTAX_POSIX_BASIC, RE_SYNTAX_POSIX_EXTENDED, RE_SYNTAX_EMACS, all
++ defined in <regex.h>). It must be the same value as 're_syntax_options'
++ at the moment of the re_compile_pattern() call.
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored);
++
++/* Creates a quotation task that produces a PCRE regular expression, that is,
++ a pattern that can be compiled with pcre_compile().
++ OPTIONS is the same value as the second argument passed to pcre_compile().
++ If ANCHORED is false, the regular expression will match substrings of lines.
++ If ANCHORED is true, it will match only complete lines, */
++extern struct regex_quote_spec
++ regex_quote_spec_pcre (int options, bool anchored);
++
++
++/* Returns the number of bytes needed for the quoted string. */
++extern size_t
++ regex_quote_length (const char *string, const struct regex_quote_spec *spec);
++
++/* Copies the quoted string to p and returns the incremented p.
++ There must be room for regex_quote_length (string, spec) + 1 bytes at p. */
++extern char *
++ regex_quote_copy (char *p,
++ const char *string, const struct regex_quote_spec *spec);
++
++/* Returns the freshly allocated quoted string. */
++extern char *
++ regex_quote (const char *string, const struct regex_quote_spec *spec);
++
++
++#endif /* _REGEX_QUOTE_H */
+--- origsrc/lib/regex.c 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regex.c 2013-06-27 18:05:27.138447639 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _LIBC
+ # include <config.h>
+@@ -25,6 +24,7 @@
+ # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+ # endif
+ # if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
++# pragma GCC diagnostic ignored "-Wold-style-definition"
+ # pragma GCC diagnostic ignored "-Wtype-limits"
+ # endif
+ #endif
+--- origsrc/lib/regex.h 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regex.h 2013-06-27 18:05:27.168447509 +0200
+@@ -1,23 +1,22 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Definitions for data structures and routines for the regular
+ expression library.
+- Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2012
+- Free Software Foundation, Inc.
++ Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software
++ Foundation, Inc.
+ This file is part of the GNU C Library.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _REGEX_H
+ #define _REGEX_H 1
+--- origsrc/lib/regex_internal.c 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regex_internal.c 2013-06-27 18:05:27.199447375 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static void re_string_construct_common (const char *str, Idx len,
+ re_string_t *pstr,
+@@ -835,7 +834,7 @@ re_string_reconstruct (re_string_t *pstr
+ }
+
+ static unsigned char
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
+ {
+ int ch;
+@@ -975,7 +974,7 @@ re_node_set_alloc (re_node_set *set, Idx
+ set->alloc = size;
+ set->nelem = 0;
+ set->elems = re_malloc (Idx, size);
+- if (BE (set->elems == NULL, 0))
++ if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
+ return REG_ESPACE;
+ return REG_NOERROR;
+ }
+@@ -1355,7 +1354,7 @@ re_node_set_insert_last (re_node_set *se
+ Return true if SET1 and SET2 are equivalent. */
+
+ static bool
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
+ {
+ Idx i;
+@@ -1370,7 +1369,7 @@ re_node_set_compare (const re_node_set *
+ /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
+
+ static Idx
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure))
+ re_node_set_contains (const re_node_set *set, Idx elem)
+ {
+ __re_size_t idx, right, mid;
+@@ -1444,11 +1443,9 @@ re_dfa_add_node (re_dfa_t *dfa, re_token
+ dfa->nodes[dfa->nodes_len] = token;
+ dfa->nodes[dfa->nodes_len].constraint = 0;
+ #ifdef RE_ENABLE_I18N
+- {
+- int type = token.type;
+ dfa->nodes[dfa->nodes_len].accept_mb =
+- (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
+- }
++ ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
++ || token.type == COMPLEX_BRACKET);
+ #endif
+ dfa->nexts[dfa->nodes_len] = REG_MISSING;
+ re_node_set_init_empty (dfa->edests + dfa->nodes_len);
+--- origsrc/lib/regex_internal.h 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regex_internal.h 2013-06-27 18:05:27.230447242 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _REGEX_INTERNAL_H
+ #define _REGEX_INTERNAL_H 1
+@@ -28,21 +27,54 @@
+ #include <string.h>
+
+ #include <langinfo.h>
+-#ifndef _LIBC
+-# include "localcharset.h"
+-#endif
+ #include <locale.h>
+ #include <wchar.h>
+ #include <wctype.h>
+ #include <stdbool.h>
+ #include <stdint.h>
+-#if defined _LIBC
++
++#ifdef _LIBC
+ # include <bits/libc-lock.h>
++# define lock_define(name) __libc_lock_define (, name)
++# define lock_init(lock) (__libc_lock_init (lock), 0)
++# define lock_fini(lock) 0
++# define lock_lock(lock) __libc_lock_lock (lock)
++# define lock_unlock(lock) __libc_lock_unlock (lock)
++#elif defined GNULIB_LOCK
++# include "glthread/lock.h"
++ /* Use gl_lock_define if empty macro arguments are known to work.
++ Otherwise, fall back on less-portable substitutes. */
++# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
++ || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
++# define lock_define(name) gl_lock_define (, name)
++# elif USE_POSIX_THREADS
++# define lock_define(name) pthread_mutex_t name;
++# elif USE_PTH_THREADS
++# define lock_define(name) pth_mutex_t name;
++# elif USE_SOLARIS_THREADS
++# define lock_define(name) mutex_t name;
++# elif USE_WINDOWS_THREADS
++# define lock_define(name) gl_lock_t name;
++# else
++# define lock_define(name)
++# endif
++# define lock_init(lock) glthread_lock_init (&(lock))
++# define lock_fini(lock) glthread_lock_destroy (&(lock))
++# define lock_lock(lock) glthread_lock_lock (&(lock))
++# define lock_unlock(lock) glthread_lock_unlock (&(lock))
++#elif defined GNULIB_PTHREAD
++# include <pthread.h>
++# define lock_define(name) pthread_mutex_t name;
++# define lock_init(lock) pthread_mutex_init (&(lock), 0)
++# define lock_fini(lock) pthread_mutex_destroy (&(lock))
++# define lock_lock(lock) pthread_mutex_lock (&(lock))
++# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
+ #else
+-# define __libc_lock_define(CLASS,NAME)
+-# define __libc_lock_init(NAME) do { } while (0)
+-# define __libc_lock_lock(NAME) do { } while (0)
+-# define __libc_lock_unlock(NAME) do { } while (0)
++# define lock_define(name)
++# define lock_init(lock) 0
++# define lock_fini(lock) 0
++# define lock_lock(lock) ((void) 0)
++# define lock_unlock(lock) ((void) 0)
+ #endif
+
+ /* In case that the system doesn't have isblank(). */
+@@ -65,7 +97,7 @@
+ # ifdef _LIBC
+ # undef gettext
+ # define gettext(msgid) \
+- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
++ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
+ # endif
+ #else
+ # define gettext(msgid) (msgid)
+@@ -101,6 +133,8 @@
+
+ /* Rename to standard API for using out of glibc. */
+ #ifndef _LIBC
++# undef __wctype
++# undef __iswctype
+ # define __wctype wctype
+ # define __iswctype iswctype
+ # define __btowc btowc
+@@ -110,10 +144,8 @@
+ # define attribute_hidden
+ #endif /* not _LIBC */
+
+-#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+-# define __attribute(arg) __attribute__ (arg)
+-#else
+-# define __attribute(arg)
++#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
++# define __attribute__(arg)
+ #endif
+
+ typedef __re_idx_t Idx;
+@@ -429,7 +461,7 @@ static void build_upper_buffer (re_strin
+ static void re_string_translate_buffer (re_string_t *pstr) internal_function;
+ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
+ int eflags)
+- internal_function __attribute ((pure));
++ internal_function __attribute__ ((pure));
+ #endif
+ #define re_string_peek_byte(pstr, offset) \
+ ((pstr)->mbs[(pstr)->cur_idx + offset])
+@@ -448,7 +480,9 @@ static unsigned int re_string_context_at
+ #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+ #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
+-#include <alloca.h>
++#if defined _LIBC || HAVE_ALLOCA
++# include <alloca.h>
++#endif
+
+ #ifndef _LIBC
+ # if HAVE_ALLOCA
+@@ -465,6 +499,12 @@ static unsigned int re_string_context_at
+ # endif
+ #endif
+
++#ifdef _LIBC
++# define MALLOC_0_IS_NONNULL 1
++#elif !defined MALLOC_0_IS_NONNULL
++# define MALLOC_0_IS_NONNULL 0
++#endif
++
+ #ifndef MAX
+ # define MAX(a,b) ((a) < (b) ? (b) : (a))
+ #endif
+@@ -695,7 +735,7 @@ struct re_dfa_t
+ #ifdef DEBUG
+ char* re_str;
+ #endif
+- __libc_lock_define (, lock)
++ lock_define (lock)
+ };
+
+ #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
+@@ -767,7 +807,7 @@ bitset_copy (bitset_t dest, const bitset
+ memcpy (dest, src, sizeof (bitset_t));
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_not (bitset_t set)
+ {
+ int bitset_i;
+@@ -779,7 +819,7 @@ bitset_not (bitset_t set)
+ & ~set[BITSET_WORDS - 1]);
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_merge (bitset_t dest, const bitset_t src)
+ {
+ int bitset_i;
+@@ -787,7 +827,7 @@ bitset_merge (bitset_t dest, const bitse
+ dest[bitset_i] |= src[bitset_i];
+ }
+
+-static void
++static void __attribute__ ((unused))
+ bitset_mask (bitset_t dest, const bitset_t src)
+ {
+ int bitset_i;
+@@ -798,7 +838,7 @@ bitset_mask (bitset_t dest, const bitset
+ #ifdef RE_ENABLE_I18N
+ /* Functions for re_string. */
+ static int
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_char_size_at (const re_string_t *pstr, Idx idx)
+ {
+ int byte_idx;
+@@ -811,7 +851,7 @@ re_string_char_size_at (const re_string_
+ }
+
+ static wint_t
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_wchar_at (const re_string_t *pstr, Idx idx)
+ {
+ if (pstr->mb_cur_max == 1)
+@@ -821,7 +861,7 @@ re_string_wchar_at (const re_string_t *p
+
+ # ifndef NOT_IN_libc
+ static int
+-internal_function __attribute ((pure))
++internal_function __attribute__ ((pure, unused))
+ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+ {
+ # ifdef _LIBC
+--- origsrc/lib/regexec.c 2012-12-22 14:21:52.000000000 +0100
++++ src/lib/regexec.c 2013-06-27 18:05:27.268447078 +0200
+@@ -1,22 +1,21 @@
+-/* -*- buffer-read-only: t -*- vi: set ro: */
+-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+ /* Extended regular expression matching and search library.
+- Copyright (C) 2002-2012 Free Software Foundation, Inc.
++ Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+- This program 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 3, or (at your option)
+- any later version.
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
+
+- This program is distributed in the hope that it will be useful,
++ The GNU C Library 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.
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
+
+- You should have received a copy of the GNU General Public License along
+- with this program; if not, see <http://www.gnu.org/licenses/>. */
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
+ Idx n) internal_function;
+@@ -200,7 +199,7 @@ static Idx group_nodes_into_DFAstates (c
+ static bool check_node_accept (const re_match_context_t *mctx,
+ const re_token_t *node, Idx idx)
+ internal_function;
+-static reg_errcode_t extend_buffers (re_match_context_t *mctx)
++static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
+ internal_function;
+
+ /* Entry point for POSIX code. */
+@@ -229,9 +228,7 @@ regexec (preg, string, nmatch, pmatch, e
+ {
+ reg_errcode_t err;
+ Idx start, length;
+-#ifdef _LIBC
+ re_dfa_t *dfa = preg->buffer;
+-#endif
+
+ if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+ return REG_BADPAT;
+@@ -247,14 +244,14 @@ regexec (preg, string, nmatch, pmatch, e
+ length = strlen (string);
+ }
+
+- __libc_lock_lock (dfa->lock);
++ lock_lock (dfa->lock);
+ if (preg->no_sub)
+ err = re_search_internal (preg, string, length, start, length,
+ length, 0, NULL, eflags);
+ else
+ err = re_search_internal (preg, string, length, start, length,
+ length, nmatch, pmatch, eflags);
+- __libc_lock_unlock (dfa->lock);
++ lock_unlock (dfa->lock);
+ return err != REG_NOERROR;
+ }
+
+@@ -422,9 +419,7 @@ re_search_stub (struct re_pattern_buffer
+ Idx nregs;
+ regoff_t rval;
+ int eflags = 0;
+-#ifdef _LIBC
+ re_dfa_t *dfa = bufp->buffer;
+-#endif
+ Idx last_start = start + range;
+
+ /* Check for out-of-range. */
+@@ -435,7 +430,7 @@ re_search_stub (struct re_pattern_buffer
+ else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+ last_start = 0;
+
+- __libc_lock_lock (dfa->lock);
++ lock_lock (dfa->lock);
+
+ eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
+ eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+@@ -499,7 +494,7 @@ re_search_stub (struct re_pattern_buffer
+ }
+ re_free (pmatch);
+ out:
+- __libc_lock_unlock (dfa->lock);
++ lock_unlock (dfa->lock);
+ return rval;
+ }
+
+@@ -1065,7 +1060,7 @@ prune_impossible_nodes (re_match_context
+ since initial states may have constraints like "\<", "^", etc.. */
+
+ static inline re_dfastate_t *
+-__attribute ((always_inline)) internal_function
++__attribute__ ((always_inline)) internal_function
+ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+ Idx idx)
+ {
+@@ -1177,7 +1172,7 @@ check_matching (re_match_context_t *mctx
+ || (BE (next_char_idx >= mctx->input.valid_len, 0)
+ && mctx->input.valid_len < mctx->input.len))
+ {
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, next_char_idx + 1);
+ if (BE (err != REG_NOERROR, 0))
+ {
+ assert (err == REG_ESPACE);
+@@ -1757,7 +1752,7 @@ clean_state_log_if_needed (re_match_cont
+ && mctx->input.valid_len < mctx->input.len))
+ {
+ reg_errcode_t err;
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, next_state_log_idx + 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+ }
+@@ -2814,7 +2809,7 @@ get_subexp (re_match_context_t *mctx, Id
+ if (bkref_str_off >= mctx->input.len)
+ break;
+
+- err = extend_buffers (mctx);
++ err = extend_buffers (mctx, bkref_str_off + 1);
+ if (BE (err != REG_NOERROR, 0))
+ return err;
+
+@@ -3937,6 +3932,7 @@ check_node_accept_bytes (const re_dfa_t
+ in_collseq = find_collation_sequence_value (pin, elem_len);
+ }
+ /* match with range expression? */
++ /* FIXME: Implement rational ranges here, too. */
+ for (i = 0; i < cset->nranges; ++i)
+ if (cset->range_starts[i] <= in_collseq
+ && in_collseq <= cset->range_ends[i])
+@@ -3988,18 +3984,9 @@ check_node_accept_bytes (const re_dfa_t
+ # endif /* _LIBC */
+ {
+ /* match with range expression? */
+-#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined __STRICT_ANSI__)
+- wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
+-#else
+- wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+- cmp_buf[2] = wc;
+-#endif
+ for (i = 0; i < cset->nranges; ++i)
+ {
+- cmp_buf[0] = cset->range_starts[i];
+- cmp_buf[4] = cset->range_ends[i];
+- if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+- && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
++ if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
+ {
+ match_len = char_len;
+ goto check_node_accept_bytes_match;
+@@ -4137,7 +4124,7 @@ check_node_accept (const re_match_contex
+
+ static reg_errcode_t
+ internal_function __attribute_warn_unused_result__
+-extend_buffers (re_match_context_t *mctx)
++extend_buffers (re_match_context_t *mctx, int min_len)
+ {
+ reg_errcode_t ret;
+ re_string_t *pstr = &mctx->input;
+@@ -4147,8 +4134,10 @@ extend_buffers (re_match_context_t *mctx
+ <= pstr->bufs_len, 0))
+ return REG_ESPACE;
+
+- /* Double the lengths of the buffers. */
+- ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2));
++ /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
++ ret = re_string_realloc_buffers (pstr,
++ MAX (min_len,
++ MIN (pstr->len, pstr->bufs_len * 2)));
+ if (BE (ret != REG_NOERROR, 0))
+ return ret;
+
+--- origsrc/sed/sed.c 2012-03-16 10:13:31.000000000 +0100
++++ src/sed/sed.c 2013-06-27 18:06:25.592195456 +0200
+@@ -57,7 +57,11 @@ bool follow_symlinks = false;
+ char *in_place_extension = NULL;
+
+ /* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
++#ifdef HAVE_FOPEN_RT
++char *read_mode = "rt";
++#else
+ char *read_mode = "r";
++#endif
+ char *write_mode = "w";
+
+ /* Do we need to be pedantically POSIX compliant? */