]> granicus.if.org Git - icu/commitdiff
ICU-9985 Add support for msys msvc build environment
authorMichael Ow <mow@svn.icu-project.org>
Wed, 27 Aug 2014 22:42:28 +0000 (22:42 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Wed, 27 Aug 2014 22:42:28 +0000 (22:42 +0000)
X-SVN-Rev: 36256

icu4c/source/acinclude.m4
icu4c/source/config/mh-msys-msvc [new file with mode: 0644]
icu4c/source/configure
icu4c/source/configure.ac
icu4c/source/data/Makefile.in
icu4c/source/runConfigureICU

index 25e1eaa1db0ff9eea3d84ac7b961822fc8ecac88..179c1c827677f944f850129187b4d5e392dc01f2 100644 (file)
@@ -52,7 +52,10 @@ x86_64-*-cygwin)
 #endif]])],                        [icu_cv_host_frag=mh-mingw64],
                                    [icu_cv_host_frag=mh-mingw])
        else
-               icu_cv_host_frag=mh-cygwin-msvc
+               case "${host}" in
+               *-*-mingw*) icu_cv_host_frag=mh-msys-msvc ;;
+               *-*-cygwin) icu_cv_host_frag=mh-cygwin-msvc ;;
+               esac
        fi ;;
 *-*-*bsd*|*-*-dragonfly*)      icu_cv_host_frag=mh-bsd-gcc ;;
 *-*-aix*)
@@ -481,7 +484,9 @@ AC_DEFUN([AC_CHECK_STRICT_COMPILE],
                 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
                 then
                     CFLAGS="$CFLAGS /W4"
-                fi
+                fi ;;
+            *-*-mingw*)
+                CFLAGS="$CFLAGS -W4" ;;
             esac
         fi
         if test "$GXX" = yes
@@ -493,7 +498,9 @@ AC_DEFUN([AC_CHECK_STRICT_COMPILE],
                 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
                 then
                     CXXFLAGS="$CXXFLAGS /W4"
-                fi
+                fi ;;
+            *-*-mingw*)
+                CFLAGS="$CFLAGS -W4" ;;
             esac
         fi
     fi
