61 #
62 # Parameter 1 is the name of the rule. This name is used as variable prefix,
63 # and the targets generated are listed in a variable by that name. It is also
64 # used as the name of the executable.
65 #
66 # Remaining parameters are named arguments. These include:
67 # MAIN_MODULE The module of the main class to launch if different from the
68 # current module
69 # MAIN_CLASS The Java main class to launch
70 # JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS
71 # EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended
72 # before JAVA_ARGS to CFLAGS, primarily to allow long string literal
73 # compile time defines exceeding Visual Studio 2013 limitations.
74 # CFLAGS Additional CFLAGS
75 # CFLAGS_windows Additional CFLAGS_windows
76 # EXTRA_RC_FLAGS Additional EXTRA_RC_FLAGS
77 # MACOSX_PRIVILEGED On macosx, allow to access other processes
78 # OPTIMIZATION Override default optimization level (LOW)
79 # OUTPUT_DIR Override default output directory
80 # VERSION_INFO_RESOURCE Override default Windows resource file
81 SetupBuildLauncher = $(NamedParamsMacroTemplate)
82 define SetupBuildLauncherBody
83 # Setup default values (unless overridden)
84 ifeq ($$($1_OPTIMIZATION), )
85 $1_OPTIMIZATION := LOW
86 endif
87
88 ifeq ($$($1_MAIN_MODULE), )
89 $1_MAIN_MODULE := $(MODULE)
90 endif
91
92 $1_JAVA_ARGS += -ms8m
93 ifneq ($$($1_MAIN_CLASS), )
94 $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
95 endif
96
97 ifneq ($$($1_EXTRA_JAVA_ARGS), )
98 $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
99 $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
100 $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
114
115 ifeq ($(STATIC_BUILD), true)
116 $1_LDFLAGS += -exported_symbols_list \
117 $(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
118 $1_LIBS += \
119 $$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
120 $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \
121 $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \
122 $(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \
123 -framework CoreFoundation \
124 -framework Foundation \
125 -framework SystemConfiguration \
126 -lstdc++ -liconv
127 endif
128 endif
129
130 ifeq ($(USE_EXTERNAL_LIBZ), true)
131 $1_LIBS += -lz
132 endif
133
134 $1_WINDOWS_JLI_LIB := $(call FindStaticLib, java.base, jli, /libjli)
135
136 $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
137 NAME := $1, \
138 EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
139 OPTIMIZATION := $$($1_OPTIMIZATION), \
140 CFLAGS := $$(CFLAGS_JDKEXE) \
141 $(LAUNCHER_CFLAGS) \
142 $(VERSION_CFLAGS) \
143 -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
144 -DPROGNAME='"$1"' \
145 $$($1_CFLAGS), \
146 CFLAGS_linux := -fPIC, \
147 CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \
148 CFLAGS_windows := $$($1_CFLAGS_windows), \
149 DISABLED_WARNINGS_gcc := unused-function, \
150 LDFLAGS := $$(LDFLAGS_JDKEXE) \
151 $$(call SET_EXECUTABLE_ORIGIN) \
152 $$($1_LDFLAGS), \
153 LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib) \
|
61 #
62 # Parameter 1 is the name of the rule. This name is used as variable prefix,
63 # and the targets generated are listed in a variable by that name. It is also
64 # used as the name of the executable.
65 #
66 # Remaining parameters are named arguments. These include:
67 # MAIN_MODULE The module of the main class to launch if different from the
68 # current module
69 # MAIN_CLASS The Java main class to launch
70 # JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS
71 # EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended
72 # before JAVA_ARGS to CFLAGS, primarily to allow long string literal
73 # compile time defines exceeding Visual Studio 2013 limitations.
74 # CFLAGS Additional CFLAGS
75 # CFLAGS_windows Additional CFLAGS_windows
76 # EXTRA_RC_FLAGS Additional EXTRA_RC_FLAGS
77 # MACOSX_PRIVILEGED On macosx, allow to access other processes
78 # OPTIMIZATION Override default optimization level (LOW)
79 # OUTPUT_DIR Override default output directory
80 # VERSION_INFO_RESOURCE Override default Windows resource file
81 # INCLUDE_TSAN If true, pass compiler and linker flags for TSAN.
82 SetupBuildLauncher = $(NamedParamsMacroTemplate)
83 define SetupBuildLauncherBody
84 # Setup default values (unless overridden)
85 ifeq ($$($1_OPTIMIZATION), )
86 $1_OPTIMIZATION := LOW
87 endif
88
89 ifeq ($$($1_MAIN_MODULE), )
90 $1_MAIN_MODULE := $(MODULE)
91 endif
92
93 $1_JAVA_ARGS += -ms8m
94 ifneq ($$($1_MAIN_CLASS), )
95 $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
96 endif
97
98 ifneq ($$($1_EXTRA_JAVA_ARGS), )
99 $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
100 $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
101 $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
115
116 ifeq ($(STATIC_BUILD), true)
117 $1_LDFLAGS += -exported_symbols_list \
118 $(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
119 $1_LIBS += \
120 $$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
121 $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \
122 $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \
123 $(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \
124 -framework CoreFoundation \
125 -framework Foundation \
126 -framework SystemConfiguration \
127 -lstdc++ -liconv
128 endif
129 endif
130
131 ifeq ($(USE_EXTERNAL_LIBZ), true)
132 $1_LIBS += -lz
133 endif
134
135 ifeq ($$($1_INCLUDE_TSAN), true)
136 $1_CFLAGS += -DINCLUDE_TSAN
137 # TSAN runtime needs to be statically or dynamically linked with the launcher
138 # instead of libjvm.so, because initialization of TSAN runtime has to happen
139 # early at program start.
140 # '-fsanitize=thread' works as a link-only flag for either GCC or Clang.
141 # With GCC, it dynamically links with libtsan.so; with Clang, it statically
142 # links the runtime into the launcher's executable.
143 $1_LDFLAGS += -fsanitize=thread
144 endif
145
146 $1_WINDOWS_JLI_LIB := $(call FindStaticLib, java.base, jli, /libjli)
147
148 $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
149 NAME := $1, \
150 EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
151 OPTIMIZATION := $$($1_OPTIMIZATION), \
152 CFLAGS := $$(CFLAGS_JDKEXE) \
153 $(LAUNCHER_CFLAGS) \
154 $(VERSION_CFLAGS) \
155 -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \
156 -DPROGNAME='"$1"' \
157 $$($1_CFLAGS), \
158 CFLAGS_linux := -fPIC, \
159 CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \
160 CFLAGS_windows := $$($1_CFLAGS_windows), \
161 DISABLED_WARNINGS_gcc := unused-function, \
162 LDFLAGS := $$(LDFLAGS_JDKEXE) \
163 $$(call SET_EXECUTABLE_ORIGIN) \
164 $$($1_LDFLAGS), \
165 LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib) \
|