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