10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER START
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The contents of this file are subject to the terms of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Common Development and Distribution License (the "License").
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You may not use this file except in compliance with the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See the License for the specific language governing permissions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and limitations under the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER END
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Use is subject to license terms.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This file handles the .nse_depinfo file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Recursive_make *bpatch = &recursive_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_recursive_init()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read the .nse_depinfo file and make a list of all the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * .RECURSIVE entries.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * bpatch Points to slot where next cell should be added
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursive_name The Name ".RECURSIVE", compared against
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This routine can be called more than once, don't do
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * anything after the first time.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(nse_depinfo, "%s/%s", search_dir, NSE_DEPINFO);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (fgetws(&line[line_index], line_size, fp) == NULL)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe colon = (wchar_t *) wcschr(line, (int) colon_char);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dollar = (wchar_t *) wcschr(line, (int) dollar_char);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this entry is an old entry, ignore it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe !IS_WEQUALN(wcs_buffer, (dollar+1) - VER_LEN, VER_LEN)){
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * set conditional_macro_string if string is present
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * get target name into recursive struct
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_recursive_dep(target, line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Report a target as recursive.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line Dependency line reported
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * bpatch Points to slot where next cell should be added
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * changed Written if report set changed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowereport_recursive_dep(Name target, wchar_t *line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * find an applicable recursive entry, if there isn't one, create it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe wchar_t * wcb = get_wstring(target->string_mb); // XXX Tolik: needs retmem
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rp->cond_macrostring = (wchar_t *) wcsdup(rec_buf);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((rp->oldline != NULL) && !IS_WEQUAL(rp->oldline, line)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * find_recursive_target(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Search the list for a given target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The target cell
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * top_level_target more info used to determinde the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursive_list The list of targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp = recursive_list; rp != NULL; rp = rp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this entry has already been removed, ignore it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this target, and the target on the list are the same
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and if one of them contains conditional macro info, while
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the other doesn't, remove this entry from the list of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursive entries. This can only happen if the Makefile
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * has changed to no longer contain conditional macros.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (rp->cond_macrostring[VER_LEN] != '\0' &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this is not a VERS2 entry, only need to match
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the target name. toptarg information from VERS1 entries
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * are ignored.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (IS_WEQUALN(wcs_buffer, string.buffer.start, VER_LEN)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * remove_recursive_dep(target, top_level_target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Mark a target as no longer recursive.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target we want to remove
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * top_level_target target we want to remove must be built from
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the same top level target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * changed Written if report set changed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* gather_recursive_deps()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Create or update list of recursive targets.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Go thru all targets and dump recursive dependencies */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (np = hashtab.begin(), e = hashtab.end(); np != e; np++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * start .RECURSIVE line with target:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (lines = get_prop(np->prop,recursive_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe lines = get_prop(lines->next, recursive_prop)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * if entry is already in depinfo
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file or entry was not built, ignore it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Write the remainder of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * .RECURSIVE line
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Complete list of makefiles used */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dump list of conditional targets,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and report recursive entry, if needed