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