xref: /freebsd/usr.sbin/config/config.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
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 <stdlib.h>
39 #include <string.h>
40 
41 struct cfgfile {
42 	STAILQ_ENTRY(cfgfile)	cfg_next;
43 	char	*cfg_path;
44 };
45 STAILQ_HEAD(, cfgfile) cfgfiles;
46 
47 struct file_list {
48 	STAILQ_ENTRY(file_list) f_next;
49 	char	*f_fn;			/* the name */
50 	int     f_type;                 /* type */
51 	u_char	f_flags;		/* see below */
52 	char	*f_compilewith;		/* special make rule if present */
53 	char	*f_depends;		/* additional dependancies */
54 	char	*f_clean;		/* File list to add to clean rule */
55 	char	*f_warn;		/* warning message */
56 };
57 
58 struct files_name {
59 	char *f_name;
60 	STAILQ_ENTRY(files_name) f_next;
61 };
62 
63 /*
64  * Types.
65  */
66 #define NORMAL		1
67 #define	PROFILING	3
68 #define NODEPEND	4
69 #define LOCAL		5
70 #define DEVDONE		0x80000000
71 #define TYPEMASK	0x7fffffff
72 
73 /*
74  * Attributes (flags).
75  */
76 #define NO_IMPLCT_RULE	1
77 #define NO_OBJ		2
78 #define BEFORE_DEPEND	4
79 #define NOWERROR	16
80 
81 struct device {
82 	int	d_done;			/* processed */
83 	char	*d_name;		/* name of device (e.g. rk11) */
84 #define	UNKNOWN -2	/* -2 means not set yet */
85 	STAILQ_ENTRY(device) d_next;	/* Next one in list */
86 };
87 
88 struct config {
89 	char	*s_sysname;
90 };
91 
92 /*
93  * Config has a global notion of which machine type is
94  * being used.  It uses the name of the machine in choosing
95  * files and directories.  Thus if the name of the machine is ``i386'',
96  * it will build from ``Makefile.i386'' and use ``../i386/inline''
97  * in the makerules, etc.  machinearch is the global notion of the
98  * MACHINE_ARCH for this MACHINE.
99  */
100 char	*machinename;
101 char	*machinearch;
102 
103 /*
104  * For each machine, a set of CPU's may be specified as supported.
105  * These and the options (below) are put in the C flags in the makefile.
106  */
107 struct cputype {
108 	char	*cpu_name;
109 	SLIST_ENTRY(cputype) cpu_next;
110 };
111 
112 SLIST_HEAD(, cputype) cputype;
113 
114 /*
115  * A set of options may also be specified which are like CPU types,
116  * but which may also specify values for the options.
117  * A separate set of options may be defined for make-style options.
118  */
119 struct opt {
120 	char	*op_name;
121 	char	*op_value;
122 	int	op_ownfile;	/* true = own file, false = makefile */
123 	SLIST_ENTRY(opt) op_next;
124 };
125 
126 SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts;
127 
128 struct opt_list {
129 	char *o_name;
130 	char *o_file;
131 	SLIST_ENTRY(opt_list) o_next;
132 };
133 
134 SLIST_HEAD(, opt_list) otab;
135 
136 struct hint {
137 	char	*hint_name;
138 	STAILQ_ENTRY(hint) hint_next;
139 };
140 
141 STAILQ_HEAD(hint_head, hint) hints;
142 
143 /*
144  * Tag present in the kernelconf.tmlp template file. It's mandatory for those
145  * two strings to be the same. Otherwise you'll get into trouble.
146  */
147 #define	KERNCONFTAG	"%%KERNCONFFILE%%"
148 
149 /*
150  * Faked option to note, that the configuration file has been taken from the
151  * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we
152  * already have a list of all required devices.
153  */
154 #define OPT_AUTOGEN	"CONFIG_AUTOGENERATED"
155 
156 extern char	*ident;
157 extern char	*env;
158 extern char	kernconfstr[];
159 extern int	do_trace;
160 extern int	envmode;
161 extern int	hintmode;
162 extern int	incignore;
163 
164 char	*get_word(FILE *);
165 char	*get_quoted_word(FILE *);
166 char	*path(const char *);
167 char	*raisestr(char *);
168 void	remember(const char *);
169 void	moveifchanged(const char *, const char *);
170 int	yyparse(void);
171 int	yylex(void);
172 void	options(void);
173 void	makefile(void);
174 void	makeenv(void);
175 void	makehints(void);
176 void	headers(void);
177 void	cfgfile_add(const char *);
178 void	cfgfile_removeall(void);
179 
180 extern STAILQ_HEAD(device_head, device) dtab;
181 
182 extern char	errbuf[80];
183 extern int	yyline;
184 extern const	char *yyfile;
185 
186 extern STAILQ_HEAD(file_list_head, file_list) ftab;
187 
188 extern STAILQ_HEAD(files_name_head, files_name) fntab;
189 
190 extern int	profiling;
191 extern int	debugging;
192 extern int	found_defaults;
193 
194 extern int	maxusers;
195 
196 extern char *PREFIX;		/* Config file name - for error messages */
197 extern char srcdir[];		/* root of the kernel source tree */
198 
199 #define eq(a,b)	(!strcmp(a,b))
200 #define ns(s)	strdup(s)
201