2 ## MSYS with Microsoft Visual C++ compiler specific setup
3 ## Copyright (c) 2014, International Business Machines Corporation and
4 ## others. All Rights Reserved.
6 # We install sbin tools into the same bin directory because
7 # pkgdata needs some of the tools in sbin, and we can't always depend on
8 # icu-config working on Windows.
11 # Need this option to use / instead of - when specifying options for the
15 ## Commands to generate dependency files
18 #GEN_DEPS.c= $(COMPILE.c) -E
19 #GEN_DEPS.cc= $(COMPILE.cc) -E
21 ## Flags to create/use a static library
22 ifneq ($(ENABLE_SHARED),YES)
23 ## Make sure that the static libraries can be built and used
24 CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M#
26 ## Make sure that the static libraries can be built
27 STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
30 ## Flags for position independent code
35 ## Additional flags when building libraries and with threads
38 ifeq ($(ENABLE_RELEASE),1)
39 # Make sure that assertions are disabled
40 CPPFLAGS+=-DU_RELEASE=1#M#
43 ifeq ($(ENABLE_DEBUG),1)
44 # Pass debugging flag through
45 CPPFLAGS+=-D_DEBUG=1#M#
46 ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M#
49 # -GF pools strings and places them into read-only memory
50 # -EHsc enables exception handling
51 # -Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility.
52 # -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions.
54 CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t
55 CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE
56 DEFS+=-DWIN32 -DCYGWINMSVC
60 COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
61 COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
64 LINK.c= LINK.EXE -subsystem:console $(LDFLAGS)
65 LINK.cc= LINK.EXE -subsystem:console $(LDFLAGS)
67 ## Commands to make a shared library
68 SHLIB.c= LINK.EXE -DLL $(LDFLAGS)
69 SHLIB.cc= LINK.EXE -DLL $(LDFLAGS)
71 ## Compiler switch to embed a runtime search path
75 ## Compiler switch to embed a library name
76 LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib)
78 ## Shared object suffix
80 ## Non-shared intermediate object suffix
82 # OUTOPT is for creating a specific output name
85 # Static library prefix and file extension
86 LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
89 # Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead.
91 ARFLAGS := -nologo $(ARFLAGS:r=)#M#
95 ## An import library is needed for z-OS, MSVC and Cygwin
99 DEFAULT_LIBS = advapi32.lib
101 # Change the stubnames so that poorly working FAT disks and installation programs can work.
102 # This is also for backwards compatibility.
105 LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
107 ## Link commands to link to ICU libs
108 ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),)
109 LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
111 LIBICUDT= $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
113 LIBICUUC= $(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
114 LIBICUI18N= $(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
115 LIBICULE= $(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
116 LIBICULX= $(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
117 LIBICUIO= $(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
118 LIBCTESTFW= $(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
119 LIBICUTOOLUTIL= $(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
121 ## These are the library specific LDFLAGS
122 LDFLAGSICUDT+= -base:"0x4ad00000" -NOENTRY# The NOENTRY option is required for creating a resource-only DLL.
123 LDFLAGSICUUC= -base:"0x4a800000"# in-uc = 1MB
124 LDFLAGSICUI18N= -base:"0x4a900000"# io-in = 2MB
125 LDFLAGSICUIO= -base:"0x4ab00000"# le-io = 1MB
126 LDFLAGSICULE= -base:"0x4ac00000"# lx-le = 512KB
127 LDFLAGSICULX= -base:"0x4ac80000"
128 LDFLAGSCTESTFW=# Unused for now.
129 LDFLAGSICUTOOLUTIL= -base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
132 %.$(STATIC_O): $(srcdir)/%.c
133 $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $<
135 $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $<
137 %.$(STATIC_O): $(srcdir)/%.cpp
138 $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $<
140 $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $<
144 ## This is a start to how depdendencies could work
145 # The commented out rules may not properly delete the file when ^C is pressed
146 # or the compiler fails.
147 # make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
148 # So system headers are ignored by ignoring \\
150 @echo "generating dependency information for $<"
151 @$(GEN_DEPS.c) $< > $@
152 # @echo -n "generating dependency information for "
153 # @echo -n "$@ $(basename $<).o : " > $@
154 # @$(SHELL) -ec '$(GEN_DEPS.c) $< \
155 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
156 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
157 # || (rm -f $@ && echo $@ && false)'
159 %.d : $(srcdir)/%.cpp
160 @echo "generating dependency information for $<"
161 @$(GEN_DEPS.cc) $< > $@
162 # @echo -n "generating dependency information for "
163 # @echo -n "$@ $(basename $<).o : " > $@
164 # @$(SHELL) -ec '$(GEN_DEPS.cc) $< \
165 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
166 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
167 # || (rm -f $@ && echo $@ && false)'
169 ## Compile a Windows resource file
170 %.res : $(srcdir)/%.rc
171 rc.exe -fo$@ $(CPPFLAGS) $<
173 ## Versioned target for a shared library.
174 FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
175 MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
177 ## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature.
178 POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \
179 ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \
181 POST_BUILD_STEP = @([ -e $@.manifest ] && \
182 ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \
185 ## Special pkgdata information that is needed
186 PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
187 ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p $(DESTDIR)$(ICUPKGDATA_DIR) ; echo $(DESTDIR)$(ICUPKGDATA_DIR))#M#
188 ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p $(DESTDIR)$(libdir) ; echo $(DESTDIR)$(libdir))#M#
190 ## Versioned import library names. The library names are versioned,
191 ## but the import libraries do not need versioning.
192 IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M#
193 MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M#
194 FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M#
196 # The following is for Makefile.inc's use.
197 ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
199 ## Versioned libraries rules
200 #%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
201 # $(RM) $@ && cp ${<F} $@
203 # The following rule is sometimes a no op.
204 # We only want to do a post-build step when a manifest file doesn't exist.
205 %.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
207 $(POST_SO_BUILD_STEP)
209 ## Install libraries as executable
210 INSTALL-L=$(INSTALL_PROGRAM)
212 # Environment variable to set a runtime search path
213 LDLIBRARYPATH_ENVVAR = PATH
215 # These are needed to allow the pkgdata nmake files to work
216 PKGDATA_INVOKE_OPTS = MAKEFLAGS=
218 # Include the version information in the shared library
219 ENABLE_SO_VERSION_DATA=1
221 ## End MSYS-specific setup