]>
Commit | Line | Data |
---|---|---|
b331163b | 1 | ## -*-makefile-*- |
f3c0d7a5 A |
2 | ## Copyright (C) 2016 and later: Unicode, Inc. and others. |
3 | ## License & terms of use: http://www.unicode.org/copyright.html | |
b331163b A |
4 | ## MSYS with Microsoft Visual C++ compiler specific setup |
5 | ## Copyright (c) 2014, International Business Machines Corporation and | |
6 | ## others. All Rights Reserved. | |
7 | ||
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. | |
11 | sbindir=$(bindir) | |
12 | ||
13 | # Need this option to use / instead of - when specifying options for the | |
14 | # rc.exe command | |
15 | MSYS_RC_MODE=1 | |
16 | ||
17 | ## Commands to generate dependency files | |
18 | GEN_DEPS.c= : | |
19 | GEN_DEPS.cc= : | |
20 | #GEN_DEPS.c= $(COMPILE.c) -E | |
21 | #GEN_DEPS.cc= $(COMPILE.cc) -E | |
22 | ||
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# | |
27 | else | |
28 | ## Make sure that the static libraries can be built | |
29 | STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION | |
30 | endif | |
31 | ||
32 | ## Flags for position independent code | |
33 | SHAREDLIBCFLAGS = | |
34 | SHAREDLIBCXXFLAGS = | |
35 | SHAREDLIBCPPFLAGS = | |
36 | ||
37 | ## Additional flags when building libraries and with threads | |
38 | LIBCPPFLAGS = | |
39 | ||
40 | ifeq ($(ENABLE_RELEASE),1) | |
41 | # Make sure that assertions are disabled | |
42 | CPPFLAGS+=-DU_RELEASE=1#M# | |
43 | endif | |
44 | ||
45 | ifeq ($(ENABLE_DEBUG),1) | |
46 | # Pass debugging flag through | |
47 | CPPFLAGS+=-D_DEBUG=1#M# | |
48 | ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M# | |
49 | endif | |
50 | ||
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. | |
f3c0d7a5 A |
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 | |
b331163b A |
58 | CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE |
59 | DEFS+=-DWIN32 -DCYGWINMSVC | |
60 | LDFLAGS+=-nologo | |
61 | ||
62 | # Commands to compile | |
63 | COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c | |
64 | COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c | |
65 | ||
66 | # Commands to link | |
67 | LINK.c= LINK.EXE -subsystem:console $(LDFLAGS) | |
68 | LINK.cc= LINK.EXE -subsystem:console $(LDFLAGS) | |
69 | ||
70 | ## Commands to make a shared library | |
71 | SHLIB.c= LINK.EXE -DLL $(LDFLAGS) | |
72 | SHLIB.cc= LINK.EXE -DLL $(LDFLAGS) | |
73 | ||
74 | ## Compiler switch to embed a runtime search path | |
75 | LD_RPATH= | |
76 | LD_RPATH_PRE= | |
77 | ||
78 | ## Compiler switch to embed a library name | |
79 | LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib) | |
80 | ||
81 | ## Shared object suffix | |
82 | SO = dll | |
83 | ## Non-shared intermediate object suffix | |
84 | STATIC_O = ao | |
85 | # OUTOPT is for creating a specific output name | |
86 | OUTOPT = -out: | |
87 | ||
88 | # Static library prefix and file extension | |
89 | LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX) | |
90 | A = lib | |
91 | ||
92 | # Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead. | |
93 | AR = LIB.EXE#M# | |
94 | ARFLAGS := -nologo $(ARFLAGS:r=)#M# | |
95 | RANLIB = ls -s#M# | |
96 | AR_OUTOPT = -OUT:#M# | |
97 | ||
98 | ## An import library is needed for z-OS, MSVC and Cygwin | |
99 | IMPORT_LIB_EXT = .lib | |
100 | ||
101 | LIBPREFIX= | |
102 | DEFAULT_LIBS = advapi32.lib | |
103 | ||
104 | # Change the stubnames so that poorly working FAT disks and installation programs can work. | |
105 | # This is also for backwards compatibility. | |
106 | DATA_STUBNAME = dt | |
107 | I18N_STUBNAME = in | |
108 | LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX) | |
109 | ||
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 | |
113 | else | |
114 | LIBICUDT= $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib | |
115 | endif | |
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 | |
123 | ||
124 | ## These are the library specific LDFLAGS | |
340931cb A |
125 | LDFLAGSICUDT+= -NOENTRY# The NOENTRY option is required for creating a resource-only DLL. |
126 | LDFLAGSICUUC=# Unused for now. | |
127 | LDFLAGSICUI18N=# Unused for now. | |
128 | LDFLAGSICUIO=# Unused for now. | |
129 | LDFLAGSICULX=# Unused for now. | |
b331163b | 130 | LDFLAGSCTESTFW=# Unused for now. |
340931cb | 131 | LDFLAGSICUTOOLUTIL=# Unused for now. |
b331163b A |
132 | |
133 | ## Compilation rules | |
134 | %.$(STATIC_O): $(srcdir)/%.c | |
135 | $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $< | |
136 | %.o: $(srcdir)/%.c | |
137 | $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $< | |
138 | ||
139 | %.$(STATIC_O): $(srcdir)/%.cpp | |
140 | $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $< | |
141 | %.o: $(srcdir)/%.cpp | |
142 | $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $< | |
143 | ||
144 | ||
145 | ## Dependency rules | |
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 \\ | |
151 | %.d : $(srcdir)/%.c | |
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)' | |
160 | ||
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)' | |
170 | ||
171 | ## Compile a Windows resource file | |
172 | %.res : $(srcdir)/%.rc | |
173 | rc.exe -fo$@ $(CPPFLAGS) $< | |
174 | ||
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) | |
178 | ||
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 )) \ | |
182 | || true | |
183 | POST_BUILD_STEP = @([ -e $@.manifest ] && \ | |
184 | ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \ | |
185 | || true | |
186 | ||
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# | |
191 | ||
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# | |
197 | ||
198 | # The following is for Makefile.inc's use. | |
199 | ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR) | |
200 | ||
201 | ## Versioned libraries rules | |
202 | #%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO) | |
203 | # $(RM) $@ && cp ${<F} $@ | |
204 | ||
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) | |
208 | @echo -n | |
209 | $(POST_SO_BUILD_STEP) | |
210 | ||
211 | ## Install libraries as executable | |
212 | INSTALL-L=$(INSTALL_PROGRAM) | |
213 | ||
214 | # Environment variable to set a runtime search path | |
215 | LDLIBRARYPATH_ENVVAR = PATH | |
216 | ||
217 | # These are needed to allow the pkgdata nmake files to work | |
218 | PKGDATA_INVOKE_OPTS = MAKEFLAGS= | |
219 | ||
220 | # Include the version information in the shared library | |
221 | ENABLE_SO_VERSION_DATA=1 | |
222 | ||
223 | ## End MSYS-specific setup |