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