Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / plist / plist-libtool.awk
blob7f7e2fa057969438229feb3fcec22f026d510691
1 # $NetBSD: plist-libtool.awk,v 1.4 2006/04/15 04:25:17 minskim Exp $
3 # Copyright (c) 2006 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by Johnny C. Lam.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. All advertising materials mentioning features or use of this software
18 # must display the following acknowledgement:
19 # This product includes software developed by the NetBSD
20 # Foundation, Inc. and its contributors.
21 # 4. Neither the name of The NetBSD Foundation nor the names of its
22 # contributors may be used to endorse or promote products derived
23 # from this software without specific prior written permission.
25 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 # POSSIBILITY OF SUCH DAMAGE.
37 ### This awk script handles libtool archive entries in PLISTs. This script
38 ### requires the following scripts to be included:
39 ###
40 ### plist-functions.awk (print_entry)
41 ###
42 ### Certain environment variables must be set prior to running this script:
43 ###
44 ### IGNORE_LIBTOOLIZE is a whitespace-separated list of ${PREFIX}-relative
45 ### paths to *.la files that should not be expanded.
46 ###
47 ### LIBTOOL_EXPAND is the path to the script that prints out the
48 ### actual library files associated with a libtool archive file.
49 ###
50 ### LIBTOOLIZE_PLIST is a yes/no variable indicating whether to expand
51 ### *.la files in the PLIST into the corresponding real libraries.
52 ###
53 ### PREFIX is the installation prefix of the package.
54 ###
55 ### TEST is the command used for shell tests, e.g. shell test built-in or
56 ### the path to a "test" binary.
57 ###
59 BEGIN {
60 LIBTOOL_EXPAND = ENVIRON["LIBTOOL_EXPAND"] ? ENVIRON["LIBTOOL_EXPAND"] : "/usr/pkgsrc/mk/plist/libtool-expand"
61 LIBTOOLIZE_PLIST = ENVIRON["LIBTOOLIZE_PLIST"] ? ENVIRON["LIBTOOLIZE_PLIST"] : "yes"
62 PREFIX = ENVIRON["PREFIX"] ? ENVIRON["PREFIX"] : "/usr/pkg"
63 TEST = ENVIRON["TEST"] ? ENVIRON["TEST"] : "test"
65 IGNORE_LA_REGEXP = ENVIRON["IGNORE_LIBTOOLIZE"] ? ENVIRON["IGNORE_LIBTOOLIZE"] : ""
66 if (IGNORE_LA_REGEXP != "") {
67 gsub(" *", "|", IGNORE_LA_REGEXP)
68 IGNORE_LA_REGEXP = "(" IGNORE_LA_REGEXP ")"
72 ###
73 ### Expand libtool archives into the list of corresponding shared and/or
74 ### static libraries.
75 ###
76 (LIBTOOLIZE_PLIST ~ /[yY][eE][sS]/) && \
77 /^[^@]/ && ($0 !~ "^" IGNORE_LA_REGEXP "$") && /\.la$/ {
78 print_entry($0)
79 cmd = TEST " -f " PREFIX "/" $0
80 if (system(cmd) == 0) {
81 cmd = "cd " PREFIX " && " LIBTOOL_EXPAND " " $0
82 while (cmd | getline) {
83 print_entry($0)
85 close(cmd)
87 next