NewMakefile.gmk

changeset 559
ef6adbf511cc
parent 494
e64f2cb57d05
child 578
6e822b534678
equal deleted inserted replaced
558:d5f3a6f60d51 559:ef6adbf511cc
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 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 22 # or visit www.oracle.com if you need additional information or have any
23 # questions. 23 # questions.
24 # 24 #
25 25
26 # Utilities used in this Makefile 26 # This must be the first rule
27 BASENAME=basename 27 default:
28 CAT=cat
29 CD=cd
30 CMP=cmp
31 CP=cp
32 ECHO=echo
33 MKDIR=mkdir
34 PRINTF=printf
35 PWD=pwd
36 TAR=tar
37 ifeq ($(PLATFORM),windows)
38 ZIP=zip
39 else
40 # store symbolic links as the link
41 ZIP=zip -y
42 endif
43 # Insure we have a path that looks like it came from pwd
44 # (This is mostly for Windows sake and drive letters)
45 define UnixPath # path
46 $(shell (cd "$1" && $(PWD)))
47 endef
48 28
49 # Current root directory 29 # Inclusion of this pseudo-target will cause make to execute this file
50 CURRENT_DIRECTORY := $(shell $(PWD)) 30 # serially, regardless of -j. Recursively called makefiles will not be
31 # affected, however. This is required for correct dependency management.
32 .NOTPARALLEL:
51 33
52 # Build directory root 34 # The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
53 BUILD_DIR_ROOT = $(CURRENT_DIRECTORY)/build 35 # /usr/ccs/bin/make lacks basically every other flow control mechanism.
36 TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1
54 37
55 # All configured Makefiles to run 38 # Assume we have GNU make, but check version.
56 ALL_MAKEFILES = $(wildcard $(BUILD_DIR_ROOT)/*-*/Makefile) 39 ifeq (,$(findstring 3.81,$(MAKE_VERSION)))
57 40 ifeq (,$(findstring 3.82,$(MAKE_VERSION)))
58 # All bundles to create 41 $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
59 ALL_IMAGE_DIRS = $(wildcard $(BUILD_DIR_ROOT)/*-*/images/*-image) 42 endif
60
61 # Build all the standard 'all', 'images', and 'clean' targets
62 all images clean: checks
63 @if [ "$(ALL_MAKEFILES)" = "" ] ; then \
64 $(ECHO) "ERROR: No configurations to build"; exit 1; \
65 fi
66 @for bdir in $(dir $(ALL_MAKEFILES)) ; do \
67 $(ECHO) "$(CD) $${bdir} && $(MAKE) $@" ; \
68 $(CD) $${bdir} && $(MAKE) $@ ; \
69 done
70
71 # TBD: Deploy input
72 $(BUILD_DIR_ROOT)/.deploy_input:
73 @if [ "$(ALL_MAKEFILES)" = "" ] ; then \
74 $(ECHO) "ERROR: No configurations to build"; exit 1; \
75 fi
76 @for bdir in $(dir $(ALL_MAKEFILES)) ; do \
77 if [ deploy/make/Makefile ] ; then \
78 echo "Attempting deploy build." ; \
79 ( \
80 $(RM) -r $${bdir}/deploy_input ; \
81 $(MKDIR) -p $${bdir}/deploy_input ; \
82 ( $(CD) $${bdir}/images && $(TAR) -cf - j2sdk-image j2re-image ) \
83 | ( $(CD) $${bdir}/deploy_input && $(TAR) -xf - ) ; \
84 ) ; \
85 fi; \
86 done
87 touch $@
88
89 # TBD: Deploy images
90 deploy: $(BUILD_DIR_ROOT)/.deploy_input
91 @if [ "$(ALL_MAKEFILES)" = "" ] ; then \
92 $(ECHO) "ERROR: No configurations to build"; exit 1; \
93 fi
94 @for bdir in $(dir $(ALL_MAKEFILES)) ; do \
95 if [ deploy/make/Makefile ] ; then \
96 echo "Attempting deploy build." ; \
97 ( \
98 $(CD) deploy/make && \
99 $(MAKE) \
100 ABS_OUTPUTDIR=$${bdir}/deploy_input \
101 OUTPUTDIR=$${bdir}/deploy_input \
102 ) ; \
103 fi; \
104 done
105
106 # TBD: Install bundles
107 install:
108
109 # Bundle creation
110 bundles:
111 @if [ "$(ALL_IMAGE_DIRS)" = "" ] ; then \
112 $(ECHO) "ERROR: No images to bundle"; exit 1; \
113 fi
114 @for i in $(ALL_IMAGE_DIRS) ; do \
115 $(MKDIR) -p $${i}/../../bundles && \
116 $(RM) $${i}/../../bundles/`$(BASENAME) $${i}`.zip && \
117 $(ECHO) "$(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip ." && \
118 $(CD) $${i} && $(ZIP) -q -r ../../bundles/`$(BASENAME) $${i}`.zip . ; \
119 done
120
121 # Clobber all the built files
122 clobber::
123 $(RM) -r $(BUILD_DIR_ROOT)
124
125 # Make various checks to insure the build will be successful
126 # Possibilities:
127 # * Check that if any closed repo is provided, they all must be.
128 # * Check that all open repos exist, at least until we are ready for some
129 # kind of partial build.
130 checks:
131 @$(ECHO) "No checks yet"
132
133 # Keep track of user targets
134 USER_TARGETS += all deploy install images clean clobber checks
135
136 ###########################################################################
137 # To help in adoption of the new configure&&make build process, a bridge
138 # build will use the old settings to run configure and do the build.
139
140 # Build with the configure bridge
141 bridgeBuild: bridge2configure images
142
143 # Bridge from old Makefile ALT settings to configure options
144 bridge2configure: $(BUILD_DIR_ROOT)/.bridge2configureOpts
145 bash ./configure $(strip $(shell $(CAT) $<))
146
147 # Create a file with configure options created from old Makefile mechanisms.
148 $(BUILD_DIR_ROOT)/.bridge2configureOpts: $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest
149 $(RM) $@
150 $(CP) $< $@
151
152 # Use this file to only change when obvious things have changed
153 $(BUILD_DIR_ROOT)/.bridge2configureOptsLatest: FRC
154 $(RM) $@.tmp
155 $(MKDIR) -p $(BUILD_DIR_ROOT)
156 @$(ECHO) " --with-debug-level=$(if $(DEBUG_LEVEL),$(DEBUG_LEVEL),release) " >> $@.tmp
157 ifdef ARCH_DATA_MODEL
158 @$(ECHO) " --with-target-bits=$(ARCH_DATA_MODEL) " >> $@.tmp
159 endif
160 ifdef ALT_PARALLEL_COMPILE_JOBS
161 @$(ECHO) " --with-num-cores=$(ALT_PARALLEL_COMPILE_JOBS) " >> $@.tmp
162 endif
163 ifdef ALT_BOOTDIR
164 @$(ECHO) " --with-boot-jdk=$(call UnixPath,$(ALT_BOOTDIR)) " >> $@.tmp
165 endif
166 ifdef ALT_CUPS_HEADERS_PATH
167 @$(ECHO) " --with-cups-include=$(call UnixPath,$(ALT_CUPS_HEADERS_PATH)) " >> $@.tmp
168 endif
169 ifdef ALT_FREETYPE_HEADERS_PATH
170 @$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp
171 endif
172 @if [ -f $@ ] ; then \
173 if ! $(CMP) $@ $@.tmp > /dev/null ; then \
174 $(CP) $@.tmp $@ ; \
175 fi ; \
176 else \
177 $(CP) $@.tmp $@ ; \
178 fi
179 $(RM) $@.tmp
180
181 # Clobber all the built files
182 clobber:: bridge2clobber
183 bridge2clobber::
184 $(RM) $(BUILD_DIR_ROOT)/.bridge2*
185 $(RM) $(BUILD_DIR_ROOT)/.deploy_input
186
187 # Keep track of phony targets
188 PHONY_LIST += bridge2configure bridgeBuild bridge2clobber
189
190 ###########################################################################
191 # Sanity checks (history target)
192 #
193
194 sanity: checks
195
196 # Keep track of user targets
197 USER_TARGETS += sanity
198
199 ###########################################################################
200 # Javadocs
201 #
202
203 javadocs:
204 cd common/makefiles && $(MAKE) -f MakefileJavadoc.gmk
205
206 # Keep track of user targets
207 USER_TARGETS += javadocs
208
209 ###########################################################################
210 # JPRT targets
211
212 ifndef JPRT_ARCHIVE_BUNDLE
213 JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/j2sdk-image.zip
214 endif 43 endif
215 44
216 jprt_build_product: DEBUG_LEVEL=release 45 # Locate this Makefile
217 jprt_build_product: BUILD_DIRNAME=*-release 46 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
218 jprt_build_product: jprt_build_generic 47 makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
48 else
49 makefile_path:=$(lastword $(MAKEFILE_LIST))
50 endif
51 root_dir:=$(dir $(makefile_path))
219 52
220 jprt_build_fastdebug: DEBUG_LEVEL=fastdebug 53 include $(root_dir)/common/makefiles/Jprt.gmk
221 jprt_build_fastdebug: BUILD_DIRNAME=*-fastdebug
222 jprt_build_fastdebug: jprt_build_generic
223 54
224 jprt_build_debug: DEBUG_LEVEL=slowdebug 55 # ... and then we can include our helper functions
225 jprt_build_debug: BUILD_DIRNAME=*-debug 56 include $(root_dir)/common/makefiles/MakeHelpers.gmk
226 jprt_build_debug: jprt_build_generic
227 57
228 jprt_build_generic: $(JPRT_ARCHIVE_BUNDLE) 58 $(eval $(call ParseLogLevel))
59 $(eval $(call ParseConfAndSpec))
229 60
230 $(JPRT_ARCHIVE_BUNDLE): bridgeBuild bundles 61 # Now determine if we have zero, one or several configurations to build.
231 $(MKDIR) -p $(@D) 62 ifeq ($(SPEC),)
232 $(RM) $@ 63 # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
233 $(CP) $(BUILD_DIR_ROOT)/$(BUILD_DIRNAME)/bundles/j2sdk-image.zip $@ 64 else
65 ifeq ($(words $(SPEC)),1)
66 # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
67 include $(root_dir)/common/makefiles/Main.gmk
68 else
69 # We are building multiple configurations.
70 # First, find out the valid targets
71 # Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
72 # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
73 all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \
74 $(MAKE) -p -q -f common/makefiles SPEC=$(firstword $(SPEC)) | \
75 grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
234 76
235 # Keep track of phony targets 77 $(all_phony_targets):
236 PHONY_LIST += jprt_build_product jprt_build_fastdebug jprt_build_debug \ 78 @$(foreach spec,$(SPEC),($(MAKE) -f NewMakefile.gmk SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
237 jprt_build_generic
238 79
239 ########################################################################### 80 endif
240 # Help target 81 endif
241 82
242 HELP_FORMAT=%12s%s\n 83 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
84 # If you addd more global targets, please update the variable global_targets in MakeHelpers.
243 85
244 help: 86 help:
245 @$(PRINTF) "# JDK Makefile\n" 87 $(info )
246 @$(PRINTF) "#\n" 88 $(info OpenJDK Makefile help)
247 @$(PRINTF) "# Usage: make [Target]\n" 89 $(info =====================)
248 @$(PRINTF) "#\n" 90 $(info )
249 @$(PRINTF) "# $(HELP_FORMAT)" "Target " "Description" 91 $(info Common make targets)
250 @$(PRINTF) "# $(HELP_FORMAT)" "------ " "-----------" 92 $(info . make [default] # Compile all product in langtools, hotspot, jaxp, jaxws,)
251 @for i in $(USER_TARGETS) ; do \ 93 $(info . # corba and jdk)
252 $(MAKE) help_$${i} ; \ 94 $(info . make all # Compile everything, all repos and images)
253 done 95 $(info . make images # Create complete j2sdk and j2re images)
254 @$(PRINTF) "#\n" 96 $(info . make overlay-images # Create limited images for sparc 64 bit platforms)
97 $(info . make bootcycle-images # Build images twice, second time with newly build JDK)
98 $(info . make install # Install the generated images locally)
99 $(info . make clean # Remove all files generated by make, but not those)
100 $(info . # generated by configure)
101 $(info . make dist-clean # Remove all files, including configuration)
102 $(info . make help # Give some help on using make)
103 $(info . make test # Run tests, default is all tests (see TEST below))
104 $(info )
105 $(info Targets for specific components)
106 $(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
107 $(info . make <component> # Build <component> and everything it depends on. )
108 $(info . make <component>-only # Build <component> only, without dependencies. This)
109 $(info . # is faster but can result in incorrect build results!)
110 $(info . make clean-<component> # Remove files generated by make for <component>)
111 $(info )
112 $(info Useful make variables)
113 $(info . make CONF= # Build all configurations (note, assignment is empty))
114 $(info . make CONF=<substring> # Build the configuration(s) with a name matching)
115 $(info . # <substring>)
116 $(info )
117 $(info . make LOG=<loglevel> # Change the log level from warn to <loglevel>)
118 $(info . # Available log levels are:)
119 $(info . # 'warn' (default), 'info', 'debug' and 'trace')
120 $(info . # To see executed command lines, use LOG=debug)
121 $(info )
122 $(info . make JOBS=<n> # Run <n> parallel make jobs)
123 $(info . # Note that -jN does not work as expected!)
124 $(info )
125 $(info . make test TEST=<test> # Only run the given test or tests, e.g.)
126 $(info . # make test TEST="jdk_lang jdk_net")
127 $(info )
255 128
256 help_all: 129 .PHONY: help
257 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
258 "Build the entire jdk but not the images"
259 help_images:
260 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
261 "Create the jdk images for the builds"
262 help_deploy:
263 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
264 "Create the jdk deploy images from the jdk images"
265 help_install:
266 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
267 "Create the jdk install bundles from the deploy images"
268 help_clean:
269 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
270 "Clean and prepare for a fresh build from scratch"
271 help_clobber:
272 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
273 "Clean and also purge any hidden derived data"
274 help_checks:
275 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
276 "Perform various checks to make sure we can build"
277 help_sanity:
278 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
279 "Same as 'make checks'"
280 help_javadocs:
281 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
282 "Build the javadocs"
283 help_help:
284 @$(PRINTF) "# $(HELP_FORMAT)" "$(subst help_,,$@) - " \
285 "Print out the help messages"
286
287 # Keep track of user targets
288 USER_TARGETS += help
289
290 ###########################################################################
291 # Phony targets
292 .PHONY: $(PHONY_LIST) $(USER_TARGETS)
293
294 # Force target
295 FRC:

mercurial