Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add build support under Windows/MinGW environment.

Conflicts:

	configure.ac

Change-Id: Ib7a40ed36f44988921bb11ec408746931e982d8c
Reviewed-on: http://review.couchbase.org/6997
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
commit 59610cfb688b99be0d09bc5072c5b652136d6e0f 1 parent e09020f
@bcui6611 bcui6611 authored
View
45 INSTALL.Windows
@@ -11,27 +11,33 @@ You will need the following installed:
* Erlang OTP (=14B01) (http://erlang.org/)
* ICU (http://icu.sourceforge.net/)
* OpenSSL (http://www.openssl.org/)
- * Mozilla SpiderMonkey (1.8) (http://www.mozilla.org/js/spidermonkey/)
+ * Mozilla SpiderMonkey (1.8) (https://github.com/couchbase/spidermonkey)
* libcurl (http://curl.haxx.se/libcurl/)
* Cygwin (http://www.cygwin.com/)
* Visual Studio 2008 (http://msdn.microsoft.com/en-gb/vstudio/default.aspx)
+ * Windows .NET Framework 4 (http://msdn.microsoft.com/en-us/netframework/aa569263)
General Notes
-------------
- * When installing Erlang, you must build it from source.
+ * For Windows + Cygwin, when installing Erlang, you must build it from source.
The CouchDB build makes use of a number of the Erlang build scripts.
+ * For Windows + MinGW + MSYS, you should copy your Erlang setup to a temp directory
+ and use it to build your Couchdb application.
+
* When installing ICU, select the binaries built with Visual Studio 2008.
+ Please select icu4c-4_2_1-Win32-msvc9.zip even though the latest one is 4.6
* When installing Cygwin, be sure to select all the `development` tools.
+ It is not needed on Windows + MinGW + Msys environemnt.
* When installing libcurl, be sure to install by hand.
The Cygwin binaries are incompatible and will not work with Erlang.
-Setting Up Cygwin
+Setting Up Cygwin (Skip the step on minGW environment)
-----------------
Before starting any Cygwin terminals, run:
@@ -57,7 +63,7 @@ You must check that:
If you do not do this, the build may fail due to Cygwin ones found in `/usr/bin`
being used instead.
-Building Erlang
+Building Erlang (Skip the step on minGW environment)
---------------
You must include Win32 OpenSSL.
@@ -100,11 +106,31 @@ If everything was successful, you should be ready to build CouchDB.
Relax.
+Clone Erlang setup (only needed on minGW environement)
+-----------------------------------------------------
+The CouchDB build makes use of a number of the Erlang build scripts.
+You can clone an existed Erlang setup to a temp directory for build purpose.
+For example, run the following command
+c:\> xcopy /e c:/erl5.7.4 c:/temp/couch_dist
+
+Build Mozilla SpiderMonkey
+--------------------------
+You need MozillaBuild to build spidermonkey successfully. You can get it from
+http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe
+
+After the prerequisites are installed, launch one of the following batch files from the c:\mozilla-build directory:
+start-msvc8.bat (VS 2005)
+start-msvc9.bat (VS 2008)
+start-msvc10.bat (VS 2010)
+
+On Windows7 platform, you need to clone the ref-config\WINNT6.0.mk as ref-config\WINNT6.1.mk in order to build.
+
Building CouchDB
----------------
Once you have satisfied the dependencies you should run:
+on Cygwin
./configure \
--with-js-include=/cygdrive/c/path_to_spidermonkey_include \
--with-js-lib=/cygdrive/c/path_to_spidermonkey_lib \
@@ -117,6 +143,17 @@ Once you have satisfied the dependencies you should run:
This command could take a while to complete.
+On minGW + MSYS
+ ./configure \
+ --with-js-include=/c/devtest/spidermonkey/dist/include \
+ --with-js-lib=/c/devtest/spidermonkey/dist/lib \
+ --with-win32-icu-binaries=/c/icu4c-4_2_1-Win32-msvc9/icu \
+ --with-erlang=/c/erl5.7.4/usr/include \
+ --with-win32-curl=/c/dev/grommit/curl-7.20.1 \
+ --with-msvc-redist-dir=/c/erl5.7.4/vcredist_x86.exe \
+ --with-msbuild-dir=/c/Windows/Microsoft.NET/Framework/v4.0.30319
+ --prefix=/c/temp/couch_dist
+
If everything was successful you should see the following message:
You have configured Apache CouchDB, time to relax.
View
84 configure.ac
@@ -131,6 +131,7 @@ AC_ARG_WITH([js-include], [AC_HELP_STRING([--with-js-include=PATH],
JS_FLAGS="$JS_FLAGS -I/usr/local/include/js"
JS_FLAGS="$JS_FLAGS -I/opt/local/include/js"
])
+AC_SUBST(JS_INCLUDE)
AC_ARG_WITH([js-lib], [AC_HELP_STRING([--with-js-lib=PATH],
[set PATH to the SpiderMonkey library directory])],
@@ -154,6 +155,18 @@ case "$(uname -s)" in
CPPFLAGS="$FLAGS $CPPFLAGS"
LDFLAGS="$FLAGS $LDFLAGS"
IS_WINDOWS="TRUE"
+ IS_CYGWIN="TRUE"
+ # The erlang cc.sh/ld.sh scripts will convert a -O option
+ # into the same optimization flags erlang itself uses.
+ CFLAGS="-O2"
+ LTCFLAGS="$CFLAGS"
+ ;;
+ MINGW*)
+ FLAGS="$LIB_FLAGS $ERLANG_FLAGS $JS_FLAGS -DXP_WIN $FLAGS"
+ CPPFLAGS="$FLAGS $CPPFLAGS"
+ LDFLAGS="$FLAGS $LDFLAGS"
+ IS_WINDOWS="TRUE"
+ IS_MINGW="TRUE"
# The erlang cc.sh/ld.sh scripts will convert a -O option
# into the same optimization flags erlang itself uses.
CFLAGS="-O2"
@@ -170,6 +183,8 @@ esac
AM_CONDITIONAL([WINDOWS], [test x$IS_WINDOWS = xTRUE])
+AM_CONDITIONAL([MINGW], [test x$IS_MINGW = xTRUE])
+
AC_CHECK_LIB([mozjs], [JS_NewContext], [JS_LIB_BASE=mozjs], [
AC_CHECK_LIB([js], [JS_NewContext], [JS_LIB_BASE=js], [
AC_CHECK_LIB([js3250], [JS_NewContext], [JS_LIB_BASE=js3250], [
@@ -194,32 +209,48 @@ if test x${IS_WINDOWS} = xTRUE; then
fi
AC_SUBST(JS_LIB_BINARY)
- # On windows we need to know the path to the openssl binaries.
- AC_ARG_WITH([openssl-bin-dir], [AC_HELP_STRING([--with-openssl-bin-dir=PATH],
- [path to the open ssl binaries for distribution on Windows])], [
- openssl_bin_dir=`cygpath -m "$withval"`
- AC_SUBST(openssl_bin_dir)
- ], [])
-
- # Windows uses Inno setup - look for its compiler.
- AC_PATH_PROG([INNO_COMPILER_EXECUTABLE], [iscc])
- if test x${INNO_COMPILER_EXECUTABLE} = x; then
- AC_MSG_WARN([You will be unable to build the Windows installer.])
+ if test x${IS_CYGWIN} = xTRUE; then
+ # On windows we need to know the path to the openssl binaries.
+ AC_ARG_WITH([openssl-bin-dir], [AC_HELP_STRING([--with-openssl-bin-dir=PATH],
+ [path to the open ssl binaries for distribution on Windows])], [
+ openssl_bin_dir=`cygpath -m "$withval"`
+ AC_SUBST(openssl_bin_dir)
+ ], [])
+
+ # Windows uses Inno setup - look for its compiler.
+ AC_PATH_PROG([INNO_COMPILER_EXECUTABLE], [iscc])
+ if test x${INNO_COMPILER_EXECUTABLE} = x; then
+ AC_MSG_WARN([You will be unable to build the Windows installer.])
+ fi
+
+ # We need the msvc redistributables for this platform too
+ # (in theory we could just install the assembly locally - but
+ # there are at least 4 directories with binaries, meaning 4 copies;
+ # so using the redist .exe means it ends up installed globally...)
+ AC_ARG_WITH([msvc-redist-dir], [AC_HELP_STRING([--with-msvc-redist-dir=PATH],
+ [path to the msvc redistributables for the Windows platform])], [
+ msvc_redist_dir=`cygpath -m "$withval"`
+ msvc_redist_name="vcredist_x86.exe"
+ AC_SUBST(msvc_redist_dir)
+ AC_SUBST(msvc_redist_name)
+ ], [])
+ if test ! -f ${msvc_redist_dir}/${msvc_redist_name}; then
+ AC_MSG_WARN([The MSVC redistributable seems to be missing; expect the installer to fail.])
+ fi
fi
- # We need the msvc redistributables for this platform too
- # (in theory we could just install the assembly locally - but
- # there are at least 4 directories with binaries, meaning 4 copies;
- # so using the redist .exe means it ends up installed globally...)
- AC_ARG_WITH([msvc-redist-dir], [AC_HELP_STRING([--with-msvc-redist-dir=PATH],
- [path to the msvc redistributables for the Windows platform])], [
- msvc_redist_dir=`cygpath -m "$withval"`
- msvc_redist_name="vcredist_x86.exe"
- AC_SUBST(msvc_redist_dir)
- AC_SUBST(msvc_redist_name)
- ], [])
- if test ! -f ${msvc_redist_dir}/${msvc_redist_name}; then
- AC_MSG_WARN([The MSVC redistributable seems to be missing; expect the installer to fail.])
+ if test x${IS_MINGW} = xTRUE; then
+ # On windows we need to know the path to the MSBuild
+ AC_ARG_WITH([msbuild-dir], [AC_HELP_STRING([--with-msbuild-dir=PATH],
+ [path to the .NET Framework 4 which contains MSBuild.exe])], [
+ msbuild_dir=$withval
+ msbuild_name="MSBuild.exe"
+ AC_SUBST(msbuild_dir)
+ AC_SUBST(msbuild_name)
+ ], [])
+ if test ! -f ${msbuild_dir}/${msbuild_name}; then
+ AC_MSG_WARN([The .NET Framework 4.0 seems to be missing; expect the couchjs module to fail.])
+ fi
fi
fi
@@ -496,7 +527,10 @@ AC_CONFIG_FILES([test/javascript/Makefile])
AC_CONFIG_FILES([test/view_server/Makefile])
AC_CONFIG_FILES([utils/Makefile])
AC_CONFIG_FILES([var/Makefile])
-
+if test x${IS_MINGW} = xTRUE; then
+ AC_CONFIG_FILES([src/couchdb/priv/couch_js/win32/msbuild.bat.tpl])
+ AC_CONFIG_FILES([src/couchdb/priv/couch_js/win32/couchjs.vcxproj.tpl])
+fi
AC_OUTPUT
# *sob* - on Windows libtool fails as 'libname_spec' isn't correct (it
View
29 src/couchdb/priv/Makefile.am
@@ -37,6 +37,13 @@ if WINDOWS
couch_icu_driver_la_LDFLAGS += -no-undefined
endif
+if MINGW
+couchjs_msbuild = couch_js/win32/msbuild.bat
+couchjs_vcproj = couch_js/win32/couchjs.vcxproj
+WIN_JS_INCLUDE = couch_js/win32/win_js_include.tmp
+WIN_JS_LIB_DIR = couch_js/win32/win_js_dir.tmp
+endif
+
COUCHJS_SRCS = \
couch_js/http.c \
couch_js/http.h \
@@ -65,6 +72,28 @@ couchspawnkillable: spawnkillable/couchspawnkillable.sh
chmod +x $@
endif
+if MINGW
+couchjs$(EXEEXT): $(COUCHJS_SRCS) $(couchjs_msbuild) $(couchjs_vcproj)
+ @rm -f couchjs$(EXEEXT)
+ (cd couch_js/win32 && msbuild.bat)
+
+$(couchjs_msbuild): $(couchjs_msbuild).tpl
+ sed -e "s|%msbuild_dir%|$(msbuild_dir)|" \
+ -e "s|%msbuild_name%|$(msbuild_name)|" \
+ < $< > $@
+
+$(couchjs_vcproj): $(couchjs_vcproj).tpl $(WIN_JS_INCLUDE) $(WIN_JS_LIB_DIR)
+ sed -e "s|%JS_INCLUDE%|`cat $(WIN_JS_INCLUDE)`|" \
+ -e "s|%JS_LIB_DIR%|`cat $(WIN_JS_LIB_DIR)`|" \
+ < $< > $@
+
+$(WIN_JS_INCLUDE):$(JS_INCLUDE)
+ echo $< | sed -e "s|^/\([a-zA-Z]\)|\1:|" > $@
+
+$(WIN_JS_LIB_DIR):$(JS_LIB_DIR)
+ echo $< | sed -e "s|^/\([a-zA-Z]\)|\1:|" > $@
+endif
+
# libtool and automake have defeated markh. For each of our executables
# we end up with 2 copies - one directly in the 'target' folder (eg, 'priv')
# and another - the correct one - in .libs. The former doesn't work but is
View
62 src/couchdb/priv/couch_js/win32/couchjs.vcxproj.tpl.in
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{489C3EDD-48EA-4780-A38E-C733D10D841D}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>couchjs</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;XP_WIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>%JS_INCLUDE%;../../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>%JS_LIB_DIR%;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>mozjs.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\http.c" />
+ <ClCompile Include="..\main.c" />
+ <ClCompile Include="..\utf8.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\http.h" />
+ <ClInclude Include="..\utf8.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
View
2  src/couchdb/priv/couch_js/win32/msbuild.bat.tpl.in
@@ -0,0 +1,2 @@
+%msbuild_dir%/%msbuild_name% couchjs.vcxproj -p:configuration=release -p:platform=win32
+cp release/couchjs.exe ../../lib
View
2  src/couchdb/priv/spawnkillable/couchspawnkillable_win.c
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
return rc;
// Write the 'terminate' command, which includes this PID, back to couch.
// *sob* - what about spaces etc?
- sprintf_s(out_buf, sizeof(out_buf), "%s --kill %d\n",
+ _snprintf(out_buf, sizeof(out_buf), "%s --kill %d\n",
argv[0], pi.dwProcessId);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), out_buf, strlen(out_buf),
&cbwritten, NULL);
Please sign in to comment.
Something went wrong with that request. Please try again.