source: trunk/minix/commands/make/h.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 8.6 KB
RevLine 
[9]1/*************************************************************************
2 *
3 * m a k e : h . h
4 *
5 * include file for make
6 *========================================================================
7 * Edition history
8 *
9 * # Date Comments By
10 * --- -------- ---------------------------------------------------- ---
11 * 1 ?? ??
12 * 2 23.08.89 LZ increased,N_EXISTS added,suffix as macro added RAL
13 * 3 30.08.89 macro flags added, indention changed PSH,RAL
14 * 4 03.09.89 fixed LZ eliminated, struct str added,... RAL
15 * 5 06.09.89 TABCHAR,M_MAKE added RAL
16 * 6 09.09.89 tos support added, EXTERN,INIT,PARMS added PHH,RAL
17 * 7 17.09.89 __STDC__ added, make1 decl. fixed , N_EXEC added RAL
18 * ------------ Version 2.0 released ------------------------------- RAL
19 *
20 *************************************************************************/
21
22#ifdef unix
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <errno.h>
26#include <stdlib.h>
27#include <string.h>
28#include <time.h>
29#include <utime.h>
30#include <stdio.h>
31#include <limits.h>
32#endif
33
34#ifdef eon
35#include <sys/stat.h>
36#include <sys/err.h>
37#endif
38
39#ifdef os9
40#include <time.h>
41#include <os9.h>
42#include <modes.h>
43#include <direct.h>
44#include <errno.h>
45#endif
46
47#ifdef tos
48struct DOSTIME {short time,date; }; /* time structure of TOS */
49
50#ifdef LATTICE
51#include <error.h>
52#include <sys/types.h>
53#include <sys/stat.h>
54#include <osbind.h>
55#endif /* LATTICE */
56
57#ifdef TURBO
58#include <tos.h>
59#include <errno.h>
60#include <string.h>
61#endif /* TURBO */
62
63#endif /* tos */
64
65#include <ctype.h>
66#include <stdio.h>
67#include <assert.h>
68
69#ifdef eon
70#define MNOENT ER_NOTF
71#else
72#define MNOENT ENOENT
73#endif
74
75#ifndef uchar
76#ifdef os9
77#define uchar char
78#define void int
79#define fputc putc
80#else
81#define uchar unsigned char
82#endif
83#endif
84
85#define bool uchar
86#ifndef time_t
87#define time_t long
88#endif
89#define TRUE (1)
90#define FALSE (0)
91#define max(a,b) ((a)>(b)?(a):(b))
92
93#ifdef unix
94#define DEFN1 "makefile"
95#define DEFN2 "Makefile"
96#endif
97#ifdef eon
98#define DEFN1 "makefile"
99#define DEFN2 "Makefile"
100#endif
101#ifdef tos
102#define DEFN1 "makefile."
103#define DEFN2 (char *)0
104#endif
105#ifdef os9
106#define DEFN1 "makefile"
107#define DEFN2 (char *)0
108#endif
109
110
111#ifdef os9
112#define TABCHAR ' '
113#else
114#define TABCHAR '\t'
115#endif
116
117#define LZ1 (2048) /* Initial input/expand string size */
118#define LZ2 (256) /* Initial input/expand string size */
119
120
121
122/*
123 * A name. This represents a file, either to be made, or existant
124 */
125
126struct name
127{
128 struct name *n_next; /* Next in the list of names */
129 char *n_name; /* Called */
130 struct line *n_line; /* Dependencies */
131 time_t n_time; /* Modify time of this name */
132 uchar n_flag; /* Info about the name */
133};
134
135#define N_MARK 0x01 /* For cycle check */
136#define N_DONE 0x02 /* Name looked at */
137#define N_TARG 0x04 /* Name is a target */
138#define N_PREC 0x08 /* Target is precious */
139#define N_DOUBLE 0x10 /* Double colon target */
140#define N_EXISTS 0x20 /* File exists */
141#define N_ERROR 0x40 /* Error occured */
142#define N_EXEC 0x80 /* Commands executed */
143
144/*
145 * Definition of a target line.
146 */
147struct line
148{
149 struct line *l_next; /* Next line (for ::) */
150 struct depend *l_dep; /* Dependents for this line */
151 struct cmd *l_cmd; /* Commands for this line */
152};
153
154
155/*
156 * List of dependents for a line
157 */
158struct depend
159{
160 struct depend *d_next; /* Next dependent */
161 struct name *d_name; /* Name of dependent */
162};
163
164
165/*
166 * Commands for a line
167 */
168struct cmd
169{
170 struct cmd *c_next; /* Next command line */
171 char *c_cmd; /* Command line */
172};
173
174
175/*
176 * Macro storage
177 */
178struct macro
179{
180 struct macro *m_next; /* Next variable */
181 char *m_name; /* Called ... */
182 char *m_val; /* Its value */
183 uchar m_flag; /* Infinite loop check */
184};
185
186
187#define M_MARK 0x01 /* for infinite loop check */
188#define M_OVERRIDE 0x02 /* command-line override */
189#define M_MAKE 0x04 /* for MAKE macro */
190
191/*
192 * String
193 */
194struct str
195{
196 char **ptr; /* ptr to real ptr. to string */
197 int len; /* length of string */
198 int pos; /* position */
199};
200
201
202/* Declaration, definition & initialization of variables */
203
204#ifndef EXTERN
205#define EXTERN extern
206#endif
207
208#ifndef INIT
209#define INIT(x)
210#endif
211
212extern int errno;
213extern char **environ;
214
215EXTERN char *myname;
216EXTERN bool domake INIT(TRUE); /* Go through the motions option */
217EXTERN bool ignore INIT(FALSE); /* Ignore exit status option */
218EXTERN bool conterr INIT(FALSE); /* continue on errors */
219EXTERN bool silent INIT(FALSE); /* Silent option */
220EXTERN bool print INIT(FALSE); /* Print debuging information */
221EXTERN bool rules INIT(TRUE); /* Use inbuilt rules */
222EXTERN bool dotouch INIT(FALSE); /* Touch files instead of making */
223EXTERN bool quest INIT(FALSE); /* Question up-to-dateness of file */
224EXTERN bool useenv INIT(FALSE); /* Env. macro def. overwrite makefile def.*/
225EXTERN bool dbginfo INIT(FALSE); /* Print lot of debugging information */
226EXTERN bool ambigmac INIT(TRUE); /* guess undef. ambiguous macros (*,<) */
227EXTERN struct name *firstname;
228EXTERN char *str1;
229EXTERN char *str2;
230EXTERN struct str str1s;
231EXTERN struct str str2s;
232EXTERN struct name **suffparray; /* ptr. to array of ptrs. to name chains */
233EXTERN int sizesuffarray INIT(20); /* size of suffarray */
234EXTERN int maxsuffarray INIT(0); /* last used entry in suffarray */
235EXTERN struct macro *macrohead;
236EXTERN bool expmake; /* TRUE if $(MAKE) has been expanded */
237EXTERN char *makefile; /* The make file */
238EXTERN int lineno;
239
240#ifdef tos
241#ifdef LATTICE
242EXTERN int _mneed INIT(60000); /* VERY important for TOS with LATTICE C*/
243#endif /* LATTICE */
244#endif /* tos */
245#ifdef eon
246#define MEMSPACE (16384)
247EXTERN unsigned memspace = MEMSPACE;
248#endif
249
250#define suffix(name) strrchr(name,(int)'.')
251
252EXTERN int _ctypech;
253#define mylower(x) (islower(_ctypech=(x)) ? _ctypech :tolower(_ctypech))
254#define myupper(x) (isupper(_ctypech=(x)) ? _ctypech :toupper(_ctypech))
255
256/* Prototypes. */
257struct sgtbuf;
258
259/* check.c */
260_PROTOTYPE(void prt, (void));
261_PROTOTYPE(void check, (struct name *np ));
262_PROTOTYPE(void circh, (void));
263_PROTOTYPE(void precious, (void));
264
265/* input.c */
266_PROTOTYPE(void init, (void));
267_PROTOTYPE(void strrealloc, (struct str *strs ));
268_PROTOTYPE(struct name *newname, (char *name ));
269_PROTOTYPE(struct name *testname, (char *name ));
270_PROTOTYPE(struct depend *newdep, (struct name *np, struct depend *dp ));
271_PROTOTYPE(struct cmd *newcmd, (char *str, struct cmd *cp ));
272_PROTOTYPE(void newline, (struct name *np, struct depend *dp, struct cmd *cp,
273 int flag ));
274_PROTOTYPE(void input, (FILE *fd ));
275
276/* macro.c */
277_PROTOTYPE(struct macro *getmp, (char *name ));
278_PROTOTYPE(char *getmacro, (char *name ));
279_PROTOTYPE(struct macro *setmacro, (char *name, char *val ));
280_PROTOTYPE(void setDFmacro, (char *name, char *val ));
281_PROTOTYPE(void doexp, (struct str *to, char *from ));
282_PROTOTYPE(void expand, (struct str *strs ));
283
284/* main.c */
285_PROTOTYPE(void main, (int argc, char **argv ));
286_PROTOTYPE(void setoption, (char option ));
287_PROTOTYPE(void usage, (void));
288_PROTOTYPE(void fatal, (char *msg, char *a1, int a2 ));
289
290/* make.c */
291_PROTOTYPE(int dosh, (char *string, char *shell ));
292_PROTOTYPE(int makeold, (char *name ));
293_PROTOTYPE(void docmds1, (struct name *np, struct line *lp ));
294_PROTOTYPE(void docmds, (struct name *np ));
295_PROTOTYPE(int Tosexec, (char *string ));
296_PROTOTYPE(time_t mstonix, (unsigned int date, unsigned int time ));
297_PROTOTYPE(void getmdate, (int fd, struct sgtbuf *tbp ));
298_PROTOTYPE(time_t cnvtime, (struct sgtbuf *tbp ));
299_PROTOTYPE(void modtime, (struct name *np ));
300_PROTOTYPE(void touch, (struct name *np ));
301_PROTOTYPE(int make, (struct name *np, int level ));
302_PROTOTYPE(void make1, (struct name *np, struct line *lp, struct depend *qdp,
303 char *basename, char *inputname ));
304_PROTOTYPE(void implmacros, (struct name *np, struct line *lp,
305 char **pbasename, char **pinputname ));
306_PROTOTYPE(void dbgprint, (int level, struct name *np, char *comment ));
307
308/* reader.c */
309_PROTOTYPE(void error, (char *msg, char *a1 ));
310_PROTOTYPE(bool getline, (struct str *strs, FILE *fd ));
311_PROTOTYPE(char *gettok, (char **ptr ));
312
313/* rules.c */
314_PROTOTYPE(bool dyndep, (struct name *np, char **pbasename,char **pinputname));
315_PROTOTYPE(void makerules, (void));
316
317/* archive.c */
318_PROTOTYPE(int is_archive_ref, (char *name));
319_PROTOTYPE(int archive_stat, (char *name, struct stat *stp));
Note: See TracBrowser for help on using the repository browser.