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$ 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 */ 534571Sgibbs char *f_depends; /* additional dependancies */ 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 147169507Swkoszek/* 148169507Swkoszek * Tag present in the kernelconf.tmlp template file. It's mandatory for those 149169507Swkoszek * two strings to be the same. Otherwise you'll get into trouble. 150169507Swkoszek */ 151169507Swkoszek#define KERNCONFTAG "%%KERNCONFFILE%%" 152169507Swkoszek 153169507Swkoszek/* 154169507Swkoszek * Faked option to note, that the configuration file has been taken from the 155169507Swkoszek * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we 156169507Swkoszek * already have a list of all required devices. 157169507Swkoszek */ 158169507Swkoszek#define OPT_AUTOGEN "CONFIG_AUTOGENERATED" 159169507Swkoszek 16045744Speterextern char *ident; 16182393Speterextern char *env; 162169507Swkoszekextern char kernconfstr[]; 16345744Speterextern int do_trace; 16482393Speterextern int envmode; 16565091Speterextern int hintmode; 166169507Swkoszekextern int incignore; 16745744Speter 16861640Speterchar *get_word(FILE *); 16961640Speterchar *get_quoted_word(FILE *); 17072684Speterchar *path(const char *); 17161640Speterchar *raisestr(char *); 17272684Spetervoid remember(const char *); 17361640Spetervoid moveifchanged(const char *, const char *); 17461640Speterint yylex(void); 17561640Spetervoid options(void); 17661640Spetervoid makefile(void); 177153888Sruvoid makeenv(void); 178153888Sruvoid makehints(void); 17961640Spetervoid headers(void); 180169507Swkoszekvoid cfgfile_add(const char *); 181169507Swkoszekvoid cfgfile_removeall(void); 182207260SimpFILE *open_makefile_template(void); 1831553Srgrimes 184169647Simpextern STAILQ_HEAD(device_head, device) dtab; 1851553Srgrimes 18645744Speterextern char errbuf[80]; 18745744Speterextern int yyline; 18879607Sddextern const char *yyfile; 1891553Srgrimes 190110895Sruextern STAILQ_HEAD(file_list_head, file_list) ftab; 1911553Srgrimes 192129073Scognetextern STAILQ_HEAD(files_name_head, files_name) fntab; 193129073Scognet 19445744Speterextern int profiling; 19545744Speterextern int debugging; 196151744Sjhbextern int found_defaults; 1971553Srgrimes 19845744Speterextern int maxusers; 1991553Srgrimes 20033598Seivindextern char *PREFIX; /* Config file name - for error messages */ 20152653Smarcelextern char srcdir[]; /* root of the kernel source tree */ 20233538Seivind 2031553Srgrimes#define eq(a,b) (!strcmp(a,b)) 20452098Speter#define ns(s) strdup(s) 205