/************************************************************************* * * m a k e : h . h * * include file for make *======================================================================== * Edition history * * # Date Comments By * --- -------- ---------------------------------------------------- --- * 1 ?? ?? * 2 23.08.89 LZ increased,N_EXISTS added,suffix as macro added RAL * 3 30.08.89 macro flags added, indention changed PSH,RAL * 4 03.09.89 fixed LZ eliminated, struct str added,... RAL * 5 06.09.89 TABCHAR,M_MAKE added RAL * 6 09.09.89 tos support added, EXTERN,INIT,PARMS added PHH,RAL * 7 17.09.89 __STDC__ added, make1 decl. fixed , N_EXEC added RAL * ------------ Version 2.0 released ------------------------------- RAL * 2.1 22.02.91 alternate tos port; revised implicit rule mechanism. TRH * *************************************************************************/ #ifdef unix # undef unix # define unix 1 /* [TRH] just to be sure */ #endif #ifdef TRHTOS /* [TRH] TOS (Turbo C) with my unix-compatibility libs; this replaces "tos" */ # define unix 0 /* unix but not quite */ #endif #ifdef MSDOS # define unix 0 #endif #ifdef unix #include #include #include #include #if unix #include #else struct utimbuf { time_t actime, modtime; }; #endif #endif #ifdef eon #include #include #endif #ifdef os9 #include #include #include #include #include #endif #ifdef tos struct DOSTIME {short time,date; }; /* time structure of TOS */ #ifdef LATTICE #include #include #include #include #endif /* LATTICE */ #ifdef TURBO #include #include #include #endif /* TURBO */ #endif /* tos */ #ifdef __STDC__ # include # include #endif #include #include #ifdef eon #define MNOENT ER_NOTF #else #define MNOENT ENOENT #endif #ifndef uchar #ifdef os9 #define uchar char #define void int #define fputc putc #else #define uchar unsigned char #endif #endif #define bool uchar #ifndef time_t #define time_t long #endif #undef TRUE /* these may be deefined in some system header */ #undef FALSE #undef max #define TRUE (1) #define FALSE (0) #define max(a,b) ((a)>(b)?(a):(b)) #if unix #define DEFN1 "makefile" #define DEFN2 "Makefile" #endif #ifdef eon #define DEFN1 "makefile" #define DEFN2 "Makefile" #endif #ifdef tos #define DEFN1 "makefile." /* [TRH] why the trailing dot? */ #define DEFN2 (char *)0 #endif #ifdef os9 #define DEFN1 "makefile" #define DEFN2 (char *)0 #endif #ifdef MSDOS #define DEFN1 "makefile" #define DEFN2 "makefile.dos" #endif #ifdef TRHTOS #define DEFN1 "makefile" #define DEFN2 "makefile.st" #endif #ifdef os9 #define TABCHAR ' ' #else #define TABCHAR '\t' #endif #ifndef SLASH # ifdef MSDOS # define SLASH '\\' # endif # ifdef TRHTOS # define SLASH '\\' # endif # ifdef tos # define SLASH '\\' # endif # ifndef SLASH # define SLASH '/' # endif #endif #define LZ1 (2048) /* Initial input/expand string size */ #define LZ2 (256) /* Initial input/expand string size */ /* * A name. This represents a file, either to be made, or existant */ struct name { struct name *n_next; /* Next in the list of names */ char *n_name; /* Called */ struct line *n_line; /* Dependencies */ time_t n_time; /* Modify time of this name */ uchar n_flag; /* Info about the name */ }; #define N_MARK 0x01 /* For cycle check */ #define N_DONE 0x02 /* Name looked at */ #define N_TARG 0x04 /* Name is a target */ #define N_PREC 0x08 /* Target is precious */ #define N_DOUBLE 0x10 /* Double colon target */ #define N_EXISTS 0x20 /* File exists */ #define N_ERROR 0x40 /* Error occured */ #define N_EXEC 0x80 /* Commands executed */ /* * Definition of a target line. */ struct line { struct line *l_next; /* Next line (for ::) */ struct depend *l_dep; /* Dependents for this line */ struct cmd *l_cmd; /* Commands for this line */ }; /* * List of dependents for a line */ struct depend { struct depend *d_next; /* Next dependent */ struct name *d_name; /* Name of dependent */ }; /* * Commands for a line */ struct cmd { struct cmd *c_next; /* Next command line */ char *c_cmd; /* Command line */ }; /* * Macro storage */ struct macro { struct macro *m_next; /* Next variable */ char *m_name; /* Called ... */ char *m_val; /* Its value */ uchar m_flag; /* Infinite loop check */ }; #define M_MARK 0x01 /* for infinite loop check */ #define M_OVERRIDE 0x02 /* command-line override */ #define M_MAKE 0x04 /* for MAKE macro */ /* * String */ struct str { char *base; /* base ptr to string */ int len; /* length of string */ int pos; /* position */ }; /* Declaration, definition & initialization of variables */ #ifndef EXTERN #define EXTERN extern #endif #ifndef INIT #define INIT(x) #endif #ifndef __STDC__ extern int errno; #endif extern char **environ; EXTERN char *myname; EXTERN bool domake INIT(TRUE); /* Go through the motions option */ EXTERN bool ignore INIT(FALSE); /* Ignore exit status option */ EXTERN bool conterr INIT(FALSE); /* continue on errors */ EXTERN bool silent INIT(FALSE); /* Silent option */ EXTERN bool print INIT(FALSE); /* Print debuging information */ EXTERN bool rules INIT(TRUE); /* Use inbuilt rules */ EXTERN bool dotouch INIT(FALSE); /* Touch files instead of making */ EXTERN bool quest INIT(FALSE); /* Question up-to-dateness of file */ EXTERN bool useenv INIT(FALSE); /* Env. macro def. overwrite makefile def.*/ EXTERN bool dbginfo INIT(FALSE); /* Print lot of debugging information */ EXTERN bool ambigmac INIT(FALSE); /* guess undef. ambiguous macros (*,<) */ #ifdef SOFTRULES EXTERN bool configure INIT(FALSE); /* install set of new builtin rules */ #endif EXTERN struct name *firstname; EXTERN struct str str1s; EXTERN struct str str2s; #define str1 (str1s.base) /* this saves an indirection */ #define str2 (str2s.base) EXTERN struct name **suffparray; /* ptr. to array of ptrs. to name chains */ EXTERN int sizesuffarray INIT(20); /* size of suffarray */ EXTERN int maxsuffarray INIT(0); /* last used entry in suffarray */ EXTERN struct macro *macrohead; EXTERN bool expmake; /* TRUE if $(MAKE) has been expanded */ EXTERN int lineno; #ifdef tos #ifdef LATTICE EXTERN int _mneed INIT(60000); /* VERY important for TOS with LATTICE C*/ #endif /* LATTICE */ #endif /* tos */ #ifdef eon #define MEMSPACE (16384) EXTERN unsigned memspace = MEMSPACE; #endif /* Defines function declarations for all functions */ #ifdef __STDC__ #define CONST const #define LINT_ARGS #else #define CONST /* */ #endif #ifndef PARMS #ifdef LINT_ARGS #define PARMS(x) x #else #define PARMS(x) () #endif #endif /* :.,$s/(PARMS\(.*\));/PARMS\1;/ */ extern time_t time PARMS(( time_t *)); extern char *ctime PARMS (( CONST time_t *)); extern char *getenv PARMS (( CONST char *)); extern char *fgets PARMS (( char *, int, FILE *)); extern char *strchr PARMS (( CONST char *, int)); extern char *strrchr PARMS (( CONST char *, int)); #ifndef __STDC__ extern char *malloc PARMS (( unsigned)); extern char *realloc PARMS (( char *, unsigned)); /* OS9 ? */ #else extern void *malloc PARMS (( size_t)); extern void *realloc PARMS (( void *, size_t)); /* OS9 ? */ #endif /* main.c */ void main PARMS (( int, char **)); void setoption PARMS ((char)); void usage PARMS (( void)); void fatal PARMS (( char *, char *, int)); void nomem PARMS (( char * )); /* check.c */ void prt PARMS (( void)); void check PARMS (( struct name *)); void circh PARMS (( void)); void precious PARMS (( void)); /* input.c */ void init PARMS (( void)); void strrealloc PARMS (( struct str *)); struct name *newname PARMS (( char *)); struct name *testname PARMS (( char *)); struct depend *newdep PARMS (( struct name *, struct depend *)); struct cmd *newcmd PARMS (( char *, struct cmd *)); void newline PARMS (( struct name *, struct depend *, struct cmd *, int)); void input PARMS (( FILE *)); /* macro.c */ struct macro *getmp PARMS (( char *)); char *getmacro PARMS (( char *)); struct macro *setmacro PARMS (( char *, char *)); void setDFmacro PARMS (( char *, char *)); void doexp PARMS (( struct str *, char *)); void expand PARMS (( struct str *)); /* make.c */ int dosh PARMS (( char *, char *)); void docmds1 PARMS (( struct name *, struct line *)); void docmds PARMS (( struct name *)); #ifdef tos int Tosexec PARMS (( char *)); time_t mstonix PARMS (( struct DOSTIME *)); #endif #ifdef os9 void getmdate PARMS (( int, struct sgtbuf *)); time_t cnvtime PARMS (( struct sgtbuf *)); void time PARMS (( time_t *)); #endif void modtime PARMS (( struct name *)); void touch PARMS (( struct name *)); int make PARMS (( struct name *, int)); void make1 PARMS (( struct name *, struct line *, struct depend *,char *, char *)); void implmacros PARMS (( struct name *, struct line *, char **,char **)); void dbgprint PARMS (( int, struct name *, char *)); /* reader.c */ void error PARMS (( char *, char *)); bool getline PARMS (( struct str *, FILE *)); char *gettok PARMS (( char **)); bool quoted PARMS (( char *, char * )); /* rules.c */ bool dyndep PARMS (( struct name *, char **, char **)); void makerules PARMS (( void)); #ifdef RULETABLE bool rule_gets PARMS (( char *, int )); # ifdef SOFTRULES void load_rules PARMS (( FILE * )); void patch_rules PARMS (( void )); # endif #endif /* * Return a pointer to the suffix of a name */ #define suffix(name) strrchr(name,(int)'.') EXTERN int _ctypech; #define mylower(x) (islower(_ctypech=(x)) ? _ctypech :tolower(_ctypech)) #define myupper(x) (isupper(_ctypech=(x)) ? _ctypech :toupper(_ctypech))