-## -*-makefile-*-
## Cygwin-specific setup
-## Copyright (c) 2001-2003, International Business Machines Corporation and
+## Copyright (c) 2001-2004, International Business Machines Corporation and
## others. All Rights Reserved.
-##
-## $Id: mh-cygwin-msvc,v 1.1.1.1 2003/07/03 18:13:33 avery Exp $
+
+# We install sbin tools into the same bin directory because
+# pkgdata needs some of the tools in sbin, and we can't always depend on
+# icu-config working on Windows.
+sbindir=$(bindir)
## Commands to generate dependency files
GEN_DEPS.c= :
GEN_DEPS.cc= :
+#GEN_DEPS.c= $(COMPILE.c) /E
+#GEN_DEPS.cc= $(COMPILE.cc) /E
+
+## Flags to create/use a static library
+ifneq ($(ENABLE_SHARED),YES)
+## Make sure that the static libraries can be built and used
+CPPFLAGS += -DU_STATIC_IMPLEMENTATION
+else
+## Make sure that the static libraries can be built
+STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
+endif
## Flags for position independent code
SHAREDLIBCFLAGS =
## Additional flags when building libraries and with threads
LIBCPPFLAGS =
-THREADSCPPFLAGS =
+ifeq ($(ENABLE_DEBUG),1)
+# /MDd means 'compiles and links a debugable multithreaded program with DLL'
+THREADSCFLAGS += /MDd
+THREADSCXXFLAGS += /MDd
+# The debug flags are defined here because configure can't handle them.
+CFLAGS+=/Zi
+CXXFLAGS+=/Zi
+LDFLAGS+=/DEBUG
+else
+# /MD means 'compiles and links a multithreaded program with DLL'
+THREADSCFLAGS += /MD
+THREADSCXXFLAGS += /MD
+endif
+
+ifeq ($(ENABLE_RELEASE),1)
+# Make sure that assertions are disabled
+CPPFLAGS+=-DU_RELEASE=1
+endif
+
+# /GF pools strings and places them into read-only memory
+# /GX enables exception handling
+CFLAGS += /GF
+CXXFLAGS += /GF /GX
CPPFLAGS+=/nologo
-DEFS+=/D"WIN32"
+DEFS+=-DWIN32
LDFLAGS+=/nologo
# Commands to compile
-COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) /GF /c
-COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) /GF /c
+COMPILE.c= $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) /c
+COMPILE.cc= $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) /c
# Commands to link
LINK.c= LINK.EXE /subsystem:console $(LDFLAGS)
LINK.cc= LINK.EXE /subsystem:console $(LDFLAGS)
## Commands to make a shared library
-SHLIB.c= LINK.EXE /DLL $(LDFLAGS)
-SHLIB.cc= LINK.EXE /DLL $(LDFLAGS)
+SHLIB.c= LINK.EXE /subsystem:console /DLL $(LDFLAGS)
+SHLIB.cc= LINK.EXE /subsystem:console /DLL $(LDFLAGS)
## Compiler switch to embed a runtime search path
LD_RPATH=
LD_RPATH_PRE=
## Compiler switch to embed a library name
-LD_SONAME =
+LD_SONAME = /IMPLIB:$(SO_TARGET:.dll=.lib)
## Shared object suffix
SO = dll
## Non-shared intermediate object suffix
-STATIC_O = o
+STATIC_O = ao
# OUTOPT is for creating a specific output name
OUTOPT = /out:
+# Static library prefix and file extension
+LIBSICU = $(STATIC_PREFIX)$(ICUPREFIX)
+A = lib
+
## An import library is needed for z/OS and MSVC
IMPORT_LIB_EXT = .lib
-LIBICU = $(ICUPREFIX)
-DEFAULT_LIBS =
+LIBPREFIX=
+DEFAULT_LIBS = advapi32.lib
-## Link commands to link to ICU libs
-LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)data$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBICUUC= $(top_builddir)/common/$(LIBICU)uc$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBICUI18N= $(top_builddir)/i18n/$(LIBICU)i18n$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBICULE= $(top_builddir)/layout/$(LIBICU)le$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBICULX= $(top_builddir)/layoutex/$(LIBICU)lx$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBCTESTFW= $(top_builddir)/tools/ctestfw/$(LIBICU)ctestfw$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBICUTOOLUTIL= $(top_builddir)/tools/toolutil/$(LIBICU)toolutil$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
-LIBUSTDIO= $(top_builddir)/extra/ustdio/$(LIBICU)io$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR).lib
+# Change the stubnames so that poorly working FAT disks and installation programs can work.
+# This is also for backwards compatibility.
+DATA_STUBNAME = dt
+I18N_STUBNAME = in
+LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
+## Link commands to link to ICU libs
+LIBICUDT= $(top_builddir)/stubdata/$(LIBICU)$(DATA_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICUUC= $(LIBDIR)/$(LIBICU)$(COMMON_STUBNAME)$(ICULIBSUFFIX).lib $(LIBICUDT)
+LIBICUI18N= $(LIBDIR)/$(LIBICU)$(I18N_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICULE= $(LIBDIR)/$(LIBICU)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICULX= $(LIBDIR)/$(LIBICU)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICUIO= $(LIBDIR)/$(LIBICU)$(IO_STUBNAME)$(ICULIBSUFFIX).lib
+LIBCTESTFW= $(top_builddir)/tools/ctestfw/$(LIBICU)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX).lib
+LIBICUTOOLUTIL= $(LIBDIR)/$(LIBICU)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX).lib
+
+## These are the library specific LDFLAGS
+LDFLAGSICUDT=# Unused for now.
+LDFLAGSICUUC= /base:"0x4a800000"# in-uc = 1MB
+LDFLAGSICUI18N= /base:"0x4a900000"# io-in = 2MB
+LDFLAGSICUIO= /base:"0x4ab00000"# le-io = 1MB
+LDFLAGSICULE= /base:"0x4ac00000"# lx-le = 512KB
+LDFLAGSICULX= /base:"0x4ac80000"
+LDFLAGSCTESTFW=# Unused for now.
+LDFLAGSICUTOOLUTIL= /base:"0x4ac00000"# Same as layout. Layout and tools probably won't mix.
+
+# The #M# is used to delete lines for icu-config
+# Current full path directory.
+CURR_FULL_DIR=$(shell cygpath -dma .)#M#
+# Current full path directory for use in source code in a -D compiler option.
+CURR_SRCCODE_FULL_DIR=$(subst \,\\\\,$(shell cygpath -da .))#M#
+
+ifeq ($(srcdir),.)
+SOURCE_FILE=$<
+else
+SOURCE_FILE=$(shell cygpath -dma $<)#M#
+endif
## Compilation rules
%.$(STATIC_O): $(srcdir)/%.c
- $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) /Fo$@ $<
+ $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) /Fo$@ $(SOURCE_FILE)
%.o: $(srcdir)/%.c
- $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) /Fo$@ $<
+ $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) /Fo$@ $(SOURCE_FILE)
%.$(STATIC_O): $(srcdir)/%.cpp
- $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) /Fo$@ $<
+ $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) /Fo$@ $(SOURCE_FILE)
%.o: $(srcdir)/%.cpp
- $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) /Fo$@ $<
-
-../data/%.o: ../data/%.c
- $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) /Fo$@ $<
+ $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) /Fo$@ $(SOURCE_FILE)
-## Dependency rules
-#%.d: $(srcdir)/%.c
-# @echo "generating dependency information for $<"
-# $(SHELL) -ec '$(GEN_DEPS.c) $< \
-# | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
-# [ -s $@ ] || rm -f $@'
-#
-#%.d: $(srcdir)/%.cpp
-# @echo "generating dependency information for $<"
-# $(SHELL) -ec '$(GEN_DEPS.cc) $< \
-# | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
-# [ -s $@ ] || rm -f $@'
## Dependency rules
+## This is a start to how depdendencies could work
+# The commented out rules may not properly delete the file when ^C is pressed
+# or the compiler fails.
+# make currently doesn't like rules with C:\\PROGRA~1\\.. in the depedency.
+# So system headers are ignored by ignoring \\
%.d : $(srcdir)/%.c
@echo "generating dependency information for $<"
@$(GEN_DEPS.c) $< > $@
+# @echo -n "generating dependency information for "
+# @echo -n "$@ $(basename $<).o : " > $@
+# @$(SHELL) -ec '$(GEN_DEPS.c) $< \
+# | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
+# | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
+# || (rm -f $@ && echo $@ && false)'
%.d : $(srcdir)/%.cpp
@echo "generating dependency information for $<"
@$(GEN_DEPS.cc) $< > $@
+# @echo -n "generating dependency information for "
+# @echo -n "$@ $(basename $<).o : " > $@
+# @$(SHELL) -ec '$(GEN_DEPS.cc) $< \
+# | grep "#line 1 " | grep -v \\\\ | cut -d " " -f 3 \
+# | /usr/bin/sort -u | sed s/\"$$/\\\\/ | sed s/^\"/\ / >> $@ \
+# || (rm -f $@ && echo $@ && false)'
## Compile a Windows resource file
%.res : $(srcdir)/%.rc
- @rc.exe /fo$@ $<
+ rc.exe /fo$@ $(SOURCE_FILE)
## Versioned target for a shared library.
-FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
-MIDDLE_SO_TARGET=$(SO_TARGET)
+FINAL_SO_TARGET= $(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
+MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
-## Versioned import library names.
-IMPORT_LIB = $(LIBICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX)$(IMPORT_LIB_EXT)
-MIDDLE_IMPORT_LIB = $(LIBICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX)$(SO_TARGET_VERSION_MAJOR)$(IMPORT_LIB_EXT)
-FINAL_IMPORT_LIB := $(MIDDLE_IMPORT_LIB)
+## Special pkgdata information that is needed
+PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
+ICUPKGDATA_INSTALL_DIR = $(shell cygpath -dma $(DESTDIR)$(ICUPKGDATA_DIR))#M#
+ICUPKGDATA_INSTALL_LIBDIR = $(shell cygpath -dma $(DESTDIR)$(libdir))#M#
+
+## Versioned import library names. The library names are versioned,
+## but the import libraries do not need versioning.
+IMPORT_LIB = $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)
+MIDDLE_IMPORT_LIB = $(IMPORT_LIB)
+FINAL_IMPORT_LIB = $(MIDDLE_IMPORT_LIB)
## Versioned libraries rules
#%$(SO_TARGET_VERSION_MAJOR).$(SO): %$(SO_TARGET_VERSION).$(SO)
-# $(RM) $@ && cp $< $@
+# $(RM) $@ && cp ${<F} $@
+# The following rule is a no op. We don't want symbolic links
%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
- $(RM) $@ && ln -s $< $@
-
-## Bind internal references
-
-# LDflags that pkgdata will use
-BIR_LDFLAGS= -Wl,-Bsymbolic
+ @echo -n
+# $(RM) $@ && ln -s ${<F} $@
-# CPPflags for genccode/gencmn
-BIR_CPPFLAGS= -DU_HAVE_BIND_INTERNAL_REFERENCES
-
-# Dependencies [i.e. map files] for the final library
-BIR_DEPS=
+## Install libraries as executable
+INSTALL-L=$(INSTALL_PROGRAM)
# Environment variable to set a runtime search path
LDLIBRARYPATH_ENVVAR = PATH
+# These are needed to allow the pkgdata nmake files to work
+PKGDATA_OPTS = -v
+PKGDATA_INVOKE_OPTS = MAKEFLAGS=
+
+# Include the version information in the shared library
+ENABLE_SO_VERSION_DATA=1
+
## End Cygwin-specific setup