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