1## -*-makefile-*- 2## Copyright (C) 2016 and later: Unicode, Inc. and others. 3## License & terms of use: http://www.unicode.org/copyright.html 4## Cygwin/MinGW specific setup 5## Copyright (c) 2001-2014, International Business Machines Corporation and 6## others. All Rights Reserved. 7 8# TODO: Finish the rest of this port. This platform port is incomplete. 9 10# This file is similar to mh-mingw64 11# Any changes made here may also need to be made in mh-mingw64 12 13# On Windows we generally have the DLLs in the bin directory rather than the lib directory. 14# This setting moves the ICU DLLs into the bin folder for MinGW/MSYS2 when "make install" is run. 15# If you prefer to have the DLLs in the lib folder, then set this to NO instead. 16MINGW_MOVEDLLSTOBINDIR = YES 17 18# We install sbin tools into the same bin directory because 19# pkgdata needs some of the tools in sbin, and we can't always depend on 20# icu-config working on Windows. 21sbindir=$(bindir) 22 23## Commands to generate dependency files 24GEN_DEPS.c= $(CC) -E -MM $(DEFS) $(CPPFLAGS) 25GEN_DEPS.cc= $(CXX) -E -MM $(DEFS) $(CPPFLAGS) 26 27## Flags to create/use a static library 28ifneq ($(ENABLE_SHARED),YES) 29## Make sure that the static libraries can be built and used 30CPPFLAGS += -DU_STATIC_IMPLEMENTATION 31else 32## Make sure that the static libraries can be built 33STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION 34endif 35 36## ICU requires a minimum target of Windows 7, and MinGW does not set this by default. 37## https://msdn.microsoft.com/en-us/library/aa383745.aspx 38CPPFLAGS += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 39 40## Flags for position independent code 41SHAREDLIBCFLAGS = 42SHAREDLIBCXXFLAGS = 43SHAREDLIBCPPFLAGS = -DPIC 44 45## Additional flags when building libraries and with threads 46THREADSCFLAGS = -mthreads 47THREADSCXXFLAGS = -mthreads 48LIBCPPFLAGS = 49 50## Add 'd' suffix to the names of binary files with Debug configuration 51ifeq ($(ENABLE_DEBUG),1) 52ICULIBSUFFIX:=$(ICULIBSUFFIX)d#M# 53endif 54 55# Commands to link. Link with C++ in case static libraries are used. 56LINK.c= $(CXX) $(CXXFLAGS) $(LDFLAGS) 57#LINK.cc= $(CXX) $(CXXFLAGS) $(LDFLAGS) 58 59## Shared library options 60LD_SOOPTIONS= 61 62## Commands to make a shared library 63SHLIB.c= $(CC) $(CFLAGS) $(LDFLAGS) -shared $(LD_SOOPTIONS) -Wl,--enable-auto-import -Wl,--out-implib=$(dir $@)lib$(notdir $(@:$(SO_TARGET_VERSION_MAJOR).$(SO)=))$(IMPORT_LIB_EXT)#M# 64SHLIB.cc= $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(LD_SOOPTIONS) -Wl,--enable-auto-import -Wl,--out-implib=$(dir $@)lib$(notdir $(@:$(SO_TARGET_VERSION_MAJOR).$(SO)=))$(IMPORT_LIB_EXT)#M# 65 66## Compiler switch to embed a runtime search path 67LD_RPATH= 68LD_RPATH_PRE= -Wl,-rpath, 69 70## Compiler switch to embed a library name 71LD_SONAME = 72 73## Shared object suffix 74SO = dll 75## Non-shared intermediate object suffix 76STATIC_O = ao 77 78ifeq ($(ENABLE_SHARED),YES) 79SO_TARGET_VERSION_SUFFIX = $(SO_TARGET_VERSION_MAJOR) 80else 81SO_TARGET_VERSION_SUFFIX = 82endif 83 84# Static library prefix and file extension 85LIBSICU = $(LIBPREFIX)$(STATIC_PREFIX)$(ICUPREFIX) 86A = a 87 88## An import library is needed for z/OS and MSVC 89IMPORT_LIB_EXT = .dll.a 90 91LIBPREFIX=lib 92 93# Change the stubnames so that poorly working FAT disks and installation programs can work. 94# This is also for backwards compatibility. 95DATA_STUBNAME = dt 96I18N_STUBNAME = in 97LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX) 98 99#SH### copied from Makefile.inc 100#SH## for icu-config to test with 101#SH#ICULIBS_COMMON_LIB_NAME="${LIBICU}${COMMON_STUBNAME}${ICULIBSUFFIX}${ICULIBSUFFIX_VERSION}.${SO}" 102#SH#ICULIBS_COMMON_LIB_NAME_A="${LIBICU}${COMMON_STUBNAME}${ICULIBSUFFIX}.${A}" 103 104#SH#ICULIBS_DATA="-l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)" 105ICULIBS_DT="-l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)" 106ICULIBS_I18N="-l$(ICUPREFIX)$(I18N_STUBNAME)$(ICULIBSUFFIX)" 107ICULIBS_LX="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX)" 108ICULIBS_IO="-l$(ICUPREFIX)$(IO_STUBNAME)$(ICULIBSUFFIX)" 109ICULIBS_UC="-l$(ICUPREFIX)$(COMMON_STUBNAME)$(ICULIBSUFFIX)" 110ICULIBS_CTESTFW="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX)" 111ICULIBS_TOOLUTIL="-l$(ICUPREFIX)tu$(ICULIBSUFFIX)" 112#SH# 113#SH## ICULIBS is the set of libraries your application should link 114#SH## with usually. Many applications will want to add ${ICULIBS_I18N} as well. 115#SH#ICULIBS="${ICULIBS_BASE} ${ICULIBS_I18N} ${ICULIBS_COMMON} ${ICULIBS_DATA} " 116 117# Note: The #M# is used to delete lines for icu-config 118MSYS_VERSION ?= $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0)#M# 119$(info Detected MSYS version: $(MSYS_VERSION)) 120 121ifeq ($(MSYS_VERSION),$(filter $(MSYS_VERSION),0 1)) 122 # Older versions of MSYS don't have cygpath by default. #M# 123 124 # Current full path directory. #M# 125 #CURR_FULL_DIR=$(shell pwd -W)#M# for MSYS 126 CURR_FULL_DIR?=$(subst \,/,$(shell cmd /c cd))#M# for Cygwin shell 127 128 # Current full path directory for use in source code in a -D compiler option. #M# 129 #CURR_SRCCODE_FULL_DIR=$(subst /,\\\\,$(shell pwd -W))#M# for MSYS 130 CURR_SRCCODE_FULL_DIR=$(subst \,/,$(shell cmd /c cd))#M# for Cygwin shell 131else 132 # MSYS2 and up have cygpath by default #M# 133 134 # Current full path directory. #M# 135 CURR_FULL_DIR?=$(shell cygpath . -a -m)#M# 136 137 # Current full path directory for use in source code in a -D compiler option. #M# 138 CURR_SRCCODE_FULL_DIR=$(shell cygpath . -a -m)#M# 139endif 140 141## Compilation rules 142%.$(STATIC_O): $(srcdir)/%.c 143 $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $< 144%.o: $(srcdir)/%.c 145 $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $< 146 147%.$(STATIC_O): $(srcdir)/%.cpp 148 $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $< 149%.o: $(srcdir)/%.cpp 150 $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $< 151 152 153## Dependency rules 154%.d: $(srcdir)/%.c 155 @echo "generating dependency information for $<" 156 @echo -n "$@ " > $@ 157 @$(GEN_DEPS.c) $< >> $@ || (rm -f $@ && FALSE) 158 159%.d: $(srcdir)/%.cpp 160 @echo "generating dependency information for $<" 161 @echo -n "$@ " > $@ 162 @$(GEN_DEPS.cc) $< >> $@ || (rm -f $@ && FALSE) 163 164## Versioned target for a shared library. 165## Since symbolic links don't work the same way on Windows, 166## we only use the version major number. 167#FINAL_SO_TARGET=$(basename $(SO_TARGET))$(SO_TARGET_VERSION).$(SO) 168FINAL_SO_TARGET=$(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO) 169MIDDLE_SO_TARGET=$(FINAL_SO_TARGET) 170 171FINAL_IMPORT_LIB = $(dir $(SO_TARGET))lib$(notdir $(basename $(SO_TARGET)))$(IMPORT_LIB_EXT)#M# 172IMPORT_LIB = $(FINAL_IMPORT_LIB)#M# 173MIDDLE_IMPORT_LIB = $(FINAL_IMPORT_LIB)#M# 174 175## Special pkgdata information that is needed 176PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR) 177 178## Versioned libraries rules 179#%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO) 180# $(RM) $@ && cp ${<F} $@ 181%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO) 182 @echo -n 183 184# Environment variable to set a runtime search path 185LDLIBRARYPATH_ENVVAR = PATH 186 187# The type of assembly to write for generating an object file 188GENCCODE_ASSEMBLY=-a gcc-cygwin 189 190# These are needed to allow the pkgdata GNU make files to work 191PKGDATA_DEFS = -DU_MAKE=\"$(MAKE)\" 192 193## End Cygwin/MinGW specific setup 194 195