xref: /freebsd/usr.sbin/config/config.h (revision 6b3455a7665208c366849f0b2b3bc916fb97516e)
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  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *	@(#)config.h	8.1 (Berkeley) 6/6/93
34  * $FreeBSD$
35  */
36 
37 /*
38  * Config.
39  */
40 #include <sys/types.h>
41 #include <sys/queue.h>
42 #include <stdlib.h>
43 #include <string.h>
44 
45 struct file_list {
46 	STAILQ_ENTRY(file_list) f_next;
47 	char	*f_fn;			/* the name */
48 	int     f_type;                 /* type or count */
49 	u_char	f_flags;		/* see below */
50 	char	*f_compilewith;		/* special make rule if present */
51 	char	*f_depends;		/* additional dependancies */
52 	char	*f_clean;		/* File list to add to clean rule */
53 	char	*f_needs;
54 	char	*f_warn;		/* warning message */
55 };
56 
57 struct files_name {
58 	char *f_name;
59 	STAILQ_ENTRY(files_name) f_next;
60 };
61 
62 /*
63  * Types.
64  */
65 #define NORMAL		1
66 #define	INVISIBLE	2
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 NEED_COUNT	8
80 #define ISDUP		16
81 #define NOWERROR	32
82 
83 struct device {
84 	int	d_done;			/* processed */
85 	char	*d_name;		/* name of device (e.g. rk11) */
86 	int	d_count;		/* device count */
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.
101  */
102 char	*machinename;
103 
104 /*
105  * For each machine, a set of CPU's may be specified as supported.
106  * These and the options (below) are put in the C flags in the makefile.
107  */
108 struct cputype {
109 	char	*cpu_name;
110 	SLIST_ENTRY(cputype) cpu_next;
111 };
112 
113 SLIST_HEAD(, cputype) cputype;
114 
115 /*
116  * A set of options may also be specified which are like CPU types,
117  * but which may also specify values for the options.
118  * A separate set of options may be defined for make-style options.
119  */
120 struct opt {
121 	char	*op_name;
122 	char	*op_value;
123 	int	op_ownfile;	/* true = own file, false = makefile */
124 	SLIST_ENTRY(opt) op_next;
125 };
126 
127 SLIST_HEAD(opt_head, opt) opt, mkopt;
128 
129 struct opt_list {
130 	char *o_name;
131 	char *o_file;
132 	SLIST_ENTRY(opt_list) o_next;
133 };
134 
135 SLIST_HEAD(, opt_list) otab;
136 
137 extern char	*ident;
138 extern char	*env;
139 extern char	*hints;
140 extern int	do_trace;
141 extern int	envmode;
142 extern int	hintmode;
143 
144 char	*get_word(FILE *);
145 char	*get_quoted_word(FILE *);
146 char	*path(const char *);
147 char	*raisestr(char *);
148 void	remember(const char *);
149 void	moveifchanged(const char *, const char *);
150 int	yyparse(void);
151 int	yylex(void);
152 void	options(void);
153 void	makefile(void);
154 void	headers(void);
155 
156 extern STAILQ_HEAD(device_head, device) dtab;
157 
158 extern char	errbuf[80];
159 extern int	yyline;
160 extern const	char *yyfile;
161 
162 extern STAILQ_HEAD(file_list_head, file_list) ftab;
163 
164 extern STAILQ_HEAD(files_name_head, files_name) fntab;
165 
166 extern int	profiling;
167 extern int	debugging;
168 
169 extern int	maxusers;
170 
171 extern char *PREFIX;		/* Config file name - for error messages */
172 extern char srcdir[];		/* root of the kernel source tree */
173 
174 #define eq(a,b)	(!strcmp(a,b))
175 #define ns(s)	strdup(s)
176