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