commit | author | age
|
41e750
|
1 |
# |
AP |
2 |
# CDDL HEADER START |
|
3 |
# |
|
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. |
|
7 |
# |
|
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. |
|
12 |
# |
|
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] |
|
18 |
# |
|
19 |
# CDDL HEADER END |
|
20 |
# |
|
21 |
|
|
22 |
# |
|
23 |
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
24 |
# |
|
25 |
# |
|
26 |
# Rules and Macros for building open source software that builds with |
|
27 |
# ninja (whether using a provided ninja file or one generated by a tool |
|
28 |
# such as meson). |
|
29 |
# |
|
30 |
# To use these rules on their own, set BUILD_STYLE=ninja before including |
|
31 |
# $(WS_MAKE_RULES)/common.mk. They will also be used for the build rules |
|
32 |
# if you set BUILD_STYLE=meson. |
|
33 |
# |
|
34 |
# Any additional pre/post configure, build, or install actions can be specified |
|
35 |
# in your Makefile by setting them in on of the following macros: |
|
36 |
# COMPONENT_PRE_BUILD_ACTION, COMPONENT_BUILD_ACTION, |
|
37 |
# COMPONENT_POST_BUILD_ACTION, COMPONENT_PRE_INSTALL_ACTION, |
|
38 |
# COMPONENT_INSTALL_ACTION, COMPONENT_POST_INSTALL_ACTION |
|
39 |
# |
|
40 |
# If component specific ninja targets need to be used for build or install, they |
|
41 |
# can be specified in |
|
42 |
# COMPONENT_BUILD_TARGETS, COMPONENT_INSTALL_TARGETS |
|
43 |
# |
|
44 |
|
|
45 |
NINJA = /usr/bin/ninja |
|
46 |
|
|
47 |
COMPONENT_INSTALL_ENV += DESTDIR=$(PROTO_DIR) |
|
48 |
COMPONENT_INSTALL_ARGS += $(COMPONENT_INSTALL_ARGS.$(BITS)) |
|
49 |
|
|
50 |
COMPONENT_BUILD_ACTION ?= \ |
|
51 |
$(ENV) $(COMPONENT_BUILD_ENV) \ |
|
52 |
$(NINJA) -C $(@D) $(COMPONENT_BUILD_ARGS) $(COMPONENT_BUILD_TARGETS) |
|
53 |
|
|
54 |
# build the configured source |
|
55 |
$(BUILD_DIR)/%/.built: $(BUILD_DIR)/%/.configured |
|
56 |
$(COMPONENT_PRE_BUILD_ACTION) |
|
57 |
($(COMPONENT_BUILD_ACTION)) |
|
58 |
$(COMPONENT_POST_BUILD_ACTION) |
|
59 |
$(TOUCH) $@ |
|
60 |
|
|
61 |
COMPONENT_INSTALL_ACTION ?= \ |
|
62 |
$(ENV) $(COMPONENT_INSTALL_ENV) \ |
|
63 |
$(NINJA) -C $(@D) $(COMPONENT_INSTALL_ARGS) $(COMPONENT_INSTALL_TARGETS) |
|
64 |
|
|
65 |
# install the built source into a prototype area |
|
66 |
$(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built |
|
67 |
$(COMPONENT_PRE_INSTALL_ACTION) |
|
68 |
($(COMPONENT_INSTALL_ACTION)) |
|
69 |
$(COMPONENT_POST_INSTALL_ACTION) |
|
70 |
$(TOUCH) $@ |
|
71 |
|
|
72 |
# set the default command to use for test of the component |
|
73 |
COMPONENT_TEST_CMD = $(NINJA) |
|
74 |
COMPONENT_SYSTEM_TEST_CMD = $(NINJA) |
|
75 |
|
|
76 |
# set the default target for test of the component |
|
77 |
COMPONENT_TEST_TARGETS = test |
|
78 |
COMPONENT_SYSTEM_TEST_TARGETS = test |
|
79 |
|
|
80 |
# test the built source |
b6799e
|
81 |
$(BUILD_DIR)/%/.tested-and-compared: $(COMPONENT_TEST_DEP) |
41e750
|
82 |
$(RM) -rf $(COMPONENT_TEST_BUILD_DIR) |
AP |
83 |
$(MKDIR) $(COMPONENT_TEST_BUILD_DIR) |
|
84 |
$(COMPONENT_PRE_TEST_ACTION) |
|
85 |
-(cd $(COMPONENT_TEST_DIR) ; \ |
|
86 |
$(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \ |
|
87 |
$(COMPONENT_TEST_CMD) \ |
|
88 |
$(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \ |
|
89 |
&> $(COMPONENT_TEST_OUTPUT) |
|
90 |
$(COMPONENT_POST_TEST_ACTION) |
|
91 |
$(COMPONENT_TEST_CREATE_TRANSFORMS) |
|
92 |
$(COMPONENT_TEST_PERFORM_TRANSFORM) |
|
93 |
$(COMPONENT_TEST_COMPARE) |
|
94 |
$(COMPONENT_TEST_CLEANUP) |
|
95 |
$(TOUCH) $@ |
|
96 |
|
89aae0
|
97 |
$(BUILD_DIR)/%/.tested: SHELLOPTS=pipefail |
b6799e
|
98 |
$(BUILD_DIR)/%/.tested: $(COMPONENT_TEST_DEP) |
89aae0
|
99 |
$(RM) -rf $(COMPONENT_TEST_BUILD_DIR) |
MT |
100 |
$(MKDIR) $(COMPONENT_TEST_BUILD_DIR) |
41e750
|
101 |
$(COMPONENT_PRE_TEST_ACTION) |
AP |
102 |
(cd $(COMPONENT_TEST_DIR) ; \ |
|
103 |
$(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \ |
|
104 |
$(COMPONENT_TEST_CMD) \ |
89aae0
|
105 |
$(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \ |
MT |
106 |
|& $(TEE) $(COMPONENT_TEST_OUTPUT) |
41e750
|
107 |
$(COMPONENT_POST_TEST_ACTION) |
89aae0
|
108 |
$(COMPONENT_TEST_CREATE_TRANSFORMS) |
MT |
109 |
$(COMPONENT_TEST_PERFORM_TRANSFORM) |
41e750
|
110 |
$(COMPONENT_TEST_CLEANUP) |
AP |
111 |
$(TOUCH) $@ |
|
112 |
|
|
113 |
clean:: |
|
114 |
$(RM) -r $(BUILD_DIR) $(PROTO_DIR) |
8203c7
|
115 |
|
MT |
116 |
USERLAND_REQUIRED_PACKAGES += developer/build/ninja |