doc/makefile-targets.txt | ●●●●● patch | view | raw | blame | history | |
make-rules/environment.mk | ●●●●● patch | view | raw | blame | history | |
make-rules/ips.mk | ●●●●● patch | view | raw | blame | history | |
make-rules/shared-macros.mk | ●●●●● patch | view | raw | blame | history | |
transforms/REQUIRED_PACKAGES | ●●●●● patch | view | raw | blame | history |
doc/makefile-targets.txt
New file @@ -0,0 +1,124 @@ This is a guide to explain various useful targets in Userland component Makefiles. There is a set of targets that all Makefiles must include, plus some addtional targets that are there for convenience. component-environment-check:: This target is an optional target that will be included in most Makefiles automatically. It is defined in $(WS_MAKE_RULES)/environment.mk which is included by $(WS_MAKE_RULES)/shares-macros.mk. It reports on some interesting information about the current environment and whether or not it is suitable to build, publish, or test the component. component-environment-prep:: This target is an optional target that will be included in most Makefiles automatically. It is defined in $(WS_MAKE_RULES)/environment.mk which is included by $(WS_MAKE_RULES)/shares-macros.mk. It uses the REQUIRE_PACKAGES macro contents to attempt to install any required packages in the current environment. It should never by used by developers to update any public build machines as those are managed by dedicated staff. download:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is typically defined by including $(WS_MAKE_RULES)/prep.mk in your component Makefile. This target depends on your component Makefile, so changes to your component Makefile will automatically trigger a re-download and subsequent build steps that depend on it. You can use the MAKEFILE_PREREQ macro to override this behaviour and avoid rebuilding with each Makefile change. This macro should only be used in the calling environment via something like: $ gmake MAKEFILE_PREREQ= install unpack:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is typically defined by including $(WS_MAKE_RULES)/prep.mk in your component Makefile. This target depends on the previously described "download" target, This target will unpack any downloaded source archives. It is an interim step in the source code preparation phase of the build. patch:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is typically defined by including $(WS_MAKE_RULES)/prep.mk in your component Makefile. This target depends on the previously described "unpack" target, This target will patch any unpacked source. It is an interim step in the source code preparation phase of the build. prep:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is typically defined by including $(WS_MAKE_RULES)/prep.mk in your component Makefile. It depends on the previously described "download" target, as well as internal interim targets to unpack source archives and apply patches to the unpacked source. configure: This target is an optional target that can be included in component Makefiles to run the community source configuration phase of a component build. It is typically defined in component Makefiles that make use of the $(WS_MAKE_RULES)/configure.mk Makefile fragment, but could be defined in others that include a source code configuration step. It is not explicitly called during the build, but provides a convenient means of downloading, unpacking, patching, and "configuring" component source for building without actually compiling the bits. build:: This target must be present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is defined in the individual component Makefiles, but most Makefile fragments under $(WS_MAKE_RULES) include targets that allow the definitions to depend on one of several convenience macros $(BUILD_32), $(BUILD_64), $(BUILD_32_and_64), and $(BUILD_NO_ARCH) to build 32-bit support, 64-bit support, both 32 and 64 bit support, or architecture neutral support. The macro used will depend on the component. install:: This target must be present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is defined in the individual component Makefiles, but most Makefile fragments under $(WS_MAKE_RULES) include targets that allow the definitions to depend on one of several convenience macros $(INSTALL_32), $(INSTALL_64), $(INSTALL_32_and_64), and $(INSTALL_NO_ARCH) to install 32-bit support, 64-bit support, both 32 and 64 bit support, or architecture neutral support. The macro used will depend on the component and corresponds to the build target macro used. pkglint:: This target is an optional target is automatically defined in each Makefile by the inclusion of $(WS_MAKE_RULES)/prep.mk. It will run the build steps necessary to pkglint the manifests for a component. publish:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is automatically defined by including $(WS_MAKE_RULES)/ips.mk. It depends on the previously described 'install' target and will perform a series of internal, intermediate steps to use the component package manifests to generate and publish packages for that component. clean:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is often automatically defined by including one of the $(WS_MAKE_RULES) Makefile fragments. It cleans up any files created by building the component with the exception of any downloaded files. clobber:: This target is present in all Makefiles. It can be used at the top level to act across all components, or on an individual component basis. It is often automatically defined by including one of the $(WS_MAKE_RULES) Makefile fragments. It depends on the previously described 'clean' target and additionally cleans up any downloaded source archives. In addition, when done from the top level or component sub-directory, it will do a find of 'manifest-*.published' and clean those up; these can be left over from components that were published but then 'hg rm'd before the next clobber. REQUIRED_PACKAGES:: This target is present in all component Makefiles. It is automatically defined by including $(WS_MAKE_RULES)/ips.mk. It is a convenience that can be used to generate the set of REQUIRED_PACKAGES that is needed by the 'pkgdepend resolve' portion of package generation and publication (publish target). It automatically appends to the component Makefile, but the results should be manually verified. make-rules/environment.mk
New file @@ -0,0 +1,101 @@ # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. # SUDO = /usr/bin/sudo define separator-line @$(PYTHON) -c 'l="="*(40-len("$1")/2); print("%s%s%s" % (l, "$1", l))' endef component-environment-check:: $(call separator-line,Workspace) @echo " Path: $(WS_TOP)" @echo " Branch: $$(hg identify -b)" @echo " Changeset: $$(hg identify -n)($$(hg identify -i))" $(call separator-line,System) @/usr/bin/uname -a @echo "Zone: $$(/usr/sbin/zonename)" @/usr/sbin/psrinfo -vp @/usr/sbin/ipadm show-addr $(call separator-line,Required Packages) @/usr/bin/pkg list -vH $(REQUIRED_PACKAGES:%=/%) $(call separator-line) component-environment-prep:: @echo "Adding required packages to build environment..." @-echo $(REQUIRED_PACKAGES:%=/%) | xargs \ $(SUDO) /usr/bin/pkg install --accept -v # # For building in a constructed zone. Currently this assumes a template zone # with /ws (tools mountpoint) and /builds (workspace mountpoint) mounted # in the same place as in the global zone. It also assumes the current # $USER account is replicated in the template zone. # ZONENAME=bz-$(shell echo "$(WS_TOP)" | md5sum | cut -c0-7)-$(COMPONENT_NAME) $(BUILD_DIR)/packages.xml: Makefile $(BUILD_DIR) @echo "$(REQUIRED_PACKAGES:%=\t\t<name>pkg:/%</name>\n)" >$(@) $(BUILD_DIR)/ai_manifest.xml: $(WS_TOOLS)/zone_default.xml $(BUILD_DIR) $(CP) $< $(@) $(BUILD_DIR)/sc_profile.xml: $(WS_TOOLS)/sc_profile.xml $(BUILD_DIR) $(GSED) -e "s/XXX_USER_XXX/$${USER}/g" -e "s/XXX_UID_XXX/$$(id -u)/g" $< >$(@) component-zone-build: $(BUILD_DIR)/ai_manifest.xml $(BUILD_DIR)/packages.xml \ $(BUILD_DIR)/sc_profile.xml download $(call separator-line) $(call separator-line,Create $(ZONENAME)) $(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) create -t template #@$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) clone template $(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) install \ -m $(BUILD_DIR)/ai_manifest.xml \ -c $(BUILD_DIR)/sc_profile.xml $(call separator-line,Boot $(ZONENAME)) $(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) boot @while $$(true) ; do \ echo "waiting for zone ..." ; \ $(SUDO) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \ /bin/true >/dev/null 2>&1 && break ; \ sleep 10 ; \ done #$(call separator-line,Prep $(ZONENAME)) #@$(SUDO) /usr/sbin/zlogin -S $(ZONENAME) \ # "cd $(COMPONENT_DIR) ; gmake component-be-prep" $(call separator-line,Build in $(ZONENAME)) $(SUDO) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \ "cd $(COMPONENT_DIR) ; gmake component-be-check install" # "cd $(COMPONENT_DIR) ; gmake component-be-check publish PKGLINT=/bin/true" $(call separator-line,Halt $(ZONENAME)) $(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) halt $(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) uninstall -F $(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) delete -F $(call separator-line) component-zone-cleanup:: -$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) halt -$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) uninstall -F -$(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) delete -F make-rules/ips.mk
@@ -47,6 +47,8 @@ endif PKGMANGLE = $(WS_TOOLS)/userland-mangler WS_TRANSFORMS = $(WS_TOP)/transforms GENERATE_HISTORY= $(WS_TOOLS)/generate-history HISTORY= history @@ -375,6 +377,20 @@ $(PKGDEPEND) resolve $(EXTDEPFILES:%=-e %) -m $(DEPENDED) $(TOUCH) $@ # # Generate a set of REQUIRED_PACKAGES based on what is needed to for pkgdepend # to resolve properly. Automatically append this to your Makefile for the truly # lazy among us. This is only a piece of the REQUIRED_PACKAGES puzzle. # You must still include packages for tools you build and test with. # REQUIRED_PACKAGES:: $(RESOLVED) $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH) @echo "# Auto-generated contents below. Please manually verify and remove this comment" >>Makefile @$(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) | \ $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' | sort -u >>Makefile @echo "*** Please edit your Makefile and verify the new content at the end ***" # lint the manifests all at once $(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH) @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)" make-rules/shared-macros.mk
@@ -992,3 +992,48 @@ component-hook: @$(COMPONENT_HOOK) # # Packages with tools that are required to build Userland components # REQUIRED_PACKAGES += developer/build/gnu-make REQUIRED_PACKAGES += developer/build/make ifeq ($(COMPILER),gcc) REQUIRED_PACKAGES += developer/gcc-53 endif ifeq ($(COMPILER),studio) ifneq ($(findstring /opt/solarisstudio12.4,$(CC)),) # If we are setup to build with an installed compiler, require the package # we can uncomment this when we know that pkglint can find it. #REQUIRED_PACKAGES += /solarisstudio/developer/solarisstudio-124 endif endif ifeq ($(PARFAIT_BUILD),yes) # uncomment this line if you need to install Parfait #REQUIRED_PACKAGES += developer/parfait/parfait-tools-161 endif REQUIRED_PACKAGES += developer/versioning/mercurial REQUIRED_PACKAGES += file/gnu-findutils REQUIRED_PACKAGES += package/pkg REQUIRED_PACKAGES += runtime/python-27 REQUIRED_PACKAGES += shell/bash REQUIRED_PACKAGES += shell/ksh93 REQUIRED_PACKAGES += system/linker REQUIRED_PACKAGES += text/gawk REQUIRED_PACKAGES += text/gnu-grep REQUIRED_PACKAGES += text/gnu-sed REQUIRED_PACKAGES += developer/java/jdk-8 REQUIRED_PACKAGES += security/sudo # Only a default dependency if component being built produces binaries. ifneq ($(strip $(BUILD_BITS)),NO_ARCH) REQUIRED_PACKAGES += system/library endif include $(WS_MAKE_RULES)/environment.mk # A simple rule to print the value of any macro. Ex: # $ gmake print-REQUIRED_PACKAGES # Note that some macros are set on a per target basis, so what you see # is not always what you get. print-%: @echo '$(subst ','\'',$*=$($*)) (origin: $(origin $*), flavor: $(flavor $*))' transforms/REQUIRED_PACKAGES
New file @@ -0,0 +1,4 @@ # print a line "REQUIRED_PACKAGES += {pkg-short-name}" <transform depend fmri=pkg:/(.+)@.+ -> print REQUIRED_PACKAGES += %<1> > # drop all actions <transform -> drop >