11553Srgrimes/*
21553Srgrimes * Copyright (c) 1980, 1993
31553Srgrimes *	The Regents of the University of California.  All rights reserved.
41553Srgrimes *
51553Srgrimes * Redistribution and use in source and binary forms, with or without
61553Srgrimes * modification, are permitted provided that the following conditions
71553Srgrimes * are met:
81553Srgrimes * 1. Redistributions of source code must retain the above copyright
91553Srgrimes *    notice, this list of conditions and the following disclaimer.
101553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111553Srgrimes *    notice, this list of conditions and the following disclaimer in the
121553Srgrimes *    documentation and/or other materials provided with the distribution.
131553Srgrimes * 4. Neither the name of the University nor the names of its contributors
141553Srgrimes *    may be used to endorse or promote products derived from this software
151553Srgrimes *    without specific prior written permission.
161553Srgrimes *
171553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201553Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271553Srgrimes * SUCH DAMAGE.
281553Srgrimes *
291553Srgrimes *	@(#)config.h	8.1 (Berkeley) 6/6/93
3052098Speter * $FreeBSD: releng/10.3/usr.sbin/config/config.h 293290 2016-01-07 00:40:51Z bdrewery $
311553Srgrimes */
321553Srgrimes
331553Srgrimes/*
341553Srgrimes * Config.
351553Srgrimes */
361553Srgrimes#include <sys/types.h>
37110895Sru#include <sys/queue.h>
381553Srgrimes#include <stdlib.h>
391553Srgrimes#include <string.h>
401553Srgrimes
41169507Swkoszekstruct cfgfile {
42169507Swkoszek	STAILQ_ENTRY(cfgfile)	cfg_next;
43169507Swkoszek	char	*cfg_path;
44169507Swkoszek};
45169507SwkoszekSTAILQ_HEAD(, cfgfile) cfgfiles;
46169507Swkoszek
471553Srgrimesstruct file_list {
48110895Sru	STAILQ_ENTRY(file_list) f_next;
491553Srgrimes	char	*f_fn;			/* the name */
50134542Speter	int     f_type;                 /* type */
511553Srgrimes	u_char	f_flags;		/* see below */
5273199Speter	char	*f_compilewith;		/* special make rule if present */
53293290Sbdrewery	char	*f_depends;		/* additional dependencies */
546803Sgibbs	char	*f_clean;		/* File list to add to clean rule */
5554490Speter	char	*f_warn;		/* warning message */
56219819Sjeff	const char *f_objprefix;	/* prefix string for object name */
571553Srgrimes};
581553Srgrimes
59129073Scognetstruct files_name {
60129073Scognet	char *f_name;
61129073Scognet	STAILQ_ENTRY(files_name) f_next;
62129073Scognet};
63129073Scognet
641553Srgrimes/*
651553Srgrimes * Types.
661553Srgrimes */
6748525Speter#define NORMAL		1
6848525Speter#define	PROFILING	3
6948525Speter#define NODEPEND	4
7048525Speter#define LOCAL		5
7130796Sjoerg#define DEVDONE		0x80000000
7230796Sjoerg#define TYPEMASK	0x7fffffff
731553Srgrimes
741553Srgrimes/*
751553Srgrimes * Attributes (flags).
761553Srgrimes */
7773204Speter#define NO_IMPLCT_RULE	1
7873204Speter#define NO_OBJ		2
7973204Speter#define BEFORE_DEPEND	4
80134542Speter#define NOWERROR	16
811553Srgrimes
821553Srgrimesstruct device {
8371879Speter	int	d_done;			/* processed */
841553Srgrimes	char	*d_name;		/* name of device (e.g. rk11) */
851553Srgrimes#define	UNKNOWN -2	/* -2 means not set yet */
86110895Sru	STAILQ_ENTRY(device) d_next;	/* Next one in list */
871553Srgrimes};
881553Srgrimes
891553Srgrimesstruct config {
901553Srgrimes	char	*s_sysname;
911553Srgrimes};
921553Srgrimes
931553Srgrimes/*
941553Srgrimes * Config has a global notion of which machine type is
951553Srgrimes * being used.  It uses the name of the machine in choosing
9645775Speter * files and directories.  Thus if the name of the machine is ``i386'',
9745775Speter * it will build from ``Makefile.i386'' and use ``../i386/inline''
98144509Simp * in the makerules, etc.  machinearch is the global notion of the
99144509Simp * MACHINE_ARCH for this MACHINE.
1001553Srgrimes */
1011553Srgrimeschar	*machinename;
102144509Simpchar	*machinearch;
1031553Srgrimes
1041553Srgrimes/*
1051553Srgrimes * For each machine, a set of CPU's may be specified as supported.
1061553Srgrimes * These and the options (below) are put in the C flags in the makefile.
1071553Srgrimes */
1081553Srgrimesstruct cputype {
1091553Srgrimes	char	*cpu_name;
110110895Sru	SLIST_ENTRY(cputype) cpu_next;
111110895Sru};
1121553Srgrimes
113110895SruSLIST_HEAD(, cputype) cputype;
114110895Sru
1151553Srgrimes/*
1161553Srgrimes * A set of options may also be specified which are like CPU types,
1171553Srgrimes * but which may also specify values for the options.
1181553Srgrimes * A separate set of options may be defined for make-style options.
1191553Srgrimes */
1201553Srgrimesstruct opt {
1211553Srgrimes	char	*op_name;
1221553Srgrimes	char	*op_value;
12312772Speter	int	op_ownfile;	/* true = own file, false = makefile */
124110895Sru	SLIST_ENTRY(opt) op_next;
125185186Sthompsa	SLIST_ENTRY(opt) op_append;
126110895Sru};
1271553Srgrimes
128169507SwkoszekSLIST_HEAD(opt_head, opt) opt, mkopt, rmopts;
129110895Sru
13012772Speterstruct opt_list {
13112772Speter	char *o_name;
13212772Speter	char *o_file;
133206664Simp	int o_flags;
134206664Simp#define OL_ALIAS	1
135110895Sru	SLIST_ENTRY(opt_list) o_next;
136110895Sru};
13712772Speter
138110895SruSLIST_HEAD(, opt_list) otab;
139110895Sru
140163638Simpstruct hint {
141163638Simp	char	*hint_name;
142163638Simp	STAILQ_ENTRY(hint) hint_next;
143163638Simp};
144163638Simp
145163638SimpSTAILQ_HEAD(hint_head, hint) hints;
146163638Simp
147264325Sasomersstruct includepath {
148264325Sasomers	char	*path;
149264325Sasomers	SLIST_ENTRY(includepath) path_next;
150264325Sasomers};
151264325Sasomers
152264325SasomersSLIST_HEAD(, includepath) includepath;
153264325Sasomers
154169507Swkoszek/*
155169507Swkoszek * Tag present in the kernelconf.tmlp template file. It's mandatory for those
156169507Swkoszek * two strings to be the same. Otherwise you'll get into trouble.
157169507Swkoszek */
158169507Swkoszek#define	KERNCONFTAG	"%%KERNCONFFILE%%"
159169507Swkoszek
160169507Swkoszek/*
161169507Swkoszek * Faked option to note, that the configuration file has been taken from the
162169507Swkoszek * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we
163169507Swkoszek * already have a list of all required devices.
164169507Swkoszek */
165169507Swkoszek#define OPT_AUTOGEN	"CONFIG_AUTOGENERATED"
166169507Swkoszek
16745744Speterextern char	*ident;
16882393Speterextern char	*env;
169169507Swkoszekextern char	kernconfstr[];
17045744Speterextern int	do_trace;
17182393Speterextern int	envmode;
17265091Speterextern int	hintmode;
173169507Swkoszekextern int	incignore;
17445744Speter
17561640Speterchar	*get_word(FILE *);
17661640Speterchar	*get_quoted_word(FILE *);
17772684Speterchar	*path(const char *);
17861640Speterchar	*raisestr(char *);
17972684Spetervoid	remember(const char *);
18061640Spetervoid	moveifchanged(const char *, const char *);
18161640Speterint	yylex(void);
18261640Spetervoid	options(void);
18361640Spetervoid	makefile(void);
184153888Sruvoid	makeenv(void);
185153888Sruvoid	makehints(void);
18661640Spetervoid	headers(void);
187169507Swkoszekvoid	cfgfile_add(const char *);
188169507Swkoszekvoid	cfgfile_removeall(void);
189207260SimpFILE	*open_makefile_template(void);
1901553Srgrimes
191169647Simpextern STAILQ_HEAD(device_head, device) dtab;
1921553Srgrimes
19345744Speterextern char	errbuf[80];
19445744Speterextern int	yyline;
19579607Sddextern const	char *yyfile;
1961553Srgrimes
197110895Sruextern STAILQ_HEAD(file_list_head, file_list) ftab;
1981553Srgrimes
199129073Scognetextern STAILQ_HEAD(files_name_head, files_name) fntab;
200129073Scognet
20145744Speterextern int	profiling;
20245744Speterextern int	debugging;
203151744Sjhbextern int	found_defaults;
2041553Srgrimes
20545744Speterextern int	maxusers;
2061553Srgrimes
20733598Seivindextern char *PREFIX;		/* Config file name - for error messages */
20852653Smarcelextern char srcdir[];		/* root of the kernel source tree */
20933538Seivind
2101553Srgrimes#define eq(a,b)	(!strcmp(a,b))
21152098Speter#define ns(s)	strdup(s)
212