1*10d63b7dSRichard Lowe /* 2*10d63b7dSRichard Lowe * CDDL HEADER START 3*10d63b7dSRichard Lowe * 4*10d63b7dSRichard Lowe * The contents of this file are subject to the terms of the 5*10d63b7dSRichard Lowe * Common Development and Distribution License (the "License"). 6*10d63b7dSRichard Lowe * You may not use this file except in compliance with the License. 7*10d63b7dSRichard Lowe * 8*10d63b7dSRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*10d63b7dSRichard Lowe * or http://www.opensolaris.org/os/licensing. 10*10d63b7dSRichard Lowe * See the License for the specific language governing permissions 11*10d63b7dSRichard Lowe * and limitations under the License. 12*10d63b7dSRichard Lowe * 13*10d63b7dSRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each 14*10d63b7dSRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*10d63b7dSRichard Lowe * If applicable, add the following below this CDDL HEADER, with the 16*10d63b7dSRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying 17*10d63b7dSRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner] 18*10d63b7dSRichard Lowe * 19*10d63b7dSRichard Lowe * CDDL HEADER END 20*10d63b7dSRichard Lowe */ 21*10d63b7dSRichard Lowe /* 22*10d63b7dSRichard Lowe * Copyright 1995 Sun Microsystems, Inc. All rights reserved. 23*10d63b7dSRichard Lowe * Use is subject to license terms. 24*10d63b7dSRichard Lowe */ 25*10d63b7dSRichard Lowe 26*10d63b7dSRichard Lowe /* 27*10d63b7dSRichard Lowe * Included files 28*10d63b7dSRichard Lowe */ 29*10d63b7dSRichard Lowe #include <libintl.h> 30*10d63b7dSRichard Lowe 31*10d63b7dSRichard Lowe #include <mk/defs.h> 32*10d63b7dSRichard Lowe #include <mksh/misc.h> /* getmem() */ 33*10d63b7dSRichard Lowe 34*10d63b7dSRichard Lowe /* 35*10d63b7dSRichard Lowe * This file deals with "Dependency Variables". 36*10d63b7dSRichard Lowe * The "-V var" command line option is used to indicate 37*10d63b7dSRichard Lowe * that var is a dependency variable. Used in conjunction with 38*10d63b7dSRichard Lowe * the -P option the user is asking if the named variables affect 39*10d63b7dSRichard Lowe * the dependencies of the given target. 40*10d63b7dSRichard Lowe */ 41*10d63b7dSRichard Lowe 42*10d63b7dSRichard Lowe struct _Depvar { 43*10d63b7dSRichard Lowe Name name; /* Name of variable */ 44*10d63b7dSRichard Lowe struct _Depvar *next; /* Linked list */ 45*10d63b7dSRichard Lowe Boolean cmdline; /* Macro defined on the cmdline? */ 46*10d63b7dSRichard Lowe }; 47*10d63b7dSRichard Lowe 48*10d63b7dSRichard Lowe typedef struct _Depvar *Depvar; 49*10d63b7dSRichard Lowe 50*10d63b7dSRichard Lowe static Depvar depvar_list; 51*10d63b7dSRichard Lowe static Depvar *bpatch = &depvar_list; 52*10d63b7dSRichard Lowe static Boolean variant_deps; 53*10d63b7dSRichard Lowe 54*10d63b7dSRichard Lowe /* 55*10d63b7dSRichard Lowe * Add a name to the list. 56*10d63b7dSRichard Lowe */ 57*10d63b7dSRichard Lowe 58*10d63b7dSRichard Lowe void depvar_add_to_list(Name name,Boolean cmdline)59*10d63b7dSRichard Lowedepvar_add_to_list(Name name, Boolean cmdline) 60*10d63b7dSRichard Lowe { 61*10d63b7dSRichard Lowe Depvar dv; 62*10d63b7dSRichard Lowe 63*10d63b7dSRichard Lowe dv = ALLOC(Depvar); 64*10d63b7dSRichard Lowe dv->name = name; 65*10d63b7dSRichard Lowe dv->next = NULL; 66*10d63b7dSRichard Lowe dv->cmdline = cmdline; 67*10d63b7dSRichard Lowe *bpatch = dv; 68*10d63b7dSRichard Lowe bpatch = &dv->next; 69*10d63b7dSRichard Lowe } 70*10d63b7dSRichard Lowe 71*10d63b7dSRichard Lowe /* 72*10d63b7dSRichard Lowe * The macro `name' has been used in either the left-hand or 73*10d63b7dSRichard Lowe * right-hand side of a dependency. See if it is in the 74*10d63b7dSRichard Lowe * list. Two things are looked for. Names given as args 75*10d63b7dSRichard Lowe * to the -V list are checked so as to set the same/differ 76*10d63b7dSRichard Lowe * output for the -P option. Names given as macro=value 77*10d63b7dSRichard Lowe * command-line args are checked and, if found, an NSE 78*10d63b7dSRichard Lowe * warning is produced. 79*10d63b7dSRichard Lowe */ 80*10d63b7dSRichard Lowe void depvar_dep_macro_used(Name name)81*10d63b7dSRichard Lowedepvar_dep_macro_used(Name name) 82*10d63b7dSRichard Lowe { 83*10d63b7dSRichard Lowe Depvar dv; 84*10d63b7dSRichard Lowe 85*10d63b7dSRichard Lowe for (dv = depvar_list; dv != NULL; dv = dv->next) { 86*10d63b7dSRichard Lowe if (name == dv->name) { 87*10d63b7dSRichard Lowe variant_deps = true; 88*10d63b7dSRichard Lowe break; 89*10d63b7dSRichard Lowe } 90*10d63b7dSRichard Lowe } 91*10d63b7dSRichard Lowe } 92*10d63b7dSRichard Lowe 93*10d63b7dSRichard Lowe 94*10d63b7dSRichard Lowe /* 95*10d63b7dSRichard Lowe * Print the results. If any of the Dependency Variables 96*10d63b7dSRichard Lowe * affected the dependencies then the dependencies potentially 97*10d63b7dSRichard Lowe * differ because of these variables. 98*10d63b7dSRichard Lowe */ 99*10d63b7dSRichard Lowe void depvar_print_results(void)100*10d63b7dSRichard Lowedepvar_print_results(void) 101*10d63b7dSRichard Lowe { 102*10d63b7dSRichard Lowe if (variant_deps) { 103*10d63b7dSRichard Lowe printf(gettext("differ\n")); 104*10d63b7dSRichard Lowe } else { 105*10d63b7dSRichard Lowe printf(gettext("same\n")); 106*10d63b7dSRichard Lowe } 107*10d63b7dSRichard Lowe } 108*10d63b7dSRichard Lowe 109