aboutsummaryrefslogtreecommitdiff
path: root/make/Makefile
blob: 55076a028afd551c4fb0299dac6f18c326407d9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# Makefile wrapper around Ant build.xml file

#
# On Solaris, the 'make' utility from Sun will not work with these makefiles.
#    This little rule is only understood by Sun's make, and is harmless
#    when seen by the GNU make tool. If using Sun's make, this causes the
#    make command to fail.
#
SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33

ifdef QUIET
  ANT_OPTIONS += -quiet
endif

ifdef VERBOSE
  ANT_OPTIONS += -verbose
endif

ifeq ($(VARIANT), OPT)
  ifneq ($(DEBUG_CLASSFILES), true)
    ANT_OPTIONS += -Djavac.debug=false
  endif
endif

# Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN)
# and the somewhat misnamed CLASS_VERSION (-target NN)
ifdef TARGET_CLASS_VERSION
  ANT_OPTIONS += -Djavac.target=$(TARGET_CLASS_VERSION)
else
  ifdef JAVAC_TARGET_ARG
    ANT_OPTIONS += -Djavac.target=$(JAVAC_TARGET_ARG)
  endif
endif

ifdef SOURCE_LANGUAGE_VERSION
  ANT_OPTIONS += -Djavac.source=$(SOURCE_LANGUAGE_VERSION)
else
  ifdef JAVAC_SOURCE_ARG 
    ANT_OPTIONS += -Djavac.source=$(JAVAC_SOURCE_ARG)
  endif
endif 

# If downloads are allowed
ifeq ($(ALLOW_DOWNLOADS),true)
  ANT_OPTIONS += -Dallow.downloads=true
endif

# Figure out the platform we are using
_SYSTEM_UNAME := $(shell uname)
_PLATFORM_KIND = unix
ifeq ($(_SYSTEM_UNAME), Windows_NT)
  _PLATFORM_KIND = windows
endif
ifneq (,$(findstring CYGWIN,$(_SYSTEM_UNAME)))
  _PLATFORM_KIND = windows
endif

# Where is /java in case we need it
ifdef ALT_SLASH_JAVA
  _SLASHJAVA = $(ALT_SLASH_JAVA)
else
  ifeq ($(_PLATFORM_KIND), windows)
    _SLASHJAVA=J:/
  else
    _SLASHJAVA=/java
  endif
endif

# Do we have the drops already downloaded?
# Check ALT_DROPS_DIR for a full path first,
# before trying to use the devtools path,
# either via ALT_JDK_DEVTOOLS_DIR or /java/devtools.
ifdef ALT_DROPS_DIR
  DROPS_DIR = $(ALT_DROPS_DIR)
else
  ifdef ALT_JDK_DEVTOOLS_DIR
    DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk7-drops
  else
    DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk7-drops
  endif
endif

# Add in path to drops already downloaded
ANT_OPTIONS += -Ddrops.dir=$(DROPS_DIR)

ifdef ALT_OUTPUTDIR
  OUTPUTDIR = $(ALT_OUTPUTDIR)
  ANT_OPTIONS += -Doutput.dir=$(ALT_OUTPUTDIR)
else
  OUTPUTDIR = ..
endif

ifdef ALT_LANGTOOLS_DIST
  ifdef ALT_BOOTDIR
    ANT_JAVA_HOME = JAVA_HOME=$(ALT_BOOTDIR)
    ANT_OPTIONS += -Djdk.home=$(ALT_BOOTDIR)
  endif
  ANT_OPTIONS += -Dbootstrap.dir=$(ALT_LANGTOOLS_DIST)/bootstrap
else
  ifdef ALT_JDK_IMPORT_PATH
    ANT_JAVA_HOME = JAVA_HOME=$(ALT_JDK_IMPORT_PATH)
    ANT_OPTIONS += -Djdk.home=$(ALT_JDK_IMPORT_PATH)
  endif
endif

ifdef ANT_HOME
  ANT = $(ANT_HOME)/bin/ant
  ifneq ($(shell test -x $(ANT); echo $$?), 0)
    $(error "$(ANT) not found; please update ANT_HOME")
  endif
else
  ANT = ant
  ifneq ($(shell which $(ANT) > /dev/null; echo $$?), 0)
    $(error "'ant' not found; please set ANT_HOME or put 'ant' on your PATH")
  endif
endif

# Default target and expected 'do everything' target
default: all

# All ant targets of interest
ANT_TARGETS = all source drop_included build dist clobber clean sanity

# Create a make target for each
$(ANT_TARGETS):
	cd .. && $(ANT_JAVA_HOME) $(ANT) $(ANT_OPTIONS) -version
	cd .. && $(ANT_JAVA_HOME) $(ANT) $(ANT_OPTIONS) $@

# Help target
define helpenvline
@echo "    $1";echo "        $2"
endef
help:
	@echo "----------------------------------------------------------"
	@echo " "
	@echo "Help information for this Makefile:"
	@echo " "
	@echo "  Targets (see ant project information for descriptions):"
	@echo "    $(ANT_TARGETS)"
	@echo " "
	@echo "  Environment or command line variables (all optional):"
	$(call helpenvline, ALT_DROPS_DIR,\
	       "Directory that contains the drop source bundles i.e. drops.dir")
	$(call helpenvline, ALT_BOOTDIR,\
	       "JAVA_HOME to use when running ant")
	$(call helpenvline, ALT_LANGTOOLS_DIST,\
	       "path to langtools repository dist directory")
	$(call helpenvline, ALT_OUTPUTDIR,\
	       "path to root of output")
	$(call helpenvline, DEBUG_CLASSFILES,\
	       "if set makes sure ant property javac.debug is true")
	$(call helpenvline, JAVAC_SOURCE_ARG,\
	       "if SOURCE_LANGUAGE_VERSION not set uses this to set ant property javac.source")
	$(call helpenvline, JAVAC_TARGET_ARG,\
	       "if TARGET_CLASS_VERSION not set uses this to set ant property javac.target")
	$(call helpenvline, SOURCE_LANGUAGE_VERSION,\
	       "if set uses this to set ant property javac.source")
	$(call helpenvline, QUIET,\
	       "if set will pass -quiet to ant")
	$(call helpenvline, TARGET_CLASS_VERSION,\
	       "JAVA_HOME to use when running ant")
	$(call helpenvline, VARIANT,\
	       "if set to OPT means optimized build will set javac.debug to false")
	$(call helpenvline, VERBOSE,\
	       "if set will pass -verbose to ant")
	@echo " "
	@echo "----------------------------------------------------------"
	@echo " "
	@echo "Ant project file help information:"
	@echo " "
	@$(ANT_JAVA_HOME) cd .. && $(ANT) $(ANT_OPTIONS) -p
	@echo " "
	@echo "----------------------------------------------------------"

# Targets for Sun's internal JPRT build system
JPRT_ARCHIVE_BUNDLE=$(OUTPUTDIR)/jprt.zip
jprt_build_product jprt_build_debug jprt_build_fastdebug: all
	$(RM) $(JPRT_ARCHIVE_BUNDLE)
	( cd $(OUTPUTDIR)/dist && \
	   zip -q -r $(JPRT_ARCHIVE_BUNDLE) . )

# Declare these phony (not filenames)
.PHONY: $(ANT_TARGETS) \
	jprt_build_product jprt_build_debug jprt_build_fastdebug