| @@ -1,182 +1,183 @@ | | | @@ -1,182 +1,183 @@ |
1 | #!/bin/sh | | 1 | #!/bin/sh |
2 | # | | 2 | # |
3 | # $NetBSD: createbuildlink,v 1.39 2020/05/16 06:28:52 rillig Exp $ | | 3 | # $NetBSD: createbuildlink,v 1.40 2022/07/08 18:06:19 rillig Exp $ |
4 | # | | 4 | # |
5 | # Copyright (c) 2002 The NetBSD Foundation, Inc. | | 5 | # Copyright (c) 2002 The NetBSD Foundation, Inc. |
6 | # All rights reserved. | | 6 | # All rights reserved. |
7 | # | | 7 | # |
8 | # This code is derived from software contributed to The NetBSD Foundation | | 8 | # This code is derived from software contributed to The NetBSD Foundation |
9 | # by Rene Hexel. | | 9 | # by Rene Hexel. |
10 | # | | 10 | # |
11 | # Redistribution and use in source and binary forms, with or without | | 11 | # Redistribution and use in source and binary forms, with or without |
12 | # modification, are permitted provided that the following conditions | | 12 | # modification, are permitted provided that the following conditions |
13 | # are met: | | 13 | # are met: |
14 | # 1. Redistributions of source code must retain the above copyright | | 14 | # 1. Redistributions of source code must retain the above copyright |
15 | # notice, this list of conditions and the following disclaimer. | | 15 | # notice, this list of conditions and the following disclaimer. |
16 | # 2. Redistributions in binary form must reproduce the above copyright | | 16 | # 2. Redistributions in binary form must reproduce the above copyright |
17 | # notice, this list of conditions and the following disclaimer in the | | 17 | # notice, this list of conditions and the following disclaimer in the |
18 | # documentation and/or other materials provided with the distribution. | | 18 | # documentation and/or other materials provided with the distribution. |
19 | # | | 19 | # |
20 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 20 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
21 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | # POSSIBILITY OF SUCH DAMAGE. | | 30 | # POSSIBILITY OF SUCH DAMAGE. |
31 | # | | 31 | # |
32 | # Create an initial buildlink3.mk from a package's Makefile and PLIST | | 32 | # Create an initial buildlink3.mk from a package's Makefile and PLIST |
33 | # | | 33 | # |
34 | | | 34 | |
35 | REV=`echo '$Revision: 1.39 $' | sed 's/\\$//g'` | | 35 | REV=`echo '$Revision: 1.40 $' | sed 's/\\$//g'` |
36 | tmpdir=/tmp | | 36 | tmpdir=/tmp |
37 | spacesintab=8 | | 37 | spacesintab=8 |
38 | makefile=Makefile | | 38 | makefile=Makefile |
39 | sedrules=$tmpdir/sedrules.buildlink.$$ | | 39 | sedrules=$tmpdir/sedrules.buildlink.$$ |
40 | PLIST=PLIST | | 40 | PLIST=PLIST |
41 | CREATEPLSUBST=false | | 41 | CREATEPLSUBST=false |
42 | | | 42 | |
43 | args=`getopt 3p $*` | | 43 | args=`getopt 3p $*` |
44 | if [ $? != 0 ]; then | | 44 | if [ $? != 0 ]; then |
45 | echo "Usage: $0 [-p] > buildlink3.mk" | | 45 | echo "Usage: $0 [-p] > buildlink3.mk" |
46 | exit 2 | | 46 | exit 2 |
47 | fi | | 47 | fi |
48 | set -- $args | | 48 | set -- $args |
49 | while [ $# -gt 0 ]; do | | 49 | while [ $# -gt 0 ]; do |
50 | case "$1" in | | 50 | case "$1" in |
51 | -3) | | 51 | -3) |
52 | shift;; | | 52 | shift;; |
53 | -p) | | 53 | -p) |
54 | CREATEPLSUBST=true | | 54 | CREATEPLSUBST=true |
55 | shift;; | | 55 | shift;; |
56 | --) | | 56 | --) |
57 | shift; break | | 57 | shift; break |
58 | ;; | | 58 | ;; |
59 | esac | | 59 | esac |
60 | shift | | 60 | shift |
61 | done | | 61 | done |
62 | | | 62 | |
63 | ## | | 63 | ## |
64 | ## some simple integrity checking | | 64 | ## some simple integrity checking |
65 | ## | | 65 | ## |
66 | if [ ! -f $makefile ]; then | | 66 | if [ ! -f $makefile ]; then |
67 | echo "===> Incomplete package! To create a buildlink file <===" | | 67 | echo "===> Incomplete package! To create a buildlink file <===" |
68 | echo "===> a working $makefile is required! <===" | | 68 | echo "===> a working $makefile is required! <===" |
69 | exit 1 | | 69 | exit 1 |
70 | fi | | 70 | fi |
71 | | | 71 | |
72 | ## | | 72 | ## |
73 | ## try to find any included Makefile.common's | | 73 | ## try to find any included Makefile.common's |
74 | ## | | 74 | ## |
75 | commons=`grep '^.include.*Makefile.common\"' $makefile | \ | | 75 | commons=`grep '^.include.*Makefile.common\"' $makefile | \ |
76 | sed 's/^.*"\(.*\)".*/\1/'` | | 76 | sed 's/^.*"\(.*\)".*/\1/'` |
77 | | | 77 | |
78 | ## | | 78 | ## |
79 | ## package specific variables | | 79 | ## package specific variables |
80 | ## | | 80 | ## |
81 | CURDIR=`pwd | sed 's|^.*/\([^/]*/[^/]*\)$|\1|'` | | 81 | CURDIR=`pwd | sed 's|^.*/\([^/]*/[^/]*\)$|\1|'` |
82 | PKGNAME=`@MAKE@ show-var VARNAME=PKGNAME` | | 82 | PKGNAME=`@MAKE@ show-var VARNAME=PKGNAME` |
83 | PKGVER=`echo $PKGNAME | sed -e 's/^.*-//'` | | 83 | PKGVER=`echo $PKGNAME | sed -e 's/^.*-//'` |
84 | PKGNOVER=`echo $PKGNAME | sed -e 's/-[^-]*$//'` | | 84 | PKGNOVER=`echo $PKGNAME | sed -e 's/-[^-]*$//'` |
85 | PKGUPPER=`echo $PKGNOVER | tr '[:lower:]' '[:upper:]' | tr - _` | | 85 | PKGUPPER=`echo $PKGNOVER | tr '[:lower:]' '[:upper:]' | tr - _` |
86 | GO_PACKAGE=`@MAKE@ show-var VARNAME=GO_SRCPATH` | | 86 | GO_PACKAGE=`@MAKE@ show-var VARNAME=GO_SRCPATH` |
87 | PREFIX=LOCALBASE | | 87 | PREFIX=LOCALBASE |
88 | | | 88 | |
89 | ## | | 89 | ## |
90 | ## create sed rules | | 90 | ## create sed rules |
91 | ## | | 91 | ## |
92 | echo >$sedrules "s|@@CURDIR@@|$CURDIR|g" | | 92 | echo >$sedrules "s|@@CURDIR@@|$CURDIR|g" |
93 | echo >>$sedrules "s|@@ID@@|\$Net""BSD\$|g" | | 93 | echo >>$sedrules "s|@@ID@@|\$Net""BSD\$|g" |
94 | echo >>$sedrules "s|@@PKGNAME@@|$PKGNAME|g" | | 94 | echo >>$sedrules "s|@@PKGNAME@@|$PKGNAME|g" |
95 | echo >>$sedrules "s|@@PKGNOVER@@|$PKGNOVER|g" | | 95 | echo >>$sedrules "s|@@PKGNOVER@@|$PKGNOVER|g" |
96 | echo >>$sedrules "s|@@PKGUPPER@@|$PKGUPPER|g" | | 96 | echo >>$sedrules "s|@@PKGUPPER@@|$PKGUPPER|g" |
97 | echo >>$sedrules "s|@@PKGVER@@|$PKGVER|g" | | 97 | echo >>$sedrules "s|@@PKGVER@@|$PKGVER|g" |
98 | echo >>$sedrules "s|@@PREFIX@@|$PREFIX|g" | | 98 | echo >>$sedrules "s|@@PREFIX@@|$PREFIX|g" |
99 | echo >>$sedrules "s|@@REV@@|$REV|g" | | 99 | echo >>$sedrules "s|@@REV@@|$REV|g" |
100 | | | 100 | |
101 | # | | 101 | # |
102 | # buildlink header | | 102 | # buildlink header |
103 | # | | 103 | # |
104 | sed -f $sedrules <<EOF | | 104 | sed -f $sedrules <<EOF |
105 | # @@ID@@ | | 105 | # @@ID@@ |
106 | # XXX | | 106 | # XXX |
107 | # XXX This file was created automatically using createbuildlink-@PKGVERSION@. | | 107 | # XXX This file was created automatically using createbuildlink-@PKGVERSION@. |
108 | # XXX After this file has been verified as correct, the comment lines | | 108 | # XXX After this file has been verified as correct, the comment lines |
109 | # XXX beginning with "XXX" should be removed. Please do not commit | | 109 | # XXX beginning with "XXX" should be removed. Please do not commit |
110 | # XXX unverified buildlink3.mk files. | | 110 | # XXX unverified buildlink3.mk files. |
111 | # XXX | | | |
112 | # XXX Packages that only install static libraries or headers should | | | |
113 | # XXX include the following line: | | | |
114 | # XXX | | | |
115 | # XXX BUILDLINK_DEPMETHOD.$PKGNOVER?= build | | | |
116 | | | 111 | |
117 | EOF | | 112 | EOF |
118 | | | 113 | |
119 | gap=" " | | 114 | gap=" " |
120 | for i in 1 2 3; do | | 115 | for i in 1 2 3; do |
121 | n=`expr $i \* $spacesintab` | | 116 | n=`expr $i \* $spacesintab` |
122 | if [ ${#PKGUPPER} -ge $n ]; then | | 117 | if [ ${#PKGUPPER} -ge $n ]; then |
123 | gap=" $gap" | | 118 | gap=" $gap" |
124 | fi | | 119 | fi |
125 | done | | 120 | done |
126 | | | 121 | |
127 | sed -f $sedrules <<EOF | | 122 | sed -f $sedrules <<EOF |
128 | BUILDLINK_TREE+= $PKGNOVER | | 123 | BUILDLINK_TREE+= $PKGNOVER |
129 | | | 124 | |
130 | .if !defined(${PKGUPPER}_BUILDLINK3_MK) | | 125 | .if !defined(${PKGUPPER}_BUILDLINK3_MK) |
131 | ${PKGUPPER}_BUILDLINK3_MK:= | | 126 | ${PKGUPPER}_BUILDLINK3_MK:= |
132 | | | 127 | |
| | | 128 | # XXX |
| | | 129 | # XXX Packages that only install static libraries or headers should |
| | | 130 | # XXX include the following line: |
| | | 131 | # XXX |
| | | 132 | # XXX BUILDLINK_DEPMETHOD.$PKGNOVER?= build |
| | | 133 | |
133 | EOF | | 134 | EOF |
134 | | | 135 | |
135 | if [ -n "$GO_PACKAGE" ] | | 136 | if [ -n "$GO_PACKAGE" ] |
136 | then | | 137 | then |
137 | sed -f $sedrules <<EOF | | 138 | sed -f $sedrules <<EOF |
138 | BUILDLINK_CONTENTS_FILTER.$PKGNOVER= \${EGREP} gopkg/ | | 139 | BUILDLINK_CONTENTS_FILTER.$PKGNOVER= \${EGREP} gopkg/ |
139 | BUILDLINK_DEPMETHOD.$PKGNOVER?= build | | 140 | BUILDLINK_DEPMETHOD.$PKGNOVER?= build |
140 | | | 141 | |
141 | EOF | | 142 | EOF |
142 | fi | | 143 | fi |
143 | | | 144 | |
144 | sed -f $sedrules <<EOF | | 145 | sed -f $sedrules <<EOF |
145 | BUILDLINK_API_DEPENDS.$PKGNOVER+= $PKGNOVER>=$PKGVER | | 146 | BUILDLINK_API_DEPENDS.$PKGNOVER+= $PKGNOVER>=$PKGVER |
146 | EOF | | 147 | EOF |
147 | | | 148 | |
148 | sed -f $sedrules <<EOF | | 149 | sed -f $sedrules <<EOF |
149 | BUILDLINK_PKGSRCDIR.$PKGNOVER?= ../../$CURDIR | | 150 | BUILDLINK_PKGSRCDIR.$PKGNOVER?= ../../$CURDIR |
150 | EOF | | 151 | EOF |
151 | | | 152 | |
152 | if [ $CREATEPLSUBST = "true" ]; then | | 153 | if [ $CREATEPLSUBST = "true" ]; then |
153 | echo "" | | 154 | echo "" |
154 | substplistbasedirs | | 155 | substplistbasedirs |
155 | echo "" | | 156 | echo "" |
156 | fi | | 157 | fi |
157 | | | 158 | |
158 | ## | | 159 | ## |
159 | ## buildlinked dependencies | | 160 | ## buildlinked dependencies |
160 | ## | | 161 | ## |
161 | grep -l '^.include.*\.\.\/.*\/.*/buildlink3.mk\"' $makefile $commons \ | | 162 | grep -l '^.include.*\.\.\/.*\/.*/buildlink3.mk\"' $makefile $commons \ |
162 | >/dev/null 2>&1 && cat <<EOF | | 163 | >/dev/null 2>&1 && cat <<EOF |
163 | | | 164 | |
164 | # XXX | | 165 | # XXX |
165 | # XXX Uncomment and keep only the buildlink3 lines below which are directly | | 166 | # XXX Uncomment and keep only the buildlink3 lines below which are directly |
166 | # XXX needed for dependencies to compile, link, and run. If this package | | 167 | # XXX needed for dependencies to compile, link, and run. If this package |
167 | # XXX provides a wrappered API or otherwise does not expose the APIs of the | | 168 | # XXX provides a wrappered API or otherwise does not expose the APIs of the |
168 | # XXX buildlink3 lines below to dependencies, remove them. | | 169 | # XXX buildlink3 lines below to dependencies, remove them. |
169 | # XXX | | 170 | # XXX |
170 | EOF | | 171 | EOF |
171 | for i in $makefile $commons ; do | | 172 | for i in $makefile $commons ; do |
172 | [ ! -f $i ] || grep '^.include.*\.\.\/.*\/.*/buildlink3.mk\"' $i | | | 173 | [ ! -f $i ] || grep '^.include.*\.\.\/.*\/.*/buildlink3.mk\"' $i | |
173 | egrep -v '/devel/pkg-config/|/textproc/intltool/|/graphics/hicolor-icon-theme/' | sed 's,^,#,' | | 174 | egrep -v '/devel/pkg-config/|/textproc/intltool/|/graphics/hicolor-icon-theme/' | sed 's,^,#,' |
174 | done | | 175 | done |
175 | | | 176 | |
176 | sed -f $sedrules <<EOF | | 177 | sed -f $sedrules <<EOF |
177 | .endif # ${PKGUPPER}_BUILDLINK3_MK | | 178 | .endif # ${PKGUPPER}_BUILDLINK3_MK |
178 | | | 179 | |
179 | BUILDLINK_TREE+= -$PKGNOVER | | 180 | BUILDLINK_TREE+= -$PKGNOVER |
180 | EOF | | 181 | EOF |
181 | | | 182 | |
182 | rm -f $sedrules | | 183 | rm -f $sedrules |