2 ## Copyright (C) 2016 and later: Unicode, Inc. and others.
3 ## License & terms of use: http://www.unicode.org/copyright.html
4 ## MSYS with Microsoft Visual C++ compiler specific setup
5 ## Copyright (c) 2014, International Business Machines Corporation and
6 ## others. All Rights Reserved.
8 # We install sbin tools into the same bin directory because
9 # pkgdata needs some of the tools in sbin, and we can't always depend on
10 # icu-config working on Windows.
13 # Need this option to use / instead of - when specifying options for the
17 ## Commands to generate dependency files
20 #GEN_DEPS.c= $(COMPILE.c) -E
21 #GEN_DEPS.cc= $(COMPILE.cc) -E
23 ## Flags to create/use a static library
24 ifneq ($(ENABLE_SHARED),YES)
25 ## Make sure that the static libraries can be built and used
26 CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M#
28 ## Make sure that the static libraries can be built
29 STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
32 ## Flags for position independent code
37 ## Additional flags when building libraries and with threads
40 ifeq ($(ENABLE_RELEASE),1)
41 # Make sure that assertions are disabled
42 CPPFLAGS+=-DU_RELEASE=1#M#
45 ifeq ($(ENABLE_DEBUG),1)
46 # Pass debugging flag through
47 CPPFLAGS+=-D_DEBUG=1#M#
48 ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M#
51 # -GF pools strings and places them into read-only memory
52 # -EHsc enables exception handling
53 # -Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility.
54 # -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions.
55 # -utf-8 set source file encoding to utf-8.
56 CFLAGS+=-GF -nologo -utf-8
57 CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t -utf-8
58 CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE
59 DEFS+=-DWIN32 -DCYGWINMSVC
63 COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
64 COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
67 LINK.c= LINK.EXE -subsystem:console $(LDFLAGS)
68 LINK.cc= LINK.EXE -subsystem:console $(LDFLAGS)
70 ## Commands to make a shared library
71 SHLIB.c= LINK.EXE -DLL $(LDFLAGS)
72 SHLIB.cc= LINK.EXE -DLL $(LDFLAGS)
74 ## Compiler switch to embed a runtime search path
78 ## Compiler switch to embed a library name
79 LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib)
81 ## Shared object suffix
83 ## Non-shared intermediate object suffix
85 # OUTOPT is for creating a specific output name
88 # Static library prefix and file extension
89 LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
92 # Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead.
94 ARFLAGS := -nologo $(ARFLAGS:r=)#M#
98 ## An import library is needed for z-OS, MSVC and Cygwin
102 DEFAULT_LIBS = advapi32.lib
104 # Change the stubnames so that poorly working FAT disks and installation programs can work.
105 # This is also for backwards compatibility.
108 LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
110 ## Link commands to link to ICU libs
111 ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),)
112 LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
114 LIBICUDT= $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
116 LIBICUUC= $(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
117 LIBICUI18N= $(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
118 LIBICULE= $(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
119 LIBICULX= $(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
120 LIBICUIO= $(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
121 LIBCTESTFW= $(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
122 LIBICUTOOLUTIL= $(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
124 ## These are the library specific LDFLAGS
125 LDFLAGSICUDT+= -base:"0x4ad00000" -NOENTRY# The NOENTRY option is required for creating a resource-only DLL.
126 LDFLAGSICUUC= -base:"0x4a800000"# in-uc = 1MB
127 LDFLAGSICUI18N= -base:"0x4a900000"# io-in = 2MB
128 LDFLAGSICUIO= -base:"0x4ab00000"# le-io = 1MB
129 LDFLAGSICULX= -base:"0x4ac80000"
130 LDFLAGSCTESTFW=# Unused for now.
131 LDFLAGSICUTOOLUTIL= -base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
134 %.$(STATIC_O): $(srcdir)/%.c
135 $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $<
137 $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $<
139 %.$(STATIC_O): $(srcdir)/%.cpp
140 $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $<
142 $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $<
146 ## This is a start to how depdendencies could work
147 # The commented out rules may not properly delete the file when ^C is pressed
148 # or the compiler fails.
149 # make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
150 # So system headers are ignored by ignoring \\
152 @echo "generating dependency information for $<"
153 @$(GEN_DEPS.c) $< > $@
154 # @echo -n "generating dependency information for "
155 # @echo -n "$@ $(basename $<).o : " > $@
156 # @$(SHELL) -ec '$(GEN_DEPS.c) $< \
157 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
158 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
159 # || (rm -f $@ && echo $@ && false)'
161 %.d : $(srcdir)/%.cpp
162 @echo "generating dependency information for $<"
163 @$(GEN_DEPS.cc) $< > $@
164 # @echo -n "generating dependency information for "
165 # @echo -n "$@ $(basename $<).o : " > $@
166 # @$(SHELL) -ec '$(GEN_DEPS.cc) $< \
167 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
168 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
169 # || (rm -f $@ && echo $@ && false)'
171 ## Compile a Windows resource file
172 %.res : $(srcdir)/%.rc
173 rc.exe -fo$@ $(CPPFLAGS) $<
175 ## Versioned target for a shared library.
176 FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
177 MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
179 ## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature.
180 POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \
181 ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \
183 POST_BUILD_STEP = @([ -e $@.manifest ] && \
184 ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \
187 ## Special pkgdata information that is needed
188 PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
189 ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p $(DESTDIR)$(ICUPKGDATA_DIR) ; echo $(DESTDIR)$(ICUPKGDATA_DIR))#M#
190 ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p $(DESTDIR)$(libdir) ; echo $(DESTDIR)$(libdir))#M#
192 ## Versioned import library names. The library names are versioned,
193 ## but the import libraries do not need versioning.
194 IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M#
195 MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M#
196 FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M#
198 # The following is for Makefile.inc's use.
199 ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
201 ## Versioned libraries rules
202 #%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
203 # $(RM) $@ && cp ${<F} $@
205 # The following rule is sometimes a no op.
206 # We only want to do a post-build step when a manifest file doesn't exist.
207 %.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
209 $(POST_SO_BUILD_STEP)
211 ## Install libraries as executable
212 INSTALL-L=$(INSTALL_PROGRAM)
214 # Environment variable to set a runtime search path
215 LDLIBRARYPATH_ENVVAR = PATH
217 # These are needed to allow the pkgdata nmake files to work
218 PKGDATA_INVOKE_OPTS = MAKEFLAGS=
220 # Include the version information in the shared library
221 ENABLE_SO_VERSION_DATA=1
223 ## End MSYS-specific setup