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