/* * Control of the implicit suffix rules */ #include "h.h" extern long ftime(); extern long time(); extern char *rindex(); extern struct name *newname(); extern char *setmacro(); /* * Return a pointer to the suffix of a name */ char * suffix(name) char * name; { return(rindex(name, '.')); } /* * Dynamic dependency. This routine applies the suffix rules * to try and find a source and a set of rules for a missing * target. If found, np is made into a target with the implicit * source name, and rules. Returns TRUE if np was made into * a target. */ bool dyndep(np) struct name * np; { register char * p; register char * q; register char * suff; /* Old suffix */ register char * basename; /* Name without suffix */ struct name * op; /* New dependent */ struct name * sp; /* Suffix */ struct line * lp; struct depend * dp; char * newsuff; p = str1; q = np->n_name; suff = suffix(q); while (q < suff) *p++ = *q++; *p = '\0'; basename = setmacro("*", str1)->m_val; if (!((sp = newname(".suffixes"))->n_flag & N_TARG)) return FALSE; for (lp = sp->n_line; lp; lp = lp->l_next) for (dp = lp->l_dep; dp; dp = dp->d_next) { newsuff = dp->d_name->n_name; if (strlen(suff)+strlen(newsuff)+1 >= LZ) fatal("Suffix rule too long"); p = str1; q = newsuff; while (*p++ = *q++) ; p--; q = suff; while (*p++ = *q++) ; sp = newname(str1); if (sp->n_flag & N_TARG) { p = str1; q = basename; if (strlen(basename) + strlen(newsuff)+1 >= LZ) fatal("Implicit name too long"); while (*p++ = *q++) ; p--; q = newsuff; while (*p++ = *q++) ; op = newname(str1); if (!op->n_time) op->n_time = ftime(op->n_name);/* Gets modtime of this file*/ if (op->n_time) { dp = newdep(op, 0); newline(np, dp, sp->n_line->l_cmd); setmacro("<", op->n_name); return TRUE; } } } return FALSE; } /* * Make the default rules */ void makerules() { struct cmd * cp; struct name * np; struct depend * dp; #ifdef xyz123zzz /* * Sure would have been nice if this had been documented as * to exactly what was going on with the routine calls. * * -mdk */ setmacro("BDSCC", "asm"); /* setmacro("BDSCFLAGS", ""); */ cp = newcmd("$(BDSCC) $(BDSCFLAGS) -n $<", 0); np = newname(".c.o"); newline(np, 0, cp); setmacro("CC", "c"); setmacro("CFLAGS", "-O"); cp = newcmd("$(CC) $(CFLAGS) -c $<", 0); np = newname(".c.obj"); newline(np, 0, cp); setmacro("M80", "asm -n"); /* setmacro("M80FLAGS", ""); */ cp = newcmd("$(M80) $(M80FLAGS) $<", 0); np = newname(".mac.o"); newline(np, 0, cp); setmacro("AS", "zas"); /* setmacro("ASFLAGS", ""); */ cp = newcmd("$(AS) $(ASFLAGS) -o $@ $<", 0); np = newname(".as.obj"); newline(np, 0, cp); np = newname(".as"); dp = newdep(np, 0); np = newname(".obj"); dp = newdep(np, dp); np = newname(".c"); dp = newdep(np, dp); np = newname(".o"); dp = newdep(np, dp); np = newname(".mac"); dp = newdep(np, dp); np = newname(".suffixes"); newline(np, dp, 0); #endif /* * C compilation. I use cc-c.sub to do what unix cc -c does. * * Macros can be overridden in makfile if I change and am * too lazy to recompile this make program's rules. * */ setmacro("ccc", "cc-c"); setmacro("cflags", ""); setmacro("cwhich", "$*"); cp = newcmd("$(ccc) $(cflags) $(cwhich)", 0); np = newname(".c.o"); newline(np, 0, cp); /* * Assembly using RMAC. */ setmacro("asm", "rmac"); setmacro("asmflags", "$$PZ SZ"); setmacro("asmwhich", "$*"); cp = newcmd("$(asm) $(asmwhich) $(asmflags)", 0); np = newname(".asm.rel"); newline(np, 0, cp); /* * No point in my Z80 assembler or MAC. Rules for * non-linkable one-module language-tools makes no * sense because it is a one-file process anyway. */ np = newname(".asm"); dp = newdep(np, 0); np = newname(".rel"); dp = newdep(np,dp); np = newname(".c"); dp = newdep(np, dp); np = newname(".o"); dp = newdep(np,dp); np = newname(".suffixes"); newline(np, dp, 0); }