1 #
   2 # Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Makefile for building  Pack200
  28 #
  29 
  30 BUILDDIR = ../../../..
  31 PACKAGE = com.sun.java.util.jar.pack
  32 LIBRARY = unpack
  33 PRODUCT = sun
  34 PGRM = unpack200
  35 JAVAC_MAX_WARNINGS=true
  36 JAVAC_WARNINGS_FATAL=true
  37 include $(BUILDDIR)/common/Defs.gmk
  38 
  39 CPLUSPLUSLIBRARY=true
  40 
  41 FILES_m = mapfile-vers
  42 include $(BUILDDIR)/common/Mapfile-vers.gmk
  43 
  44 #
  45 # Files to compile
  46 #
  47 AUTO_FILES_JAVA_DIRS = com/sun/java/util/jar/pack
  48 
  49 include FILES_cpp.gmk
  50 
  51 FILES_export = $(PKGDIR)/NativeUnpack.java
  52 
  53 #
  54 # Rules
  55 include $(BUILDDIR)/common/Library.gmk
  56 
  57 build: unpacker
  58 
  59 vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
  60 
  61 ifeq ($(STANDALONE),true)
  62  ifneq ($(SYSTEM_ZLIB),true)
  63   ZIPOBJDIR = $(OUTPUTDIR)/tmp/sun/java.util.zip/zip/$(OBJDIRNAME)
  64 
  65   ZIPOBJS =  $(ZIPOBJDIR)/zcrc32.$(OBJECT_SUFFIX) \
  66              $(ZIPOBJDIR)/deflate.$(OBJECT_SUFFIX) \
  67              $(ZIPOBJDIR)/trees.$(OBJECT_SUFFIX) \
  68              $(ZIPOBJDIR)/zadler32.$(OBJECT_SUFFIX) \
  69              $(ZIPOBJDIR)/compress.$(OBJECT_SUFFIX) \
  70              $(ZIPOBJDIR)/zutil.$(OBJECT_SUFFIX) \
  71              $(ZIPOBJDIR)/inflate.$(OBJECT_SUFFIX) \
  72              $(ZIPOBJDIR)/infback.$(OBJECT_SUFFIX) \
  73              $(ZIPOBJDIR)/inftrees.$(OBJECT_SUFFIX) \
  74              $(ZIPOBJDIR)/inffast.$(OBJECT_SUFFIX)
  75 
  76   ZINCLUDE=-I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
  77   OTHER_CXXFLAGS += $(ZINCLUDE)
  78   LDDFLAGS += $(ZIPOBJS)
  79  else
  80   LDDFLAGS += -lz
  81   OTHER_CXXFLAGS += -DSYSTEM_ZLIB
  82  endif
  83 else
  84   OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
  85   OTHER_LDLIBS += $(JVMLIB)
  86 endif
  87 
  88 CXXFLAGS_DBG += -DFULL
  89 CXXFLAGS_OPT += -DPRODUCT
  90 CXXFLAGS_COMMON += -DFULL
  91 
  92 ifeq ($(PLATFORM), windows) 
  93   CXXFLAGS_COMMON += $(MS_RUNTIME_OPTION)
  94   LDOUTPUT = -Fe
  95 
  96   # JDK name required here
  97   RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
  98         /D "JDK_INTERNAL_NAME=$(PGRM)" \
  99         /D "JDK_FTYPE=0x1L"
 100 
 101   RES = $(OBJDIR)/$(PGRM).res
 102 else
 103   LDOUTPUT = -o #Have a space 
 104   LDDFLAGS += -lc
 105   OTHER_LDLIBS  += $(LIBCXX)
 106 # setup the list of libraries to link in...
 107 ifeq ($(PLATFORM), linux)
 108 ifeq ("$(CC_VER_MAJOR)", "3")
 109   OTHER_LDLIBS  += -Wl,-Bstatic -lgcc_eh -Wl,-Bdynamic
 110 endif
 111 endif #LINUX
 112 endif #PLATFORM
 113 
 114 UNPACK_EXE = $(BINDIR)/unpack200$(EXE_SUFFIX)
 115 
 116 UNPACK_EXE_FILES_cpp =  $(filter-out jni.cpp,$(FILES_cpp))
 117 
 118 UNPACK_EXE_FILES_cpp += main.cpp
 119 
 120 UNPACK_EXE_FILES_o = $(addprefix $(COBJDIR)/, \
 121                         $(notdir  \
 122                         $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(UNPACK_EXE_FILES_cpp)) \
 123                      ))
 124 
 125 COBJDIR = $(strip $(subst unpack,unpack-cmd,$(OBJDIR)))
 126 
 127 all: build
 128 
 129 build: prop pack200-tool
 130 
 131 prop:
 132         $(MAKE) -C prop
 133 
 134 pack200-tool:
 135         $(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack)
 136 
 137 # ignore mapfile for non-product binary 
 138 unpacker:
 139         $(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_DBG=
 140 
 141 ifeq ($(PLATFORM), windows)
 142 IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
 143 SED_ALL_MANIFEST=$(SED) -e 's%IMVERSION%$(IMVERSIONVALUE)%g'
 144 updatefiles:: 
 145         $(CAT) $(TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest | $(SED_ALL_MANIFEST) > $(OBJDIR)/unpack200.exe.manifest
 146 winres::  $(RES)
 147 else
 148 updatefiles::
 149         $(ECHO) "Manifest not required for Unix"
 150 winres::
 151         $(ECHO) "Resource files not required for Unix"
 152 endif
 153 
 154 # Mapfile-vers.gmk, does not copy over the mapfile-vers-unpack200, when
 155 # the make utiliy is re-invoked, as in this case. In order to workaround
 156 # this special case, the mapfile required for the unpack200 command, is
 157 # explicitly copied over to the expected location.
 158 $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
 159         $(prep-target)
 160         $(RM) $(TEMPDIR)/mapfile-vers
 161         $(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
 162         $(LINKER)  $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
 163 ifdef MT
 164         $(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
 165 endif
 166         $(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
 167         @$(call binary_file_verification,$@)
 168 
 169 ifeq ($(PLATFORM), windows) 
 170 $(RES):: $(VERSIONINFO_RESOURCE)
 171         $(prep-target)
 172         $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
 173 endif
 174 
 175 $(COBJDIR)/%.$(OBJECT_SUFFIX): %.cpp
 176         $(prep-target)
 177         $(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$(COBJDIR)/$*.$(OBJECT_SUFFIX) $<
 178 
 179 #
 180 # Clean up.
 181 #
 182 clean::
 183         $(RM) -r $(CLASSDESTDIR)/com/sun/java/util/jar/pack $(TEMPDIR)
 184         $(RM) -r $(OUTPUTDIR)/tmp/$(PRODUCT)/$(PACKAGE)
 185         $(MAKE) -C prop clean
 186 
 187 .PHONY: unpacker clean winres prop