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