make/common/Demo.gmk

Print this page
rev 4528 : 6988099: jvmti demos missing Publisher (COMPANY resource) in dlls/exes on windows
Summary: Add creation/linking of resource data to link step for demos on Windows
Reviewed-by: dcubed, zgu, ngmr
Contributed-by: Sean Chou <zhouyx@linux.vnet.ibm.com>

@@ -156,10 +156,12 @@
   ifeq ($(PLATFORM),windows)
     # Note: This is a link with cl.exe, not link.exe, options differ quite
     #       bit between them.
     LINK.demo   = $(LINK.c)
     LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION))
+    DEMO_VERSION_INFO = $(OBJDIR)/$(LIBRARY).res
+    LDLIBS.demo += $(DEMO_VERSION_INFO)
   else
     ifneq ($(DEMO_NEEDS_CPP),)
       LINK.demo   = $(LINK.cpp)
       LDLIBS.demo = $(LIBCXX)
       ifeq ($(PLATFORM),solaris)

@@ -286,10 +288,17 @@
   # Install the destination src.zip file and create the src tree
   $(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP)
         $(install-file)
 endif
 
+ifeq ($(PLATFORM),windows)
+# JDK name required here
+RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
+            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
+            /D "JDK_FTYPE=0x2L"
+endif
+
 # Native library building
 ifdef DEMO_LIBRARY
 
   # Full paths to object files
   DEMO_FULL_OBJECTS = $(DEMO_OBJECTS:%=$(OBJDIR)/%)

@@ -306,10 +315,13 @@
   endif
 
   # Actual creation of the native shared library (C++ and C are different)
 $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
         @$(prep-target)
+  ifeq ($(PLATFORM),windows)
+        $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
+  endif
         $(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
             $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
         @$(call binary_file_verification,$@)
 
   # Generation of any javah include file, make sure objects are dependent on it