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 41struct cfgfile { 42 STAILQ_ENTRY(cfgfile) cfg_next; 43 char *cfg_path; 44}; 45STAILQ_HEAD(, cfgfile) cfgfiles; 46 47struct 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 dependencies */ 54 char *f_clean; /* File list to add to clean rule */ 55 char *f_warn; /* warning message */ 56 const char *f_objprefix; /* prefix string for object name */ 57}; 58 59struct files_name { 60 char *f_name; 61 STAILQ_ENTRY(files_name) f_next; 62}; 63 64/* 65 * Types. 66 */ 67#define NORMAL 1 68#define PROFILING 3 69#define NODEPEND 4 70#define LOCAL 5 71#define DEVDONE 0x80000000 72#define TYPEMASK 0x7fffffff 73 74/* 75 * Attributes (flags). 76 */ 77#define NO_IMPLCT_RULE 1 78#define NO_OBJ 2 79#define BEFORE_DEPEND 4 80#define NOWERROR 16 81 82struct device { 83 int d_done; /* processed */ 84 char *d_name; /* name of device (e.g. rk11) */ 85#define UNKNOWN -2 /* -2 means not set yet */ 86 STAILQ_ENTRY(device) d_next; /* Next one in list */ 87}; 88 89struct config { 90 char *s_sysname; 91}; 92 93/* 94 * Config has a global notion of which machine type is 95 * being used. It uses the name of the machine in choosing 96 * files and directories. Thus if the name of the machine is ``i386'', 97 * it will build from ``Makefile.i386'' and use ``../i386/inline'' 98 * in the makerules, etc. machinearch is the global notion of the 99 * MACHINE_ARCH for this MACHINE. 100 */ 101char *machinename; 102char *machinearch; 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 */ 108struct cputype { 109 char *cpu_name; 110 SLIST_ENTRY(cputype) cpu_next; 111}; 112 113SLIST_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 */ 120struct 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 SLIST_ENTRY(opt) op_append; 126}; 127 128SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts; 129 130struct opt_list { 131 char *o_name; 132 char *o_file; 133 int o_flags; 134#define OL_ALIAS 1 135 SLIST_ENTRY(opt_list) o_next; 136}; 137 138SLIST_HEAD(, opt_list) otab; 139 140struct hint { 141 char *hint_name; 142 STAILQ_ENTRY(hint) hint_next; 143}; 144 145STAILQ_HEAD(hint_head, hint) hints; 146 147struct includepath { 148 char *path; 149 SLIST_ENTRY(includepath) path_next; 150}; 151 152SLIST_HEAD(, includepath) includepath; 153 154/* 155 * Tag present in the kernelconf.tmlp template file. It's mandatory for those 156 * two strings to be the same. Otherwise you'll get into trouble. 157 */ 158#define KERNCONFTAG "%%KERNCONFFILE%%" 159 160/* 161 * Faked option to note, that the configuration file has been taken from the 162 * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we 163 * already have a list of all required devices. 164 */ 165#define OPT_AUTOGEN "CONFIG_AUTOGENERATED" 166 167extern char *ident; 168extern char *env; 169extern char kernconfstr[]; 170extern int do_trace; 171extern int envmode; 172extern int hintmode; 173extern int incignore; 174 175char *get_word(FILE *); 176char *get_quoted_word(FILE *); 177char *path(const char *); 178char *raisestr(char *); 179void remember(const char *); 180void moveifchanged(const char *, const char *); 181int yylex(void); 182void options(void); 183void makefile(void); 184void makeenv(void); 185void makehints(void); 186void headers(void); 187void cfgfile_add(const char *); 188void cfgfile_removeall(void); 189FILE *open_makefile_template(void); 190 191extern STAILQ_HEAD(device_head, device) dtab; 192 193extern char errbuf[80]; 194extern int yyline; 195extern const char *yyfile; 196 197extern STAILQ_HEAD(file_list_head, file_list) ftab; 198 199extern STAILQ_HEAD(files_name_head, files_name) fntab; 200 201extern int profiling; 202extern int debugging; 203extern int found_defaults; 204 205extern int maxusers; 206 207extern char *PREFIX; /* Config file name - for error messages */ 208extern char srcdir[]; /* root of the kernel source tree */ 209 210#define eq(a,b) (!strcmp(a,b)) 211#define ns(s) strdup(s) 212