4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/param.h>
36 #pragma init(ld_support_init)
38 #define SUNPRO_DEPENDENCIES "SUNPRO_DEPENDENCIES"
41 * Linked list of strings - used to keep lists of names
42 * of directories or files.
49 typedef struct Stritem Stritem
;
51 static char *depend_file
= NULL
;
52 static Stritem
*list
= NULL
;
57 depend_file
= getenv(SUNPRO_DEPENDENCIES
);
61 prepend_str(Stritem
**list
, const char *str
)
65 const char *lib
= "libldmake.so";
67 if (!(new = calloc(1, sizeof (Stritem
)))) {
72 if (!(newstr
= malloc(strlen(str
) + 1))) {
77 new->str
= strcpy(newstr
, str
);
85 ld_file(const char *file
, const Elf_Kind ekind
, int flags
, Elf
*elf
)
88 * SUNPRO_DEPENDENCIES wasn't set, we don't collect .make.state
94 if ((flags
& LD_SUP_DERIVED
) && !(flags
& LD_SUP_EXTRACTED
))
95 prepend_str(&list
, file
);
99 ld_file64(const char *file
, const Elf_Kind ekind
, int flags
, Elf
*elf
)
101 ld_file(file
, ekind
, flags
, elf
);
105 ld_atexit(int exit_code
)
108 char lockfile
[MAXPATHLEN
], *err
, *space
, *target
;
110 extern char *file_lock(char *, char *, int);
112 if (!depend_file
|| exit_code
)
115 if ((space
= strchr(depend_file
, ' ')) == NULL
)
120 (void) snprintf(lockfile
, MAXPATHLEN
, "%s.lock", depend_file
);
121 if ((err
= file_lock(depend_file
, lockfile
, 0))) {
122 (void) fprintf(stderr
, "%s\n", err
);
126 if (!(ofp
= fopen(depend_file
, "a")))
130 (void) fprintf(ofp
, "%s: ", target
);
132 for (cur
= list
; cur
; cur
= cur
->next
)
133 (void) fprintf(ofp
, " %s", cur
->str
);
135 (void) fputc('\n', ofp
);
138 (void) unlink(lockfile
);
143 ld_atexit64(int exit_code
)
145 ld_atexit(exit_code
);