1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1984-2012 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 /*
22  * Glenn Fowler
23  * AT&T Research
24  *
25  * make option attributes and flag mappings
26  *
27  * omitted letters are avilable for option flags:
28  *
29  *	abcdefghijklmnopqrstuvwxyz
30  *      --------------------------
31  *	ABCDEFGHIJK MNOPQRSTUV X
32  *	abcdefg ijkl no  rst vwx z
33  */
34 
35 #define OPT(o)		(o&((1<<9)-1))	/* get opt char from code	*/
36 #define Of		(1<<8)		/* cannot be set by flag	*/
37 
38 #define Oa		(1<<9)		/* multiple string values added	*/
39 #define Ob		(1<<10)		/* boolean value		*/
40 #define Oi		(1<<11)		/* state.* sense inverted	*/
41 #define Om		(1<<13)		/* internal option		*/
42 #define On		(1<<14)		/* numeric value		*/
43 #define Oo		(1<<15)		/* flag sense opposite		*/
44 #define Op		(1L<<19)	/* .mo probe prerequisite	*/
45 #define Os		(1L<<16)	/* string value			*/
46 #define Ov		(1L<<17)	/* value is optional		*/
47 #define Ox		(1L<<18)	/* not expanded in $(-)		*/
48 
49 #define OPT_COMPILE	(1L<<26)	/* compile into object		*/
50 #define OPT_DECLARE	(1L<<27)	/* compile declaration		*/
51 #define OPT_DEFAULT	(1L<<28)	/* := default value		*/
52 #define OPT_EXTERNAL	(1L<<29)	/* external by name		*/
53 #define OPT_READONLY	(1L<<30)	/* cannot reset til state.user	*/
54 #define OPT_SET		(1L<<31)	/* explicitly set		*/
55 
56 #define OPT_accept	('A'|Ob)	/* accept existing targets	*/
57 #define OPT_alias	('a'|Ob)	/* directory aliasing enabled	*/
58 #define OPT_base	('b'|Ob|Ox)	/* compile base|global rules	*/
59 #define OPT_believe	('B'|On)	/* believe state from this level*/
60 #define OPT_byname	('o'|Oa|Os|Ox)	/* command line option by name	*/
61 #define OPT_compile	('c'|Ob|Ox)	/* force makefile compilation	*/
62 #define OPT_compatibility ('C'|Ob|Ox)	/* disable compatibility msgs	*/
63 #define OPT_corrupt	('X'|Os|Ov)	/* corrupt statefile action	*/
64 #define OPT_cross	('J'|Ob)	/* don't run gen'd executables	*/
65 #define OPT_debug	('d'|Oi|On)	/* debug trace level		*/
66 #define OPT_define	('D'|Op|Os|Ox)	/* passed to preprocessor	*/
67 #define OPT_errorid	('E'|Os)	/* append to error output id	*/
68 #define OPT_exec	('n'|Ob|Oo)	/* execute shell actions	*/
69 #define OPT_expandview	('x'|Ob)	/* expand paths if fsview!=0	*/
70 #define OPT_explain	('e'|Ob)	/* explain actions		*/
71 #define OPT_file	('f'|Oa|Os|Ox)	/* next arg is makefile		*/
72 #define OPT_force	('F'|Ob)	/* force targets to be updated	*/
73 #define OPT_global	('g'|Oa|Os|Ov)	/* next arg is global makefile	*/
74 #define OPT_ignore	('i'|Ob)	/* ignore shell action errors	*/
75 #define OPT_ignorelock	('K'|Ob)	/* ignore state file locking	*/
76 #define OPT_include	('I'|Os|Ox)	/* passed to preprocessor	*/
77 #define OPT_intermediate ('G'|Ob)	/* force intermediate targets	*/
78 #define OPT_jobs	('j'|On)	/* job concurrency level	*/
79 #define OPT_keepgoing	('k'|Ob)	/* do sibling prereqs on error	*/
80 #define OPT_list	('l'|Ob|Ox)	/* list info and don't make	*/
81 #define OPT_mam		('M'|Os)	/* generate mam			*/
82 #define OPT_never	('N'|Ob)	/* really - don't exec anything	*/
83 #define OPT_option	(101|Oa|Of|Os|Ox)/* define new option by name	*/
84 #define OPT_override	(102|Ob|Of|Ox)	/* override selected algorithms	*/
85 #define OPT_preprocess	('P'|Ob)	/* preprocess all makefiles	*/
86 #define OPT_questionable ('Q'|On)	/* enable questionable code	*/
87 #define OPT_readonly	('R'|Ob)	/* current vars|opts readonly	*/
88 #define OPT_readstate	('S'|On|Ov)	/* read state file on startup	*/
89 #define OPT_regress	('q'|Os|Ov)	/* output for regression test	*/
90 #define OPT_reread	(103|Ob|Of|Ox)	/* force re-read all makefiles	*/
91 #define OPT_ruledump	('r'|Ob|Ox)	/* dump rule definitions	*/
92 #define OPT_scan	(104|Ob|Of)	/* scan|check implicit prereqs	*/
93 #define OPT_serialize	('O'|Ob)	/* serialize concurrent output	*/
94 #define OPT_silent	('s'|Ob)	/* run silently			*/
95 #define OPT_strictview	('V'|Ob)	/* strict views			*/
96 #define OPT_targetcontext (105|Ob|Of)	/* expand in target dir context	*/
97 #define OPT_targetprefix (106|Os|Of)	/* source dir target prefix sep	*/
98 #define OPT_test	('T'|On)	/* enable test code		*/
99 #define OPT_tolerance	('z'|On)	/* time comparison tolerance	*/
100 #define OPT_touch	('t'|Ob)	/* touch out of date targets	*/
101 #define OPT_undef	('U'|Op|Os|Ox)	/* passed to preprocessor	*/
102 #define OPT_vardump	('v'|Ob|Ox)	/* dump variable definitions	*/
103 #define OPT_warn	('w'|Ob)	/* enable source file warnings	*/
104 #define OPT_writeobject	(107|Of|Os|Ov|Ox)/* write recompiled object	*/
105 #define OPT_writestate	(108|Of|Os|Ov|Ox)/* write state file on exit	*/
106 
107 struct Option_s; typedef struct Option_s Option_t;
108 
109 struct Option_s				/* option table entry		*/
110 {
111 	char*		name;		/* option name			*/
112 	unsigned long	flags;		/* O[a-z] and OPT_[A-Z]+ flags	*/
113 	char*		value;		/* overloaded value		*/
114 	char*		set;		/* call this on set		*/
115 	char*		description;	/* description			*/
116 	char*		arg;		/* arg name			*/
117 	Option_t*	next;		/* external option list link	*/
118 };
119 
120 extern Option_t*	optflag(int);
121 extern void		optcheck(int);
122 extern void		optinit(void);
123