]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/config/config.h
Merge branch 'releng/11.3' into releng-CDN/11.3
[FreeBSD/FreeBSD.git] / usr.sbin / config / config.h
1 /*
2  * Copyright (c) 1980, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      @(#)config.h    8.1 (Berkeley) 6/6/93
30  * $FreeBSD$
31  */
32
33 /*
34  * Config.
35  */
36 #include <sys/types.h>
37 #include <sys/queue.h>
38 #include <stdbool.h>
39 #include <stdlib.h>
40 #include <string.h>
41
42 struct cfgfile {
43         STAILQ_ENTRY(cfgfile)   cfg_next;
44         char    *cfg_path;
45 };
46 STAILQ_HEAD(, cfgfile) cfgfiles;
47
48 struct file_list {
49         STAILQ_ENTRY(file_list) f_next;
50         char    *f_fn;                  /* the name */
51         int     f_type;                 /* type */
52         u_char  f_flags;                /* see below */
53         char    *f_compilewith;         /* special make rule if present */
54         char    *f_depends;             /* additional dependencies */
55         char    *f_clean;               /* File list to add to clean rule */
56         char    *f_warn;                /* warning message */
57         const char *f_objprefix;        /* prefix string for object name */
58         const char *f_srcprefix;        /* source prefix such as $S/ */
59 };
60
61 struct files_name {
62         char *f_name;
63         STAILQ_ENTRY(files_name) f_next;
64 };
65
66 /*
67  * Types.
68  */
69 #define NORMAL          1
70 #define PROFILING       3
71 #define NODEPEND        4
72 #define LOCAL           5
73 #define DEVDONE         0x80000000
74 #define TYPEMASK        0x7fffffff
75
76 /*
77  * Attributes (flags).
78  */
79 #define NO_IMPLCT_RULE  1
80 #define NO_OBJ          2
81 #define BEFORE_DEPEND   4
82 #define NOWERROR        16
83
84 struct device {
85         int     d_done;                 /* processed */
86         char    *d_name;                /* name of device (e.g. rk11) */
87 #define UNKNOWN -2      /* -2 means not set yet */
88         STAILQ_ENTRY(device) d_next;    /* Next one in list */
89 };
90
91 struct config {
92         char    *s_sysname;
93 };
94
95 /*
96  * Config has a global notion of which machine type is
97  * being used.  It uses the name of the machine in choosing
98  * files and directories.  Thus if the name of the machine is ``i386'',
99  * it will build from ``Makefile.i386'' and use ``../i386/inline''
100  * in the makerules, etc.  machinearch is the global notion of the
101  * MACHINE_ARCH for this MACHINE.
102  */
103 char    *machinename;
104 char    *machinearch;
105
106 /*
107  * For each machine, a set of CPU's may be specified as supported.
108  * These and the options (below) are put in the C flags in the makefile.
109  */
110 struct cputype {
111         char    *cpu_name;
112         SLIST_ENTRY(cputype) cpu_next;
113 };
114
115 SLIST_HEAD(, cputype) cputype;
116
117 /*
118  * A set of options may also be specified which are like CPU types,
119  * but which may also specify values for the options.
120  * A separate set of options may be defined for make-style options.
121  */
122 struct opt {
123         char    *op_name;
124         char    *op_value;
125         int     op_ownfile;     /* true = own file, false = makefile */
126         SLIST_ENTRY(opt) op_next;
127         SLIST_ENTRY(opt) op_append;
128 };
129
130 SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts;
131
132 struct opt_list {
133         char *o_name;
134         char *o_file;
135         int o_flags;
136 #define OL_ALIAS        1
137         SLIST_ENTRY(opt_list) o_next;
138 };
139
140 SLIST_HEAD(, opt_list) otab;
141
142 struct envvar {
143         char    *env_str;
144         bool    env_is_file;
145         STAILQ_ENTRY(envvar) envvar_next;
146 };
147
148 STAILQ_HEAD(envvar_head, envvar) envvars;
149
150 struct hint {
151         char    *hint_name;
152         STAILQ_ENTRY(hint) hint_next;
153 };
154
155 STAILQ_HEAD(hint_head, hint) hints;
156
157 struct includepath {
158         char    *path;
159         SLIST_ENTRY(includepath) path_next;
160 };
161
162 SLIST_HEAD(, includepath) includepath;
163
164 /*
165  * Tag present in the kernconf.tmpl template file. It's mandatory for those
166  * two strings to be the same. Otherwise you'll get into trouble.
167  */
168 #define KERNCONFTAG     "%%KERNCONFFILE%%"
169
170 /*
171  * Faked option to note, that the configuration file has been taken from the
172  * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we
173  * already have a list of all required devices.
174  */
175 #define OPT_AUTOGEN     "CONFIG_AUTOGENERATED"
176
177 extern char     *ident;
178 extern char     kernconfstr[];
179 extern int      do_trace;
180 extern int      incignore;
181
182 char    *get_word(FILE *);
183 char    *get_quoted_word(FILE *);
184 char    *path(const char *);
185 char    *raisestr(char *);
186 void    remember(const char *);
187 void    moveifchanged(const char *, const char *);
188 int     yylex(void);
189 void    options(void);
190 void    makefile(void);
191 void    makeenv(void);
192 void    makehints(void);
193 void    headers(void);
194 void    cfgfile_add(const char *);
195 void    cfgfile_removeall(void);
196 FILE    *open_makefile_template(void);
197
198 extern STAILQ_HEAD(device_head, device) dtab;
199
200 extern char     errbuf[80];
201 extern int      yyline;
202 extern const    char *yyfile;
203
204 extern STAILQ_HEAD(file_list_head, file_list) ftab;
205
206 extern STAILQ_HEAD(files_name_head, files_name) fntab;
207
208 extern int      profiling;
209 extern int      debugging;
210 extern int      found_defaults;
211
212 extern int      maxusers;
213 extern int      versreq;
214
215 extern char *PREFIX;            /* Config file name - for error messages */
216 extern char srcdir[];           /* root of the kernel source tree */
217
218 #define eq(a,b) (!strcmp(a,b))
219 #define ns(s)   strdup(s)