Makefile revision 1870:4aa2e64eff30
1#
2# Copyright (c) 2015, 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.
8#
9# This code is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12# version 2 for more details (a copy is included in the LICENSE file that
13# accompanied this code).
14#
15# You should have received a copy of the GNU General Public License version
16# 2 along with this work; if not, write to the Free Software Foundation,
17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18#
19# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20# or visit www.oracle.com if you need additional information or have any
21# questions.
22#
23
24#
25# This is a temporary standalone makefile
26#
27
28BUILD_DIR := $(shell pwd)/build
29CLASSES_DIR := ${BUILD_DIR}/classes
30IMAGE_DIR := ${BUILD_DIR}/image
31RUN_DIR := $(shell pwd)/run
32
33SRC_DIR := src/share/classes/
34SOURCES := ${SRC_DIR}/jdk/test/failurehandler/*.java                   \
35           ${SRC_DIR}/jdk/test/failurehandler/action/*.java            \
36           ${SRC_DIR}/jdk/test/failurehandler/jtreg/*.java             \
37           ${SRC_DIR}/jdk/test/failurehandler/value/*.java
38
39CONF_DIR = src/share/conf
40
41JAVA_RELEASE = 7
42
43TARGET_JAR = ${IMAGE_DIR}/lib/jtregFailureHandler.jar
44
45OS_NAME := $(shell uname -o 2>&1)
46
47ifeq ("${OS_NAME}", "Cygwin")
48BUILD_DIR := $(shell cygpath -m "${BUILD_DIR}")
49CLASSES_DIR := $(shell cygpath -m "${CLASSES_DIR}")
50IMAGE_DIR := $(shell cygpath -m "${IMAGE_DIR}") RUN_DIR := $(shell cygpath -m "${RUN_DIR}")
51SRC_DIR := $(shell cygpath -m "${SRC_DIR}")
52JTREG_HOME := $(shell cygpath -m "${JTREG_HOME}")
53CC := "cl.exe"
54endif
55
56all: clean test
57
58native: require_env
59ifeq ("${OS_NAME}", "Cygwin")
60    "${CC}" src/windows/native/jdk/test/failurehandler/jtreg/*.c            \
61        -I"$(shell cygpath -w ${JAVA_HOME}/include)"                        \
62        -I"$(shell cygpath -w ${JAVA_HOME}/include/win32)"                  \
63        /link /MACHINE:X64 /DLL /OUT:timeoutHandler.dll
64endif
65
66check_defined = $(foreach 1,$1,$(__check_defined))
67__check_defined = $(if $(value $1),, $(error $1 is not set))
68
69classes: require_env
70    mkdir -p ${IMAGE_DIR}/bin ${IMAGE_DIR}/lib ${CLASSES_DIR}
71    "${JAVA_HOME}"/bin/javac -target ${JAVA_RELEASE} -source ${JAVA_RELEASE}  \
72        -sourcepath $(shell pwd)                                              \
73        -classpath ${JTREG_HOME}/lib/jtreg.jar:${JAVA_HOME}/lib/tools.jar     \
74        -d ${CLASSES_DIR}                                                     \
75        ${SOURCES}
76    "${JAVA_HOME}"/bin/jar cf ${TARGET_JAR} -C ${CLASSES_DIR} .
77    "${JAVA_HOME}"/bin/jar uf ${TARGET_JAR} -C ${CONF_DIR} .
78
79#
80# Use JTREG_TEST_OPTS for test VM options
81# Use JTREG_TESTS for jtreg tests parameter
82#
83test: require_env build
84    rm -rf ${RUN_DIR}
85    mkdir -p ${RUN_DIR}
86    "${JTREG_HOME}"/bin/jtreg                                               \
87        -jdk:"${JAVA_HOME}"                                                 \
88        ${JTREG_TEST_OPTS}                                                  \
89        -timeout:0.1 -va -retain:all                                        \
90        -noreport                                                           \
91        -agentvm                                                            \
92        -thd:"${TARGET_JAR}"                                                \
93        -th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler   \
94        -od:"${TARGET_JAR}"                                                 \
95        -o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver       \
96        -w:${RUN_DIR}/JTwork -r:${RUN_DIR}/JTreport                         \
97        $(if ${JTREG_TESTS}, ${JTREG_TESTS}, test)                          \
98        && false || true
99
100debug: JTREG_TEST_OPTS += "-J-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005'"
101debug: test
102
103require_env:
104    $(call check_defined, JAVA_HOME)
105    $(call check_defined, JTREG_HOME)
106
107clean:
108    rm -rf "${BUILD_DIR}" "${RUN_DIR}"
109
110build: classes native
111
112.PHONY: all build classes native test require_env clean
113.DEFAULT: all
114
115