4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
26 GEM
=/usr
/ruby
/$(RUBY_VERSION
)/bin
/gem
28 VENDOR_GEM_DIR
=/usr
/ruby
/$(RUBY_VERSION
)/lib
/ruby
/vendor_ruby
/gems
/$(RUBY_LIB_VERSION
)
30 # Name of the gem spec to use. This will typically be
31 # <component_name>.gemspec
32 GEMSPEC
=$(COMPONENT_NAME
).gemspec
35 # Some gems projects have to be built using rake
36 # Allow GEM build/install commands to be overwritten
37 # to account for possible differences
38 GEM_BUILD_ACTION
=(cd
$(@D
); $(GEM
) build
$(GEM_BUILD_ARGS
) $(GEMSPEC
))
40 # Build install args in a more readable fashion
41 ifeq ($(firstword $(subst .
,$(space
),$(RUBY_VERSION
))),2)
42 # gem install 2.x does docs differently. Continue to generate both types
43 GEM_INSTALL_ARGS
+= --document rdoc
,ri
46 GEM_INSTALL_ARGS
+= -V
--local
--force
47 GEM_INSTALL_ARGS
+= --install-dir
$(PROTO_DIR
)/$(VENDOR_GEM_DIR
)
48 GEM_INSTALL_ARGS
+= --bindir $(PROTO_DIR
)/$(VENDOR_GEM_DIR
)/bin
50 # cd into build directory
51 # gem 2.2.3 uses .gem from the cwd ignoring command line .gem file
52 # gem 1.8.23.2 uses command line .gem file OR .gem from cwd
53 GEM_INSTALL_ACTION
= (cd
$(@D
); $(GEM
) install $(GEM_INSTALL_ARGS
) $(COMPONENT_NAME
))
56 $(BUILD_DIR
)/%/.built
: $(SOURCE_DIR
)/.prep
57 $(RM
) -r
$(@D
) ; $(MKDIR
) $(@D
)
58 $(GTAR
) -C
$(SOURCE_DIR
) -cpf
- . |
$(GTAR
) -C
$(@D
) -xpf
-
59 $(COMPONENT_PRE_BUILD_ACTION
)
60 # Build the gem and cause the generation of a new gem spec
61 # file in $(COMPONENT_SRC)
63 $(COMPONENT_POST_BUILD_ACTION
)
66 $(BUILD_DIR
)/%/.installed
: $(BUILD_DIR
)/%/.built
67 $(COMPONENT_PRE_INSTALL_ACTION
)
68 $(MKDIR
) $(PROTO_DIR
)/$(GEM_DIR
)
69 # Install the new recreated gem
71 $(COMPONENT_POST_INSTALL_ACTION
)
74 COMPONENT_TEST_TARGETS
=
76 # Test the built source. If the output file shows up in the environment or
77 # arguments, don't redirect stdout/stderr to it.
78 $(BUILD_DIR
)/%/.tested-and-compared
: $(BUILD_DIR
)/%/.built
79 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
80 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
81 $(COMPONENT_PRE_TEST_ACTION
)
82 -(cd
$(COMPONENT_TEST_DIR
) ; \
83 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
84 $(COMPONENT_TEST_CMD
) \
85 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
86 $(if
$(findstring $(COMPONENT_TEST_OUTPUT
),$(COMPONENT_TEST_ENV
)$(COMPONENT_TEST_ARGS
)),,&> $(COMPONENT_TEST_OUTPUT
))
87 $(COMPONENT_POST_TEST_ACTION
)
88 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
89 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
90 $(COMPONENT_TEST_COMPARE
)
91 $(COMPONENT_TEST_CLEANUP
)
95 $(BUILD_DIR
)/%/.tested
: SHELLOPTS
=pipefail
96 $(BUILD_DIR
)/%/.tested
: $(COMPONENT_TEST_DEP
)
97 $(RM
) -rf
$(COMPONENT_TEST_BUILD_DIR
)
98 $(MKDIR
) $(COMPONENT_TEST_BUILD_DIR
)
99 $(COMPONENT_PRE_TEST_ACTION
)
100 (cd
$(COMPONENT_TEST_DIR
) ; \
101 $(COMPONENT_TEST_ENV_CMD
) $(COMPONENT_TEST_ENV
) \
102 $(COMPONENT_TEST_CMD
) \
103 $(COMPONENT_TEST_ARGS
) $(COMPONENT_TEST_TARGETS
)) \
104 $(if
$(findstring $(COMPONENT_TEST_OUTPUT
),$(COMPONENT_TEST_ENV
)$(COMPONENT_TEST_ARGS
)),,|
& $(TEE
) $(COMPONENT_TEST_OUTPUT
))
105 $(COMPONENT_POST_TEST_ACTION
)
106 $(COMPONENT_TEST_CREATE_TRANSFORMS
)
107 $(COMPONENT_TEST_PERFORM_TRANSFORM
)
108 $(COMPONENT_TEST_CLEANUP
)
112 $(RM
) -r
$(SOURCE_DIR
) $(BUILD_DIR
)
114 USERLAND_REQUIRED_PACKAGES
+= runtime
/ruby