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