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 MODULE = unpack200-tool
32 PACKAGE = com.sun.java.util.jar.pack
33 LIBRARY = unpack
34 PRODUCT = sun
35 PGRM = unpack200
36 JAVAC_MAX_WARNINGS=true
37 JAVAC_WARNINGS_FATAL=true
38 include $(BUILDDIR)/common/Defs.gmk
39
40 CPLUSPLUSLIBRARY=true
41
42 FILES_m = mapfile-vers
43 include $(BUILDDIR)/common/Mapfile-vers.gmk
44
45 #
46 # Files to compile
47 #
48 AUTO_FILES_JAVA_DIRS = com/sun/java/util/jar/pack
49
50 include FILES_cpp.gmk
51
52 FILES_export = $(PKGDIR)/NativeUnpack.java
53
54 #
55 # Rules
56 include $(BUILDDIR)/common/Library.gmk
57
58 build: unpacker
59
60 vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
61
62 ifeq ($(STANDALONE),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 OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
81 OTHER_LDLIBS += $(JVMLIB)
82 endif
83
84 CXXFLAGS_DBG += -DFULL
85 CXXFLAGS_OPT += -DPRODUCT
86 CXXFLAGS_COMMON += -DFULL
87
88 ifeq ($(PLATFORM), windows)
89 CXXFLAGS_COMMON += $(MS_RUNTIME_OPTION)
90 LDOUTPUT = -Fe
91
92 # JDK name required here
93 RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
94 /D "JDK_INTERNAL_NAME=$(PGRM)" \
95 /D "JDK_FTYPE=0x1L"
96
97 RES = $(OBJDIR)/$(PGRM).res
98 else
99 LDOUTPUT = -o #Have a space
100 LDDFLAGS += -lc
101 OTHER_LDLIBS += $(LIBCXX)
102 # setup the list of libraries to link in...
103 ifeq ($(PLATFORM), linux)
104 ifeq ("$(CC_VER_MAJOR)", "3")
105 OTHER_LDLIBS += -Wl,-Bstatic -lgcc_eh -Wl,-Bdynamic
106 endif
107 endif #LINUX
108 endif #PLATFORM
109
110 UNPACK_EXE = $(BINDIR)/unpack200$(EXE_SUFFIX)
111
112 UNPACK_EXE_FILES_cpp = $(filter-out jni.cpp,$(FILES_cpp))
113
114 UNPACK_EXE_FILES_cpp += main.cpp
115
116 UNPACK_EXE_FILES_o = $(addprefix $(COBJDIR)/, \
117 $(notdir \
118 $(patsubst %.cpp,%.$(OBJECT_SUFFIX),$(UNPACK_EXE_FILES_cpp)) \
119 ))
120
121 COBJDIR = $(strip $(subst unpack,unpack-cmd,$(OBJDIR)))
122
123 all: build
124
125 build: prop
126
127 prop:
128 $(MAKE) -C prop
129
130 # ignore mapfile for non-product binary
131 unpacker:
132 $(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_DBG=
133
134 ifeq ($(PLATFORM), windows)
135 IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
136 SED_ALL_MANIFEST=$(SED) -e 's%IMVERSION%$(IMVERSIONVALUE)%g'
137 updatefiles::
138 $(CAT) $(TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest | $(SED_ALL_MANIFEST) > $(OBJDIR)/unpack200.exe.manifest
139 winres:: $(RES)
140 else
141 updatefiles::
142 $(ECHO) "Manifest not required for Unix"
143 winres::
144 $(ECHO) "Resource files not required for Unix"
145 endif
146
147 # Mapfile-vers.gmk, does not copy over the mapfile-vers-unpack200, when
148 # the make utiliy is re-invoked, as in this case. In order to workaround
149 # this special case, the mapfile required for the unpack200 command, is
150 # explicitly copied over to the expected location.
151 $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
152 $(prep-target)
153 $(RM) $(TEMPDIR)/mapfile-vers
154 $(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
155 $(LINKER) $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
156 ifdef MT
157 $(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
158 endif
159 $(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
160 @$(call binary_file_verification,$@)
161 $(install-module-file)
162
163 ifeq ($(PLATFORM), windows)
164 $(RES):: $(VERSIONINFO_RESOURCE)
165 $(prep-target)
166 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
167 endif
168
169 $(COBJDIR)/%.$(OBJECT_SUFFIX): %.cpp
170 $(prep-target)
171 $(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$(COBJDIR)/$*.$(OBJECT_SUFFIX) $<
172
173 #
174 # Clean up.
175 #
176 clean::
177 $(RM) -r $(CLASSDESTDIR)/com/sun/java/util/jar/pack $(TEMPDIR)
178 $(RM) -r $(OUTPUTDIR)/tmp/$(PRODUCT)/$(PACKAGE)
179 $(MAKE) -C prop clean
180
181 .PHONY: unpacker clean winres prop
--- EOF ---