* New config.sub and config.guess
[make.git] / variable.h
blobd449ef82d97c7fbc8d4af060051d8983886bff44
1 /* Definitions for using variables in GNU Make.
2 Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* Codes in a variable definition saying where the definition came from.
21 Increasing numeric values signify less-overridable definitions. */
22 enum variable_origin
24 o_default, /* Variable from the default set. */
25 o_env, /* Variable from environment. */
26 o_file, /* Variable given in a makefile. */
27 o_env_override, /* Variable from environment, if -e. */
28 o_command, /* Variable given by user. */
29 o_override, /* Variable from an `override' directive. */
30 o_automatic, /* Automatic variable -- cannot be set. */
31 o_invalid /* Core dump time. */
34 /* Structure that represents one variable definition.
35 Each bucket of the hash table is a chain of these,
36 chained through `next'. */
38 struct variable
40 struct variable *next; /* Link in the chain. */
41 char *name; /* Variable name. */
42 char *value; /* Variable value. */
43 struct floc fileinfo; /* Where the variable was defined. */
44 enum variable_origin
45 origin ENUM_BITFIELD (3); /* Variable origin. */
46 unsigned int recursive:1; /* Gets recursively re-evaluated. */
47 unsigned int expanding:1; /* Nonzero if currently being expanded. */
48 unsigned int per_target:1; /* Nonzero if a target-specific variable. */
49 unsigned int append:1; /* Nonzero if an appending target-specific
50 variable. */
51 enum variable_export
53 v_export, /* Export this variable. */
54 v_noexport, /* Don't export this variable. */
55 v_ifset, /* Export it if it has a non-default value. */
56 v_default /* Decide in target_environment. */
57 } export ENUM_BITFIELD (2);
60 /* Structure that represents a variable set. */
62 struct variable_set
64 struct variable **table; /* Hash table of variables. */
65 unsigned int buckets; /* Number of hash buckets in `table'. */
68 /* Structure that represents a list of variable sets. */
70 struct variable_set_list
72 struct variable_set_list *next; /* Link in the chain. */
73 struct variable_set *set; /* Variable set. */
76 extern char *variable_buffer;
77 extern struct variable_set_list *current_variable_set_list;
79 /* expand.c */
80 extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
81 extern char *variable_expand PARAMS ((char *line));
82 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
83 #define allocated_variable_expand(line) \
84 allocated_variable_expand_for_file (line, (struct file *) 0)
85 extern char *expand_argument PARAMS ((char *str, char *end));
86 extern char *variable_expand_string PARAMS ((char *line, char *string,
87 long length));
89 /* function.c */
90 extern int handle_function PARAMS ((char **op, char **stringp));
91 extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
92 extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace,
93 unsigned int slen, unsigned int rlen, int by_word, int suffix_only));
94 extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
95 char *pattern_percent, char *replace_percent));
97 /* expand.c */
98 extern char *recursively_expand PARAMS ((struct variable *v));
100 /* variable.c */
101 extern struct variable_set_list *create_new_variable_set PARAMS ((void));
102 extern struct variable_set_list *push_new_variable_scope PARAMS ((void));
103 extern void pop_variable_scope PARAMS ((void));
104 extern void define_automatic_variables PARAMS ((void));
105 extern void initialize_file_variables PARAMS ((struct file *file, int read));
106 extern void print_file_variables PARAMS ((struct file *file));
107 extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix));
108 extern void merge_variable_set_lists PARAMS ((struct variable_set_list **setlist0, struct variable_set_list *setlist1));
109 extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var));
111 extern struct variable *lookup_variable PARAMS ((char *name, unsigned int length));
113 extern struct variable *define_variable_in_set
114 PARAMS ((char *name, unsigned int length, char *value,
115 enum variable_origin origin, int recursive,
116 struct variable_set *set, const struct floc *flocp));
118 /* Define a variable in the current variable set. */
120 #define define_variable(n,l,v,o,r) \
121 define_variable_in_set((n),(l),(v),(o),(r),\
122 current_variable_set_list->set,NILF)
124 /* Define a variable with a location in the current variable set. */
126 #define define_variable_loc(n,l,v,o,r,f) \
127 define_variable_in_set((n),(l),(v),(o),(r),\
128 current_variable_set_list->set,(f))
130 /* Define a variable in FILE's variable set. */
132 #define define_variable_for_file(n,l,v,o,r,f) \
133 define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF)
135 extern char **target_environment PARAMS ((struct file *file));
137 extern int export_all_variables;