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