]>
Commit | Line | Data |
---|---|---|
73c04bcf | 1 | ## Cygwin with Microsoft Visual C++ compiler specific setup |
f3c0d7a5 A |
2 | ## Copyright (C) 2016 and later: Unicode, Inc. and others. |
3 | ## License & terms of use: http://www.unicode.org/copyright.html | |
51004dcb | 4 | ## Copyright (c) 2001-2013, International Business Machines Corporation and |
b75a7d8f | 5 | ## others. All Rights Reserved. |
374ca955 A |
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) | |
b75a7d8f A |
11 | |
12 | ## Commands to generate dependency files | |
13 | GEN_DEPS.c= : | |
14 | GEN_DEPS.cc= : | |
57a6839d A |
15 | #GEN_DEPS.c= $(COMPILE.c) -E |
16 | #GEN_DEPS.cc= $(COMPILE.cc) -E | |
374ca955 A |
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 | |
73c04bcf | 21 | CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M# |
374ca955 A |
22 | else |
23 | ## Make sure that the static libraries can be built | |
24 | STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION | |
25 | endif | |
b75a7d8f | 26 | |
3d1f044b A |
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 | ||
b75a7d8f A |
31 | ## Flags for position independent code |
32 | SHAREDLIBCFLAGS = | |
33 | SHAREDLIBCXXFLAGS = | |
34 | SHAREDLIBCPPFLAGS = | |
35 | ||
36 | ## Additional flags when building libraries and with threads | |
37 | LIBCPPFLAGS = | |
b75a7d8f | 38 | |
374ca955 A |
39 | ifeq ($(ENABLE_RELEASE),1) |
40 | # Make sure that assertions are disabled | |
46f4442e | 41 | CPPFLAGS+=-DU_RELEASE=1#M# |
374ca955 A |
42 | endif |
43 | ||
73c04bcf A |
44 | ifeq ($(ENABLE_DEBUG),1) |
45 | # Pass debugging flag through | |
46f4442e A |
46 | CPPFLAGS+=-D_DEBUG=1#M# |
47 | ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M# | |
73c04bcf A |
48 | endif |
49 | ||
374ca955 | 50 | # /GF pools strings and places them into read-only memory |
73c04bcf A |
51 | # /EHsc enables exception handling |
52 | # /Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility. | |
46f4442e | 53 | # -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions. |
f3c0d7a5 A |
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 | |
46f4442e | 57 | CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE |
4388f060 | 58 | DEFS+=-DWIN32 -DCYGWINMSVC |
57a6839d | 59 | LDFLAGS+=-nologo |
b75a7d8f A |
60 | |
61 | # Commands to compile | |
57a6839d A |
62 | COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c |
63 | COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c | |
b75a7d8f A |
64 | |
65 | # Commands to link | |
57a6839d A |
66 | LINK.c= LINK.EXE -subsystem:console $(LDFLAGS) |
67 | LINK.cc= LINK.EXE -subsystem:console $(LDFLAGS) | |
b75a7d8f A |
68 | |
69 | ## Commands to make a shared library | |
57a6839d A |
70 | SHLIB.c= LINK.EXE -DLL $(LDFLAGS) |
71 | SHLIB.cc= LINK.EXE -DLL $(LDFLAGS) | |
b75a7d8f A |
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 | |
57a6839d | 78 | LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib) |
b75a7d8f A |
79 | |
80 | ## Shared object suffix | |
81 | SO = dll | |
82 | ## Non-shared intermediate object suffix | |
374ca955 | 83 | STATIC_O = ao |
b75a7d8f | 84 | # OUTOPT is for creating a specific output name |
57a6839d | 85 | OUTOPT = -out: |
b75a7d8f | 86 | |
374ca955 A |
87 | # Static library prefix and file extension |
88 | LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX) | |
89 | A = lib | |
90 | ||
46f4442e A |
91 | # Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead. |
92 | AR = LIB.EXE#M# | |
57a6839d | 93 | ARFLAGS := -nologo $(ARFLAGS:r=)#M# |
46f4442e | 94 | RANLIB = ls -s#M# |
57a6839d | 95 | AR_OUTOPT = -OUT:#M# |
46f4442e | 96 | |
729e4ab9 | 97 | ## An import library is needed for z/OS, MSVC and Cygwin |
b75a7d8f A |
98 | IMPORT_LIB_EXT = .lib |
99 | ||
374ca955 A |
100 | LIBPREFIX= |
101 | DEFAULT_LIBS = advapi32.lib | |
b75a7d8f | 102 | |
374ca955 A |
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) | |
b75a7d8f | 108 | |
374ca955 | 109 | ## Link commands to link to ICU libs |
46f4442e | 110 | ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),) |
374ca955 | 111 | LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib |
46f4442e A |
112 | else |
113 | LIBICUDT= $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib | |
114 | endif | |
374ca955 A |
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 | |
340931cb A |
124 | LDFLAGSICUDT+= -NOENTRY# The NOENTRY option is required for creating a resource-only DLL. |
125 | LDFLAGSICUUC=# Unused for now. | |
126 | LDFLAGSICUI18N=# Unused for now. | |
127 | LDFLAGSICUIO=# Unused for now. | |
128 | LDFLAGSICULX=# Unused for now. | |
374ca955 | 129 | LDFLAGSCTESTFW=# Unused for now. |
340931cb | 130 | LDFLAGSICUTOOLUTIL=# Unused for now. |
374ca955 A |
131 | |
132 | # The #M# is used to delete lines for icu-config | |
133 | # Current full path directory. | |
51004dcb | 134 | CURR_FULL_DIR?=$(subst \,/,$(shell cygpath -da .))#M# -m isn't used because it doesn't work on Win98 |
374ca955 | 135 | # Current full path directory for use in source code in a -D compiler option. |
73c04bcf | 136 | CURR_SRCCODE_FULL_DIR=$(subst \,\\,$(shell cygpath -da .))#M# |
374ca955 A |
137 | |
138 | ifeq ($(srcdir),.) | |
139 | SOURCE_FILE=$< | |
140 | else | |
141 | SOURCE_FILE=$(shell cygpath -dma $<)#M# | |
142 | endif | |
b75a7d8f A |
143 | |
144 | ## Compilation rules | |
145 | %.$(STATIC_O): $(srcdir)/%.c | |
57a6839d | 146 | $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $(SOURCE_FILE) |
b75a7d8f | 147 | %.o: $(srcdir)/%.c |
57a6839d | 148 | $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $(SOURCE_FILE) |
b75a7d8f A |
149 | |
150 | %.$(STATIC_O): $(srcdir)/%.cpp | |
57a6839d | 151 | $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $(SOURCE_FILE) |
b75a7d8f | 152 | %.o: $(srcdir)/%.cpp |
57a6839d | 153 | $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $(SOURCE_FILE) |
b75a7d8f | 154 | |
b75a7d8f A |
155 | |
156 | ## Dependency rules | |
374ca955 A |
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 \\ | |
b75a7d8f A |
162 | %.d : $(srcdir)/%.c |
163 | @echo "generating dependency information for $<" | |
164 | @$(GEN_DEPS.c) $< > $@ | |
374ca955 A |
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)' | |
b75a7d8f A |
171 | |
172 | %.d : $(srcdir)/%.cpp | |
173 | @echo "generating dependency information for $<" | |
174 | @$(GEN_DEPS.cc) $< > $@ | |
374ca955 A |
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)' | |
b75a7d8f A |
181 | |
182 | ## Compile a Windows resource file | |
183 | %.res : $(srcdir)/%.rc | |
57a6839d | 184 | rc.exe -fo$@ $(CPPFLAGS) $(SOURCE_FILE) |
b75a7d8f A |
185 | |
186 | ## Versioned target for a shared library. | |
374ca955 A |
187 | FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO) |
188 | MIDDLE_SO_TARGET=$(FINAL_SO_TARGET) | |
b75a7d8f | 189 | |
46f4442e A |
190 | ## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature. |
191 | POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \ | |
729e4ab9 | 192 | ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \ |
46f4442e | 193 | || true |
729e4ab9 A |
194 | POST_BUILD_STEP = @([ -e $@.manifest ] && \ |
195 | ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \ | |
46f4442e A |
196 | || true |
197 | ||
374ca955 A |
198 | ## Special pkgdata information that is needed |
199 | PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR) | |
729e4ab9 A |
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# | |
374ca955 A |
202 | |
203 | ## Versioned import library names. The library names are versioned, | |
204 | ## but the import libraries do not need versioning. | |
73c04bcf A |
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) | |
b75a7d8f A |
211 | |
212 | ## Versioned libraries rules | |
213 | #%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO) | |
374ca955 | 214 | # $(RM) $@ && cp ${<F} $@ |
46f4442e A |
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. | |
b75a7d8f | 218 | %.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO) |
374ca955 | 219 | @echo -n |
46f4442e | 220 | $(POST_SO_BUILD_STEP) |
b75a7d8f | 221 | |
374ca955 A |
222 | ## Install libraries as executable |
223 | INSTALL-L=$(INSTALL_PROGRAM) | |
b75a7d8f A |
224 | |
225 | # Environment variable to set a runtime search path | |
226 | LDLIBRARYPATH_ENVVAR = PATH | |
227 | ||
374ca955 | 228 | # These are needed to allow the pkgdata nmake files to work |
374ca955 A |
229 | PKGDATA_INVOKE_OPTS = MAKEFLAGS= |
230 | ||
231 | # Include the version information in the shared library | |
232 | ENABLE_SO_VERSION_DATA=1 | |
233 | ||
b75a7d8f A |
234 | ## End Cygwin-specific setup |
235 |