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. 10sbindir=$(bindir) 11 12## Commands to generate dependency files 13GEN_DEPS.c= : 14GEN_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 19ifneq ($(ENABLE_SHARED),YES) 20## Make sure that the static libraries can be built and used 21CPPFLAGS += -DU_STATIC_IMPLEMENTATION#M# 22else 23## Make sure that the static libraries can be built 24STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION 25endif 26 27## ICU requires a minimum target of Windows 7, and WINVER is not set to this by default. 28## https://msdn.microsoft.com/en-us/library/aa383745.aspx 29CPPFLAGS += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 30 31## Flags for position independent code 32SHAREDLIBCFLAGS = 33SHAREDLIBCXXFLAGS = 34SHAREDLIBCPPFLAGS = 35 36## Additional flags when building libraries and with threads 37LIBCPPFLAGS = 38 39ifeq ($(ENABLE_RELEASE),1) 40# Make sure that assertions are disabled 41CPPFLAGS+=-DU_RELEASE=1#M# 42endif 43 44ifeq ($(ENABLE_DEBUG),1) 45# Pass debugging flag through 46CPPFLAGS+=-D_DEBUG=1#M# 47ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M# 48endif 49 50# /GF pools strings and places them into read-only memory 51# /EHsc enables exception handling 52# /Zc:wchar_t makes wchar_t a native type. Required for C++ ABI compatibility. 53# -D_CRT_SECURE_NO_DEPRECATE is needed to quiet warnings about using standard C functions. 54# -utf-8 set source file encoding to utf-8. 55CFLAGS+=-GF -nologo -utf-8 56CXXFLAGS+=-GF -nologo -EHsc -Zc:wchar_t -utf-8 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+= -NOENTRY# The NOENTRY option is required for creating a resource-only DLL. 125LDFLAGSICUUC=# Unused for now. 126LDFLAGSICUI18N=# Unused for now. 127LDFLAGSICUIO=# Unused for now. 128LDFLAGSICULX=# Unused for now. 129LDFLAGSCTESTFW=# Unused for now. 130LDFLAGSICUTOOLUTIL=# Unused for now. 131 132# The #M# is used to delete lines for icu-config 133# Current full path directory. 134CURR_FULL_DIR?=$(subst \,/,$(shell cygpath -da .))#M# -m isn't used because it doesn't work on Win98 135# Current full path directory for use in source code in a -D compiler option. 136CURR_SRCCODE_FULL_DIR=$(subst \,\\,$(shell cygpath -da .))#M# 137 138ifeq ($(srcdir),.) 139SOURCE_FILE=$< 140else 141SOURCE_FILE=$(shell cygpath -dma $<)#M# 142endif 143 144## Compilation rules 145%.$(STATIC_O): $(srcdir)/%.c 146 $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -Fo$@ $(SOURCE_FILE) 147%.o: $(srcdir)/%.c 148 $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -Fo$@ $(SOURCE_FILE) 149 150%.$(STATIC_O): $(srcdir)/%.cpp 151 $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -Fo$@ $(SOURCE_FILE) 152%.o: $(srcdir)/%.cpp 153 $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -Fo$@ $(SOURCE_FILE) 154 155 156## Dependency rules 157## This is a start to how dependencies could work 158# The commented out rules may not properly delete the file when ^C is pressed 159# or the compiler fails. 160# make currently doesn't like rules with C:\\PROGRA~1\\.. in the dependency. 161# So system headers are ignored by ignoring \\ 162%.d : $(srcdir)/%.c 163 @echo "generating dependency information for $<" 164 @$(GEN_DEPS.c) $< > $@ 165# @echo -n "generating dependency information for " 166# @echo -n "$@ $(basename $<).o : " > $@ 167# @$(SHELL) -ec '$(GEN_DEPS.c) $< \ 168# | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \ 169# | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \ 170# || (rm -f $@ && echo $@ && false)' 171 172%.d : $(srcdir)/%.cpp 173 @echo "generating dependency information for $<" 174 @$(GEN_DEPS.cc) $< > $@ 175# @echo -n "generating dependency information for " 176# @echo -n "$@ $(basename $<).o : " > $@ 177# @$(SHELL) -ec '$(GEN_DEPS.cc) $< \ 178# | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \ 179# | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \ 180# || (rm -f $@ && echo $@ && false)' 181 182## Compile a Windows resource file 183%.res : $(srcdir)/%.rc 184 rc.exe -fo$@ $(CPPFLAGS) $(SOURCE_FILE) 185 186## Versioned target for a shared library. 187FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO) 188MIDDLE_SO_TARGET=$(FINAL_SO_TARGET) 189 190## Starting in MSVC 2005, manifest files are required. This reduces the obnoxiousness of this feature. 191 POST_SO_BUILD_STEP = @([ -e $<.manifest ] && \ 192 ( echo Embedding manifest into $< && mt.exe -nologo -manifest $<.manifest -outputresource:"$<;2" && rm -rf $<.manifest )) \ 193 || true 194 POST_BUILD_STEP = @([ -e $@.manifest ] && \ 195 ( echo Embedding manifest into $@ && mt.exe -nologo -manifest $@.manifest -outputresource:"$@;1" && rm -rf $@.manifest )) \ 196 || true 197 198## Special pkgdata information that is needed 199PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR) 200ICUPKGDATA_INSTALL_DIR = $(shell mkdir -p $(DESTDIR)$(ICUPKGDATA_DIR) ; cygpath -dma $(DESTDIR)$(ICUPKGDATA_DIR))#M# 201ICUPKGDATA_INSTALL_LIBDIR = $(shell mkdir -p $(DESTDIR)$(libdir) ; cygpath -dma $(DESTDIR)$(libdir))#M# 202 203## Versioned import library names. The library names are versioned, 204## but the import libraries do not need versioning. 205IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)#M# 206MIDDLE_IMPORT_LIB = $(IMPORT_LIB)#M# 207FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)#M# 208 209# The following is for Makefile.inc's use. 210ICULIBSUFFIX_VERSION = $(LIB_VERSION_MAJOR) 211 212## Versioned libraries rules 213#%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO) 214# $(RM) $@ && cp ${<F} $@ 215 216# The following rule is sometimes a no op. 217# We only want to do a post-build step when a manifest file doesn't exist. 218%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO) 219 @echo -n 220 $(POST_SO_BUILD_STEP) 221 222## Install libraries as executable 223INSTALL-L=$(INSTALL_PROGRAM) 224 225# Environment variable to set a runtime search path 226LDLIBRARYPATH_ENVVAR = PATH 227 228# These are needed to allow the pkgdata nmake files to work 229PKGDATA_INVOKE_OPTS = MAKEFLAGS= 230 231# Include the version information in the shared library 232ENABLE_SO_VERSION_DATA=1 233 234## End Cygwin-specific setup 235 236