]> git.saurik.com Git - apple/icu.git/blob - icuSources/config/mh-cygwin-msvc
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / config / mh-cygwin-msvc
1 ## Cygwin with Microsoft Visual C++ compiler specific setup
2 ## Copyright (C) 2016 and later: Unicode, Inc. and others.
3 ## License & terms of use: http://www.unicode.org/copyright.html
4 ## Copyright (c) 2001-2013, International Business Machines Corporation and
5 ## others. All Rights Reserved.
6
7 # We install sbin tools into the same bin directory because
8 # pkgdata needs some of the tools in sbin, and we can't always depend on
9 # icu-config working on Windows.
10 sbindir=$(bindir)
11
12 ## Commands to generate dependency files
13 GEN_DEPS.c= :
14 GEN_DEPS.cc= :
15 #GEN_DEPS.c= $(COMPILE.c) -E
16 #GEN_DEPS.cc= $(COMPILE.cc) -E
17
18 ## Flags to create/use a static library
19 ifneq ($(ENABLE_SHARED),YES)
20 ## Make sure that the static libraries can be built and used
21 CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M#
22 else
23 ## Make sure that the static libraries can be built
24 STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
25 endif
26
27 ## ICU requires a minimum target of Windows 7, and WINVER is not set to this by default.
28 ## https://msdn.microsoft.com/en-us/library/aa383745.aspx
29 CPPFLAGS += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601
30
31 ## Flags for position independent code
32 SHAREDLIBCFLAGS =
33 SHAREDLIBCXXFLAGS =
34 SHAREDLIBCPPFLAGS =
35
36 ## Additional flags when building libraries and with threads
37 LIBCPPFLAGS =
38
39 ifeq ($(ENABLE_RELEASE),1)
40 # Make sure that assertions are disabled
41 CPPFLAGS+=-DU_RELEASE=1#M#
42 endif
43
44 ifeq ($(ENABLE_DEBUG),1)
45 # Pass debugging flag through
46 CPPFLAGS+=-D_DEBUG=1#M#
47 ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M#
48 endif
49
50 # /GF pools strings and places them into read-only memory
51 # /EHsc enables exception handling
52 # /Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility.
53 # -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions.
54 # -utf-8 set source file encoding to utf-8.
55 CFLAGS+=-GF -nologo -utf-8
56 CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t -utf-8
57 CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE
58 DEFS+=-DWIN32 -DCYGWINMSVC
59 LDFLAGS+=-nologo
60
61 # Commands to compile
62 COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
63 COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
64
65 # Commands to link
66 LINK.c= LINK.EXE -subsystem:console $(LDFLAGS)
67 LINK.cc= LINK.EXE -subsystem:console $(LDFLAGS)
68
69 ## Commands to make a shared library
70 SHLIB.c= LINK.EXE -DLL $(LDFLAGS)
71 SHLIB.cc= LINK.EXE -DLL $(LDFLAGS)
72
73 ## Compiler switch to embed a runtime search path
74 LD_RPATH=
75 LD_RPATH_PRE=
76
77 ## Compiler switch to embed a library name
78 LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib)
79
80 ## Shared object suffix
81 SO = dll
82 ## Non-shared intermediate object suffix
83 STATIC_O = ao
84 # OUTOPT is for creating a specific output name
85 OUTOPT = -out:
86
87 # Static library prefix and file extension
88 LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
89 A = lib
90
91 # Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead.
92 AR = LIB.EXE#M#
93 ARFLAGS := -nologo $(ARFLAGS:r=)#M#
94 RANLIB = ls -s#M#
95 AR_OUTOPT = -OUT:#M#
96
97 ## An import library is needed for z/OS, MSVC and Cygwin
98 IMPORT_LIB_EXT = .lib
99
100 LIBPREFIX=
101 DEFAULT_LIBS = advapi32.lib
102
103 # Change the stubnames so that poorly working FAT disks and installation programs can work.
104 # This is also for backwards compatibility.
105 DATA_STUBNAME = dt
106 I18N_STUBNAME = in
107 LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
108
109 ## Link commands to link to ICU libs
110 ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),)
111 LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
112 else
113 LIBICUDT= $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
114 endif
115 LIBICUUC= $(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
116 LIBICUI18N= $(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
117 LIBICULE= $(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
118 LIBICULX= $(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
119 LIBICUIO= $(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
120 LIBCTESTFW= $(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
121 LIBICUTOOLUTIL= $(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
122
123 ## These are the library specific LDFLAGS
124 LDFLAGSICUDT+= -base:"0x4ad00000" -NOENTRY# The NOENTRY option is required for creating a resource-only DLL.
125 LDFLAGSICUUC= -base:"0x4a800000"# in-uc = 1MB
126 LDFLAGSICUI18N= -base:"0x4a900000"# io-in = 2MB
127 LDFLAGSICUIO= -base:"0x4ab00000"# le-io = 1MB
128 LDFLAGSICULX= -base:"0x4ac80000"
129 LDFLAGSCTESTFW=# Unused for now.
130 LDFLAGSICUTOOLUTIL= -base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
131
132 # The #M# is used to delete lines for icu-config
133 # Current full path directory.
134 CURR_FULL_DIR?=$(subst \,/,$(shell cygpath -da .))#M# -m isn't used because it doesn't work on Win98
135 # Current full path directory for use in source code in a -D compiler option.
136 CURR_SRCCODE_FULL_DIR=$(subst \,\\,$(shell cygpath -da .))#M#
137
138 ifeq ($(srcdir),.)
139 SOURCE_FILE=$<
140 else
141 SOURCE_FILE=$(shell cygpath -dma $<)#M#
142 endif
143
144 ## Compilation rules
145 %.$(STATIC_O): $(srcdir)/%.c
146 $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $(SOURCE_FILE)
147 %.o: $(srcdir)/%.c
148 $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $(SOURCE_FILE)
149
150 %.$(STATIC_O): $(srcdir)/%.cpp
151 $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $(SOURCE_FILE)
152 %.o: $(srcdir)/%.cpp
153 $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $(SOURCE_FILE)
154
155
156 ## Dependency rules
157 ## This is a start to how depdendencies could work
158 # The commented out rules may not properly delete the file when ^C is pressed
159 # or the compiler fails.
160 # make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
161 # So system headers are ignored by ignoring \\
162 %.d : $(srcdir)/%.c
163 @echo "generating dependency information for $<"
164 @$(GEN_DEPS.c) $< > $@
165 # @echo -n "generating dependency information for "
166 # @echo -n "$@ $(basename $<).o : " > $@
167 # @$(SHELL) -ec '$(GEN_DEPS.c) $< \
168 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
169 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
170 # || (rm -f $@ && echo $@ && false)'
171
172 %.d : $(srcdir)/%.cpp
173 @echo "generating dependency information for $<"
174 @$(GEN_DEPS.cc) $< > $@
175 # @echo -n "generating dependency information for "
176 # @echo -n "$@ $(basename $<).o : " > $@
177 # @$(SHELL) -ec '$(GEN_DEPS.cc) $< \
178 # | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
179 # | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
180 # || (rm -f $@ && echo $@ && false)'
181
182 ## Compile a Windows resource file
183 %.res : $(srcdir)/%.rc
184 rc.exe -fo$@ $(CPPFLAGS) $(SOURCE_FILE)
185
186 ## Versioned target for a shared library.
187 FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
188 MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
189
190 ## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature.
191 POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \
192 ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \
193 || true
194 POST_BUILD_STEP = @([ -e $@.manifest ] && \
195 ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \
196 || true
197
198 ## Special pkgdata information that is needed
199 PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
200 ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p $(DESTDIR)$(ICUPKGDATA_DIR) ; cygpath -dma $(DESTDIR)$(ICUPKGDATA_DIR))#M#
201 ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p $(DESTDIR)$(libdir) ; cygpath -dma $(DESTDIR)$(libdir))#M#
202
203 ## Versioned import library names. The library names are versioned,
204 ## but the import libraries do not need versioning.
205 IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M#
206 MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M#
207 FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M#
208
209 # The following is for Makefile.inc's use.
210 ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
211
212 ## Versioned libraries rules
213 #%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
214 # $(RM) $@ && cp ${<F} $@
215
216 # The following rule is sometimes a no op.
217 # We only want to do a post-build step when a manifest file doesn't exist.
218 %.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
219 @echo -n
220 $(POST_SO_BUILD_STEP)
221
222 ## Install libraries as executable
223 INSTALL-L=$(INSTALL_PROGRAM)
224
225 # Environment variable to set a runtime search path
226 LDLIBRARYPATH_ENVVAR = PATH
227
228 # These are needed to allow the pkgdata nmake files to work
229 PKGDATA_INVOKE_OPTS = MAKEFLAGS=
230
231 # Include the version information in the shared library
232 ENABLE_SO_VERSION_DATA=1
233
234 ## End Cygwin-specific setup
235