diff --git a/icu4c/source/config/mh-msys-msvc b/icu4c/source/config/mh-msys-msvc
new file mode 100644 (file)
index 0000000..0a20042
--- /dev/null
@@ -0,0 +1,221 @@
+## -*-makefile-*-
+## MSYS with Microsoft Visual C++ compiler specific setup
+## Copyright (c) 2014, International Business Machines Corporation and
+## others. All Rights Reserved.
+
+# We install sbin tools into the same bin directory because
+# pkgdata needs some of the tools in sbin, and we can't always depend on
+# icu-config working on Windows.
+sbindir=$(bindir)
+
+# Need this option to use / instead of - when specifying options for the
+# rc.exe command
+MSYS_RC_MODE=1
+
+## Commands to generate dependency files
+GEN_DEPS.c=    :
+GEN_DEPS.cc=   :
+#GEN_DEPS.c=   $(COMPILE.c) -E
+#GEN_DEPS.cc=  $(COMPILE.cc) -E
+
+## Flags to create/use a static library
+ifneq ($(ENABLE_SHARED),YES)
+## Make sure that the static libraries can be built and used
+CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M#
+else
+## Make sure that the static libraries can be built
+STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
+endif
+
+## Flags for position independent code
+SHAREDLIBCFLAGS = 
+SHAREDLIBCXXFLAGS = 
+SHAREDLIBCPPFLAGS =
+
+## Additional flags when building libraries and with threads
+LIBCPPFLAGS = 
+
+ifeq ($(ENABLE_RELEASE),1)
+# Make sure that assertions are disabled
+CPPFLAGS+=-DU_RELEASE=1#M#
+endif
+
+ifeq ($(ENABLE_DEBUG),1)
+# Pass debugging flag through
+CPPFLAGS+=-D_DEBUG=1#M#
+ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M#
+endif
+
+# -GF pools strings and places them into read-only memory
+# -EHsc enables exception handling
+# -Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility.
+# -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions.
+CFLAGS+=-GF -nologo
+CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t
+CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE
+DEFS+=-DWIN32 -DCYGWINMSVC
+LDFLAGS+=-nologo
+
+# Commands to compile
+COMPILE.c=     $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
+COMPILE.cc=    $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
+
+# Commands to link
+LINK.c=                LINK.EXE -subsystem:console $(LDFLAGS)
+LINK.cc=       LINK.EXE -subsystem:console $(LDFLAGS)
+
+## Commands to make a shared library
+SHLIB.c=       LINK.EXE -DLL $(LDFLAGS)
+SHLIB.cc=      LINK.EXE -DLL $(LDFLAGS)
+
+## Compiler switch to embed a runtime search path
+LD_RPATH=      
+LD_RPATH_PRE=
+
+## Compiler switch to embed a library name
+LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib)
+
+## Shared object suffix
+SO = dll
+## Non-shared intermediate object suffix
+STATIC_O = ao
+# OUTOPT is for creating a specific output name
+OUTOPT = -out:
+
+# Static library prefix and file extension
+LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
+A = lib
+
+# Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead.
+AR = LIB.EXE#M#
+ARFLAGS := -nologo $(ARFLAGS:r=)#M#
+RANLIB = ls -s#M#
+AR_OUTOPT = -OUT:#M#
+
+## An import library is needed for z-OS, MSVC and Cygwin
+IMPORT_LIB_EXT = .lib
+
+LIBPREFIX=
+DEFAULT_LIBS = advapi32.lib
+
+# Change the stubnames so that poorly working FAT disks and installation programs can work.
+# This is also for backwards compatibility.
+DATA_STUBNAME = dt
+I18N_STUBNAME = in
+LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
+
+## Link commands to link to ICU libs
+ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),)
+LIBICUDT=      $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
+else
+LIBICUDT=      $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
+endif
+LIBICUUC=      $(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
+LIBICUI18N=    $(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICULE=      $(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICULX=      $(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICUIO=      $(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
+LIBCTESTFW=    $(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICUTOOLUTIL=        $(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
+
+## These are the library specific LDFLAGS
+LDFLAGSICUDT+= -base:"0x4ad00000" -NOENTRY# The NOENTRY option is required for creating a resource-only DLL.
+LDFLAGSICUUC=  -base:"0x4a800000"# in-uc = 1MB
+LDFLAGSICUI18N=        -base:"0x4a900000"# io-in = 2MB
+LDFLAGSICUIO=  -base:"0x4ab00000"# le-io = 1MB
+LDFLAGSICULE=  -base:"0x4ac00000"# lx-le = 512KB
+LDFLAGSICULX=  -base:"0x4ac80000"
+LDFLAGSCTESTFW=# Unused for now.
+LDFLAGSICUTOOLUTIL=    -base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
+
+## Compilation rules
+%.$(STATIC_O): $(srcdir)/%.c
+       $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $<
+%.o: $(srcdir)/%.c
+       $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $<
+
+%.$(STATIC_O): $(srcdir)/%.cpp
+       $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $<
+%.o: $(srcdir)/%.cpp
+       $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $<
+
+
+## Dependency rules
+## This is a start to how depdendencies could work
+# The commented out rules may not properly delete the file when ^C is pressed
+#   or the compiler fails.
+# make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
+#   So system headers are ignored by ignoring \\
+%.d : $(srcdir)/%.c
+       @echo "generating dependency information for $<"
+       @$(GEN_DEPS.c) $< > $@
+#      @echo -n "generating dependency information for "
+#      @echo -n "$@ $(basename $<).o : " > $@
+#      @$(SHELL) -ec '$(GEN_DEPS.c) $< \
+#              | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
+#              | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\     / >> $@ \
+#              || (rm -f $@ && echo $@ && false)'
+
+%.d : $(srcdir)/%.cpp
+       @echo "generating dependency information for $<"
+       @$(GEN_DEPS.cc) $< > $@
+#      @echo -n "generating dependency information for "
+#      @echo -n "$@ $(basename $<).o : " > $@
+#      @$(SHELL) -ec '$(GEN_DEPS.cc) $< \
+#              | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
+#              | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\     / >> $@ \
+#              || (rm -f $@ && echo $@ && false)'
+
+## Compile a Windows resource file
+%.res : $(srcdir)/%.rc
+       rc.exe -fo$@ $(CPPFLAGS) $<
+
+## Versioned target for a shared library.
+FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
+MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
+
+## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature.
+       POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \
+       ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \
+       || true
+       POST_BUILD_STEP = @([ -e $@.manifest ] && \
+       ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \
+       || true
+
+## Special pkgdata information that is needed
+PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
+ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p  $(DESTDIR)$(ICUPKGDATA_DIR) ;  echo $(DESTDIR)$(ICUPKGDATA_DIR))#M#
+ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p  $(DESTDIR)$(libdir) ; echo $(DESTDIR)$(libdir))#M#
+
+## Versioned import library names. The library names are versioned,
+## but the import libraries do not need versioning.
+IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M#
+MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M#
+FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M#
+
+# The following is for Makefile.inc's use.
+ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
+
+## Versioned libraries rules
+#%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
+#      $(RM) $@ && cp ${<F} $@
+
+# The following rule is sometimes a no op.
+# We only want to do a post-build step when a manifest file doesn't exist.
+%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
+       @echo -n
+       $(POST_SO_BUILD_STEP)
+
+## Install libraries as executable
+INSTALL-L=$(INSTALL_PROGRAM)
+
+# Environment variable to set a runtime search path
+LDLIBRARYPATH_ENVVAR = PATH
+
+# These are needed to allow the pkgdata nmake files to work
+PKGDATA_INVOKE_OPTS = MAKEFLAGS=
+
+# Include the version information in the shared library
+ENABLE_SO_VERSION_DATA=1
+
+## End MSYS-specific setup
index 26fbfa0751eb4c057d90a794cf78eb9406a76dec..579368684d17da5e82691e1c1f11a78e1534e0cd 100755 (executable)
@@ -4119,7 +4119,9 @@ $as_echo "$ac_use_strict_options" >&6; }
                 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
                 then
                     CFLAGS="$CFLAGS /W4"
-                fi
+                fi ;;
+            *-*-mingw*)
+                CFLAGS="$CFLAGS -W4" ;;
             esac
         fi
         if test "$GXX" = yes
@@ -4131,7 +4133,9 @@ $as_echo "$ac_use_strict_options" >&6; }
                 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
                 then
                     CXXFLAGS="$CXXFLAGS /W4"
-                fi
+                fi ;;
+            *-*-mingw*)
+                CFLAGS="$CFLAGS -W4" ;;
             esac
         fi
     fi
@@ -4927,7 +4931,10 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
        else
-               icu_cv_host_frag=mh-cygwin-msvc
+               case "${host}" in
+               *-*-mingw*) icu_cv_host_frag=mh-msys-msvc ;;
+               *-*-cygwin) icu_cv_host_frag=mh-cygwin-msvc ;;
+               esac
        fi ;;
 *-*-*bsd*|*-*-dragonfly*)      icu_cv_host_frag=mh-bsd-gcc ;;
 *-*-aix*)
