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