• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## -*-makefile-*-
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.
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.
11sbindir=$(bindir)
12
13# Need this option to use / instead of - when specifying options for the
14# rc.exe command
15MSYS_RC_MODE=1
16
17## Commands to generate dependency files
18GEN_DEPS.c=	:
19GEN_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
24ifneq ($(ENABLE_SHARED),YES)
25## Make sure that the static libraries can be built and used
26CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M#
27else
28## Make sure that the static libraries can be built
29STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
30endif
31
32## Flags for position independent code
33SHAREDLIBCFLAGS =
34SHAREDLIBCXXFLAGS =
35SHAREDLIBCPPFLAGS =
36
37## Additional flags when building libraries and with threads
38LIBCPPFLAGS =
39
40ifeq ($(ENABLE_RELEASE),1)
41# Make sure that assertions are disabled
42CPPFLAGS+=-DU_RELEASE=1#M#
43endif
44
45ifeq ($(ENABLE_DEBUG),1)
46# Pass debugging flag through
47CPPFLAGS+=-D_DEBUG=1#M#
48ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M#
49endif
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.
55CFLAGS+=-GF -nologo
56CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t
57CPPFLAGS+=-D_CRT_SECURE_NO_DEPRECATE
58DEFS+=-DWIN32 -DCYGWINMSVC
59LDFLAGS+=-nologo
60
61# Commands to compile
62COMPILE.c=	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c
63COMPILE.cc=	$(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c
64
65# Commands to link
66LINK.c=		LINK.EXE -subsystem:console $(LDFLAGS)
67LINK.cc=	LINK.EXE -subsystem:console $(LDFLAGS)
68
69## Commands to make a shared library
70SHLIB.c=	LINK.EXE -DLL $(LDFLAGS)
71SHLIB.cc=	LINK.EXE -DLL $(LDFLAGS)
72
73## Compiler switch to embed a runtime search path
74LD_RPATH=
75LD_RPATH_PRE=
76
77## Compiler switch to embed a library name
78LD_SONAME = -IMPLIB:$(SO_TARGET:.dll=.lib)
79
80## Shared object suffix
81SO = dll
82## Non-shared intermediate object suffix
83STATIC_O = ao
84# OUTOPT is for creating a specific output name
85OUTOPT = -out:
86
87# Static library prefix and file extension
88LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
89A = lib
90
91# Cygwin's ar can't handle Win64 right now. So we use Microsoft's tool instead.
92AR = LIB.EXE#M#
93ARFLAGS := -nologo $(ARFLAGS:r=)#M#
94RANLIB = ls -s#M#
95AR_OUTOPT = -OUT:#M#
96
97## An import library is needed for z-OS, MSVC and Cygwin
98IMPORT_LIB_EXT = .lib
99
100LIBPREFIX=
101DEFAULT_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.
105DATA_STUBNAME = dt
106I18N_STUBNAME = in
107LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
108
109## Link commands to link to ICU libs
110ifeq ($(wildcard $(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib),)
111LIBICUDT=	$(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
112else
113LIBICUDT=	$(LIBDIR)/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
114endif
115LIBICUUC=	$(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
116LIBICUI18N=	$(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
117LIBICULE=	$(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
118LIBICULX=	$(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
119LIBICUIO=	$(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
120LIBCTESTFW=	$(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
121LIBICUTOOLUTIL=	$(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
122
123## These are the library specific LDFLAGS
124LDFLAGSICUDT+=	-base:"0x4ad00000" -NOENTRY# The NOENTRY option is required for creating a resource-only DLL.
125LDFLAGSICUUC=	-base:"0x4a800000"# in-uc = 1MB
126LDFLAGSICUI18N=	-base:"0x4a900000"# io-in = 2MB
127LDFLAGSICUIO=	-base:"0x4ab00000"# le-io = 1MB
128LDFLAGSICULX=	-base:"0x4ac80000"
129LDFLAGSCTESTFW=# Unused for now.
130LDFLAGSICUTOOLUTIL=	-base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
131
132## Compilation rules
133%.$(STATIC_O): $(srcdir)/%.c
134	$(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $<
135%.o: $(srcdir)/%.c
136	$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $<
137
138%.$(STATIC_O): $(srcdir)/%.cpp
139	$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $<
140%.o: $(srcdir)/%.cpp
141	$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $<
142
143
144## Dependency rules
145## This is a start to how depdendencies could work
146# The commented out rules may not properly delete the file when ^C is pressed
147#   or the compiler fails.
148# make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
149#   So system headers are ignored by ignoring \\
150%.d : $(srcdir)/%.c
151	@echo "generating dependency information for $<"
152	@$(GEN_DEPS.c) $< > $@
153#	@echo -n "generating dependency information for "
154#	@echo -n "$@ $(basename $<).o : " > $@
155#	@$(SHELL) -ec '$(GEN_DEPS.c) $< \
156#		| grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
157#		| /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\	/ >> $@ \
158#		|| (rm -f $@ && echo $@ && false)'
159
160%.d : $(srcdir)/%.cpp
161	@echo "generating dependency information for $<"
162	@$(GEN_DEPS.cc) $< > $@
163#	@echo -n "generating dependency information for "
164#	@echo -n "$@ $(basename $<).o : " > $@
165#	@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
166#		| grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
167#		| /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\	/ >> $@ \
168#		|| (rm -f $@ && echo $@ && false)'
169
170## Compile a Windows resource file
171%.res : $(srcdir)/%.rc
172	rc.exe -fo$@ $(CPPFLAGS) $<
173
174## Versioned target for a shared library.
175FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
176MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
177
178## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature.
179	POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \
180	( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \
181	|| true
182	POST_BUILD_STEP = @([ -e $@.manifest ] && \
183	( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \
184	|| true
185
186## Special pkgdata information that is needed
187PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
188ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p  $(DESTDIR)$(ICUPKGDATA_DIR) ;  echo $(DESTDIR)$(ICUPKGDATA_DIR))#M#
189ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p  $(DESTDIR)$(libdir) ; echo $(DESTDIR)$(libdir))#M#
190
191## Versioned import library names. The library names are versioned,
192## but the import libraries do not need versioning.
193IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M#
194MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M#
195FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M#
196
197# The following is for Makefile.inc's use.
198ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR)
199
200## Versioned libraries rules
201#%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
202#	$(RM) $@ && cp ${<F} $@
203
204# The following rule is sometimes a no op.
205# We only want to do a post-build step when a manifest file doesn't exist.
206%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
207	@echo -n
208	$(POST_SO_BUILD_STEP)
209
210## Install libraries as executable
211INSTALL-L=$(INSTALL_PROGRAM)
212
213# Environment variable to set a runtime search path
214LDLIBRARYPATH_ENVVAR = PATH
215
216# These are needed to allow the pkgdata nmake files to work
217PKGDATA_INVOKE_OPTS = MAKEFLAGS=
218
219# Include the version information in the shared library
220ENABLE_SO_VERSION_DATA=1
221
222## End MSYS-specific setup
223