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