@@ -5169,7 +5176,7 @@ $as_echo "$enabled" >&6; }
 MSVC_RELEASE_FLAG=""
 if test $enabled = yes
 then
-    if test $icu_cv_host_frag = mh-cygwin-msvc
+    if test $icu_cv_host_frag = mh-cygwin-msvc -o $icu_cv_host_frag = mh-msys-msvc
     then
         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
index 0b0fc49f9ce42dfb2ab4369e987b3de1ccc379c1..a86db17aa64a07c1e854fa474b80cb5d2f609142 100644 (file)
@@ -330,7 +330,7 @@ AC_SUBST(UCLN_NO_AUTO_CLEANUP)
 MSVC_RELEASE_FLAG=""
 if test $enabled = yes
 then
-    if test $icu_cv_host_frag = mh-cygwin-msvc
+    if test $icu_cv_host_frag = mh-cygwin-msvc -o $icu_cv_host_frag = mh-msys-msvc
     then
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
     #if defined _MSC_VER && _MSC_VER >= 1400
index 77679befc6dc482543612ff1c774b9b65459573d..dc7a4e5b5403a48d07288f4175268fa96ff250f1 100644 (file)
@@ -353,9 +353,13 @@ ifeq ($(ENABLE_SO_VERSION_DATA),1)
 ifeq ($(PKGDATA_MODE),dll)
 SO_VERSION_DATA = $(OUTTMPDIR)/icudata.res
 $(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc
+ifeq ($(MSYS_RC_MODE),1)
+       rc.exe -i$(srcdir)/../common -i$(top_builddir)/common -fo$@ $(CPPFLAGS) $<
+else
        rc.exe /i$(srcdir)/../common /i$(top_builddir)/common /fo$@ $(CPPFLAGS) $(SOURCE_FILE)
 endif
 endif
+endif
 
 INDEX_NAME=res_index
 INDEX_FILE=$(OUTTMPDIR)/$(INDEX_NAME).txt
index 716c12f710657252c30fb8a6b16c9ffc561be07d..bc6ae8fd2067289e96d28c7c89e50960156f00cd 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 1999-2013, International Business Machines Corporation and
+# Copyright (c) 1999-2014, International Business Machines Corporation and
 # others. All Rights Reserved.
 
 # runConfigureICU: This script will run the "configure" script for the appropriate platform
@@ -51,6 +51,7 @@ The following names can be supplied as the argument for platform:
     MacOSX              Use the default compilers on MacOS X (Darwin)
     MacOSX/GCC          Use the GNU gcc/g++ compilers on MacOSX (Darwin)
     MinGW               Use the GNU gcc/g++ compilers on MinGW
+    MSYS/MSVC           Use the Microsoft Visual C++ computer on MSYS
     QNX                 Use the QNX QCC compiler on QNX/Neutrino
     Solaris             Use the Sun cc/CC compilers on Solaris
     Solaris/GCC         Use the GNU gcc/g++ compilers on Solaris
@@ -315,6 +316,17 @@ case $platform in
         CXXFLAGS="--std=c++03"
         export CXXFLAGS
         ;;
+    MSYS/MSVC)
+        THE_OS="MSYS"
+        THE_COMP="Microsoft Visual C++"
+        CC=cl; export CC
+        CXX=cl; export CXX
+        RELEASE_CFLAGS='-Gy -MD'
+        RELEASE_CXXFLAGS='-Gy -MD'
+        DEBUG_CFLAGS='-Zi -MDd'
+        DEBUG_CXXFLAGS='-Zi -MDd'
+        DEBUG_LDFLAGS='-DEBUG'
+        ;;
     *BSD)
         THE_OS="BSD"
         THE_COMP="the GNU C++"