Install newest German translation.
[make/kirr.git] / variable.h
blob8d4853f2a5caa732066eca0314fd3780b3f06e2e
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 #define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */
40 #define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1)
42 struct variable
44 struct variable *next; /* Link in the chain. */
45 char *name; /* Variable name. */
46 char *value; /* Variable value. */
47 struct floc fileinfo; /* Where the variable was defined. */
48 unsigned int recursive:1; /* Gets recursively re-evaluated. */
49 unsigned int expanding:1; /* Nonzero if currently being expanded. */
50 unsigned int exp_count:EXP_COUNT_BITS;
51 /* If >1, allow this many self-referential
52 expansions */
53 unsigned int per_target:1; /* Nonzero if a target-specific variable. */
54 unsigned int append:1; /* Nonzero if an appending target-specific
55 variable. */
57 enum variable_origin
58 origin ENUM_BITFIELD (3); /* Variable origin. */
60 enum variable_export
62 v_export, /* Export this variable. */
63 v_noexport, /* Don't export this variable. */
64 v_ifset, /* Export it if it has a non-default value. */
65 v_default /* Decide in target_environment. */
66 } export ENUM_BITFIELD (2);
69 /* Structure that represents a variable set. */
71 struct variable_set
73 struct variable **table; /* Hash table of variables. */
74 unsigned int buckets; /* Number of hash buckets in `table'. */
77 /* Structure that represents a list of variable sets. */
79 struct variable_set_list
81 struct variable_set_list *next; /* Link in the chain. */
82 struct variable_set *set; /* Variable set. */
85 extern char *variable_buffer;
86 extern struct variable_set_list *current_variable_set_list;
88 /* expand.c */
89 extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
90 extern char *variable_expand PARAMS ((char *line));
91 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
92 #define allocated_variable_expand(line) \
93 allocated_variable_expand_for_file (line, (struct file *) 0)
94 extern char *expand_argument PARAMS ((char *str, char *end));
95 extern char *variable_expand_string PARAMS ((char *line, char *string,
96 long length));
98 /* function.c */
99 extern int handle_function PARAMS ((char **op, char **stringp));
100 extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
101 extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace,
102 unsigned int slen, unsigned int rlen, int by_word, int suffix_only));
103 extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
104 char *pattern_percent, char *replace_percent));
106 /* expand.c */
107 extern char *recursively_expand_for_file PARAMS ((struct variable *v,
108 struct file *file));
109 #define recursively_expand(v) recursively_expand_for_file (v, NULL)
111 /* variable.c */
112 extern struct variable_set_list *create_new_variable_set PARAMS ((void));
113 extern struct variable_set_list *push_new_variable_scope PARAMS ((void));
114 extern void pop_variable_scope PARAMS ((void));
115 extern void define_automatic_variables PARAMS ((void));
116 extern void initialize_file_variables PARAMS ((struct file *file, int read));
117 extern void print_file_variables PARAMS ((struct file *file));
118 extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix));
119 extern void merge_variable_set_lists PARAMS ((struct variable_set_list **setlist0, struct variable_set_list *setlist1));
120 extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var));
122 extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length));
123 extern struct variable *lookup_variable_in_set PARAMS ((const char *name,
124 unsigned int length,
125 const struct variable_set *set));
127 extern struct variable *define_variable_in_set
128 PARAMS ((char *name, unsigned int length, char *value,
129 enum variable_origin origin, int recursive,
130 struct variable_set *set, const struct floc *flocp));
132 /* Define a variable in the current variable set. */
134 #define define_variable(n,l,v,o,r) \
135 define_variable_in_set((n),(l),(v),(o),(r),\
136 current_variable_set_list->set,NILF)
138 /* Define a variable with a location in the current variable set. */
140 #define define_variable_loc(n,l,v,o,r,f) \
141 define_variable_in_set((n),(l),(v),(o),(r),\
142 current_variable_set_list->set,(f))
144 /* Define a variable in FILE's variable set. */
146 #define define_variable_for_file(n,l,v,o,r,f) \
147 define_variable_in_set((n),(l),(v),(o),(r),(f)->variables->set,NILF)
149 /* Warn that NAME is an undefined variable. */
151 #define warn_undefined(n,l) do{\
152 if (warn_undefined_variables_flag) \
153 error (reading_file, \
154 _("warning: undefined variable `%.*s'"), \
155 (int)(l), (n)); \
156 }while(0)
158 extern char **target_environment PARAMS ((struct file *file));
160 extern int export_all_variables;