00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef unix
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #include <errno.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <time.h>
00029 #include <utime.h>
00030 #include <stdio.h>
00031 #include <limits.h>
00032 #endif
00033
00034 #ifdef eon
00035 #include <sys/stat.h>
00036 #include <sys/err.h>
00037 #endif
00038
00039 #ifdef os9
00040 #include <time.h>
00041 #include <os9.h>
00042 #include <modes.h>
00043 #include <direct.h>
00044 #include <errno.h>
00045 #endif
00046
00047 #ifdef tos
00048 struct DOSTIME {short time,date; };
00049
00050 #ifdef LATTICE
00051 #include <error.h>
00052 #include <sys/types.h>
00053 #include <sys/stat.h>
00054 #include <osbind.h>
00055 #endif
00056
00057 #ifdef TURBO
00058 #include <tos.h>
00059 #include <errno.h>
00060 #include <string.h>
00061 #endif
00062
00063 #endif
00064
00065 #include <ctype.h>
00066 #include <stdio.h>
00067 #include <assert.h>
00068
00069 #ifdef eon
00070 #define MNOENT ER_NOTF
00071 #else
00072 #define MNOENT ENOENT
00073 #endif
00074
00075 #ifndef uchar
00076 #ifdef os9
00077 #define uchar char
00078 #define void int
00079 #define fputc putc
00080 #else
00081 #define uchar unsigned char
00082 #endif
00083 #endif
00084
00085 #define bool uchar
00086 #ifndef time_t
00087 #define time_t long
00088 #endif
00089 #define TRUE (1)
00090 #define FALSE (0)
00091 #define max(a,b) ((a)>(b)?(a):(b))
00092
00093 #ifdef unix
00094 #define DEFN1 "makefile"
00095 #define DEFN2 "Makefile"
00096 #endif
00097 #ifdef eon
00098 #define DEFN1 "makefile"
00099 #define DEFN2 "Makefile"
00100 #endif
00101 #ifdef tos
00102 #define DEFN1 "makefile."
00103 #define DEFN2 (char *)0
00104 #endif
00105 #ifdef os9
00106 #define DEFN1 "makefile"
00107 #define DEFN2 (char *)0
00108 #endif
00109
00110
00111 #ifdef os9
00112 #define TABCHAR ' '
00113 #else
00114 #define TABCHAR '\t'
00115 #endif
00116
00117 #define LZ1 (2048)
00118 #define LZ2 (256)
00119
00120
00121
00122
00123
00124
00125
00126 struct name
00127 {
00128 struct name *n_next;
00129 char *n_name;
00130 struct line *n_line;
00131 time_t n_time;
00132 uchar n_flag;
00133 };
00134
00135 #define N_MARK 0x01
00136 #define N_DONE 0x02
00137 #define N_TARG 0x04
00138 #define N_PREC 0x08
00139 #define N_DOUBLE 0x10
00140 #define N_EXISTS 0x20
00141 #define N_ERROR 0x40
00142 #define N_EXEC 0x80
00143
00144
00145
00146
00147 struct line
00148 {
00149 struct line *l_next;
00150 struct depend *l_dep;
00151 struct cmd *l_cmd;
00152 };
00153
00154
00155
00156
00157
00158 struct depend
00159 {
00160 struct depend *d_next;
00161 struct name *d_name;
00162 };
00163
00164
00165
00166
00167
00168 struct cmd
00169 {
00170 struct cmd *c_next;
00171 char *c_cmd;
00172 };
00173
00174
00175
00176
00177
00178 struct macro
00179 {
00180 struct macro *m_next;
00181 char *m_name;
00182 char *m_val;
00183 uchar m_flag;
00184 };
00185
00186
00187 #define M_MARK 0x01
00188 #define M_OVERRIDE 0x02
00189 #define M_MAKE 0x04
00190
00191
00192
00193
00194 struct str
00195 {
00196 char **ptr;
00197 int len;
00198 int pos;
00199 };
00200
00201
00202
00203
00204 #ifndef EXTERN
00205 #define EXTERN extern
00206 #endif
00207
00208 #ifndef INIT
00209 #define INIT(x)
00210 #endif
00211
00212 extern int errno;
00213 extern char **environ;
00214
00215 EXTERN char *myname;
00216 EXTERN bool domake INIT(TRUE);
00217 EXTERN bool ignore INIT(FALSE);
00218 EXTERN bool conterr INIT(FALSE);
00219 EXTERN bool silent INIT(FALSE);
00220 EXTERN bool print INIT(FALSE);
00221 EXTERN bool rules INIT(TRUE);
00222 EXTERN bool dotouch INIT(FALSE);
00223 EXTERN bool quest INIT(FALSE);
00224 EXTERN bool useenv INIT(FALSE);
00225 EXTERN bool dbginfo INIT(FALSE);
00226 EXTERN bool ambigmac INIT(TRUE);
00227 EXTERN struct name *firstname;
00228 EXTERN char *str1;
00229 EXTERN char *str2;
00230 EXTERN struct str str1s;
00231 EXTERN struct str str2s;
00232 EXTERN struct name **suffparray;
00233 EXTERN int sizesuffarray INIT(20);
00234 EXTERN int maxsuffarray INIT(0);
00235 EXTERN struct macro *macrohead;
00236 EXTERN bool expmake;
00237 EXTERN char *makefile;
00238 EXTERN int lineno;
00239
00240 #ifdef tos
00241 #ifdef LATTICE
00242 EXTERN int _mneed INIT(60000);
00243 #endif
00244 #endif
00245 #ifdef eon
00246 #define MEMSPACE (16384)
00247 EXTERN unsigned memspace = MEMSPACE;
00248 #endif
00249
00250 #define suffix(name) strrchr(name,(int)'.')
00251
00252 EXTERN int _ctypech;
00253 #define mylower(x) (islower(_ctypech=(x)) ? _ctypech :tolower(_ctypech))
00254 #define myupper(x) (isupper(_ctypech=(x)) ? _ctypech :toupper(_ctypech))
00255
00256
00257 struct sgtbuf;
00258
00259
00260 _PROTOTYPE(void prt, (void));
00261 _PROTOTYPE(void check, (struct name *np ));
00262 _PROTOTYPE(void circh, (void));
00263 _PROTOTYPE(void precious, (void));
00264
00265
00266 _PROTOTYPE(void init, (void));
00267 _PROTOTYPE(void strrealloc, (struct str *strs ));
00268 _PROTOTYPE(struct name *newname, (char *name ));
00269 _PROTOTYPE(struct name *testname, (char *name ));
00270 _PROTOTYPE(struct depend *newdep, (struct name *np, struct depend *dp ));
00271 _PROTOTYPE(struct cmd *newcmd, (char *str, struct cmd *cp ));
00272 _PROTOTYPE(void newline, (struct name *np, struct depend *dp, struct cmd *cp,
00273 int flag ));
00274 _PROTOTYPE(void input, (FILE *fd ));
00275
00276
00277 _PROTOTYPE(struct macro *getmp, (char *name ));
00278 _PROTOTYPE(char *getmacro, (char *name ));
00279 _PROTOTYPE(struct macro *setmacro, (char *name, char *val ));
00280 _PROTOTYPE(struct macro *addmacro, (char *name, char *val ));
00281 _PROTOTYPE(void setDFmacro, (char *name, char *val ));
00282 _PROTOTYPE(void doexp, (struct str *to, char *from ));
00283 _PROTOTYPE(void expand, (struct str *strs ));
00284
00285
00286 _PROTOTYPE(void main, (int argc, char **argv ));
00287 _PROTOTYPE(void setoption, (char option ));
00288 _PROTOTYPE(void usage, (void));
00289 _PROTOTYPE(void fatal, (char *msg, char *a1, int a2 ));
00290
00291
00292 _PROTOTYPE(int dosh, (char *string, char *shell ));
00293 _PROTOTYPE(int makeold, (char *name ));
00294 _PROTOTYPE(void docmds1, (struct name *np, struct line *lp ));
00295 _PROTOTYPE(void docmds, (struct name *np ));
00296 _PROTOTYPE(int Tosexec, (char *string ));
00297 _PROTOTYPE(time_t mstonix, (unsigned int date, unsigned int time ));
00298 _PROTOTYPE(void getmdate, (int fd, struct sgtbuf *tbp ));
00299 _PROTOTYPE(time_t cnvtime, (struct sgtbuf *tbp ));
00300 _PROTOTYPE(void modtime, (struct name *np ));
00301 _PROTOTYPE(void touch, (struct name *np ));
00302 _PROTOTYPE(int make, (struct name *np, int level ));
00303 _PROTOTYPE(void make1, (struct name *np, struct line *lp, struct depend *qdp,
00304 char *basename, char *inputname ));
00305 _PROTOTYPE(void implmacros, (struct name *np, struct line *lp,
00306 char **pbasename, char **pinputname ));
00307 _PROTOTYPE(void dbgprint, (int level, struct name *np, char *comment ));
00308
00309
00310 _PROTOTYPE(void error, (char *msg, char *a1 ));
00311 _PROTOTYPE(bool getline, (struct str *strs, FILE *fd ));
00312 _PROTOTYPE(char *gettok, (char **ptr ));
00313
00314
00315 _PROTOTYPE(bool dyndep, (struct name *np, char **pbasename,char **pinputname));
00316 _PROTOTYPE(void makerules, (void));
00317
00318
00319 _PROTOTYPE(int is_archive_ref, (char *name));
00320 _PROTOTYPE(int archive_stat, (char *name, struct stat *stp));