VirtualBox

source: kBuild/branches/GNU/src/gmake/variable.h@ 54

Last change on this file since 54 was 54, checked in by (none), 21 years ago

This commit was manufactured by cvs2svn to create branch 'GNU'.

  • Property svn:eol-style set to native
File size: 8.5 KB
Line 
1/* Definitions for using variables in GNU Make.
2Copyright (C) 1988, 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
3This file is part of GNU Make.
4
5GNU Make is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2, or (at your option)
8any later version.
9
10GNU Make is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with GNU Make; see the file COPYING. If not, write to
17the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18Boston, MA 02111-1307, USA. */
19
20#include "hash.h"
21
22/* Codes in a variable definition saying where the definition came from.
23 Increasing numeric values signify less-overridable definitions. */
24enum variable_origin
25 {
26 o_default, /* Variable from the default set. */
27 o_env, /* Variable from environment. */
28 o_file, /* Variable given in a makefile. */
29 o_env_override, /* Variable from environment, if -e. */
30 o_command, /* Variable given by user. */
31 o_override, /* Variable from an `override' directive. */
32 o_automatic, /* Automatic variable -- cannot be set. */
33 o_invalid /* Core dump time. */
34 };
35
36enum variable_flavor
37 {
38 f_bogus, /* Bogus (error) */
39 f_simple, /* Simple definition (:=) */
40 f_recursive, /* Recursive definition (=) */
41 f_append, /* Appending definition (+=) */
42 f_conditional /* Conditional definition (?=) */
43 };
44
45/* Structure that represents one variable definition.
46 Each bucket of the hash table is a chain of these,
47 chained through `next'. */
48
49#define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */
50#define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1)
51
52struct variable
53 {
54 char *name; /* Variable name. */
55 int length; /* strlen (name) */
56 char *value; /* Variable value. */
57 struct floc fileinfo; /* Where the variable was defined. */
58 unsigned int recursive:1; /* Gets recursively re-evaluated. */
59 unsigned int append:1; /* Nonzero if an appending target-specific
60 variable. */
61 unsigned int conditional:1; /* Nonzero if set with a ?=. */
62 unsigned int per_target:1; /* Nonzero if a target-specific variable. */
63 unsigned int special:1; /* Nonzero if this is a special variable. */
64 unsigned int exportable:1; /* Nonzero if the variable _could_ be
65 exported. */
66 unsigned int expanding:1; /* Nonzero if currently being expanded. */
67 unsigned int exp_count:EXP_COUNT_BITS;
68 /* If >1, allow this many self-referential
69 expansions. */
70 enum variable_flavor
71 flavor ENUM_BITFIELD (3); /* Variable flavor. */
72 enum variable_origin
73 origin ENUM_BITFIELD (3); /* Variable origin. */
74 enum variable_export
75 {
76 v_export, /* Export this variable. */
77 v_noexport, /* Don't export this variable. */
78 v_ifset, /* Export it if it has a non-default value. */
79 v_default /* Decide in target_environment. */
80 } export ENUM_BITFIELD (2);
81 };
82
83/* Structure that represents a variable set. */
84
85struct variable_set
86 {
87 struct hash_table table; /* Hash table of variables. */
88 };
89
90/* Structure that represents a list of variable sets. */
91
92struct variable_set_list
93 {
94 struct variable_set_list *next; /* Link in the chain. */
95 struct variable_set *set; /* Variable set. */
96 };
97
98/* Structure used for pattern-specific variables. */
99
100struct pattern_var
101 {
102 struct pattern_var *next;
103 char *target;
104 unsigned int len;
105 char *suffix;
106 struct variable variable;
107 };
108
109extern char *variable_buffer;
110extern struct variable_set_list *current_variable_set_list;
111
112/* expand.c */
113extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
114extern char *variable_expand PARAMS ((char *line));
115extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
116#define allocated_variable_expand(line) \
117 allocated_variable_expand_for_file (line, (struct file *) 0)
118extern char *expand_argument PARAMS ((const char *str, const char *end));
119extern char *variable_expand_string PARAMS ((char *line, char *string,
120 long length));
121extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp));
122extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len));
123
124/* function.c */
125extern int handle_function PARAMS ((char **op, char **stringp));
126extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
127extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace,
128 unsigned int slen, unsigned int rlen, int by_word, int suffix_only));
129extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
130 char *pattern_percent, char *replace_percent));
131
132/* expand.c */
133extern char *recursively_expand_for_file PARAMS ((struct variable *v,
134 struct file *file));
135#define recursively_expand(v) recursively_expand_for_file (v, NULL)
136
137/* variable.c */
138extern struct variable_set_list *create_new_variable_set PARAMS ((void));
139extern struct variable_set_list *push_new_variable_scope PARAMS ((void));
140extern void pop_variable_scope PARAMS ((void));
141extern void define_automatic_variables PARAMS ((void));
142extern void initialize_file_variables PARAMS ((struct file *file, int read));
143extern void print_file_variables PARAMS ((struct file *file));
144extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix));
145extern void merge_variable_set_lists PARAMS ((struct variable_set_list **to_list, struct variable_set_list *from_list));
146extern struct variable *do_variable_definition PARAMS ((const struct floc *flocp, const char *name, char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var));
147extern struct variable *parse_variable_definition PARAMS ((struct variable *v, char *line));
148extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var));
149extern void init_hash_global_variable_set PARAMS ((void));
150extern void hash_init_function_table PARAMS ((void));
151extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length));
152extern struct variable *lookup_variable_in_set PARAMS ((const char *name,
153 unsigned int length,
154 const struct variable_set *set));
155
156extern struct variable *define_variable_in_set
157 PARAMS ((const char *name, unsigned int length, char *value,
158 enum variable_origin origin, int recursive,
159 struct variable_set *set, const struct floc *flocp));
160
161/* Define a variable in the current variable set. */
162
163#define define_variable(n,l,v,o,r) \
164 define_variable_in_set((n),(l),(v),(o),(r),\
165 current_variable_set_list->set,NILF)
166
167/* Define a variable with a location in the current variable set. */
168
169#define define_variable_loc(n,l,v,o,r,f) \
170 define_variable_in_set((n),(l),(v),(o),(r),\
171 current_variable_set_list->set,(f))
172
173/* Define a variable with a location in the global variable set. */
174
175#define define_variable_global(n,l,v,o,r,f) \
176 define_variable_in_set((n),(l),(v),(o),(r),NULL,(f))
177
178/* Define a variable in FILE's variable set. */
179
180#define define_variable_for_file(n,l,v,o,r,f) \
181 define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF)
182
183/* Warn that NAME is an undefined variable. */
184
185#define warn_undefined(n,l) do{\
186 if (warn_undefined_variables_flag) \
187 error (reading_file, \
188 _("warning: undefined variable `%.*s'"), \
189 (int)(l), (n)); \
190 }while(0)
191
192extern char **target_environment PARAMS ((struct file *file));
193
194extern struct pattern_var *create_pattern_var PARAMS ((char *target, char *suffix));
195
196extern int export_all_variables;
197
198#define MAKELEVEL_NAME "MAKELEVEL"
199#define MAKELEVEL_LENGTH (sizeof (MAKELEVEL_NAME) - 1)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette