/* This is file mm.c */ /* ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 ** ** This file is distributed under the terms listed in the document ** "copying.dj", available from DJ Delorie at the address above. ** A copy of "copying.dj" should accompany this file; if not, a copy ** should be available from where this file was obtained. This file ** may not be distributed without a verbatim copy of "copying.dj". ** ** This file is distributed WITHOUT ANY WARRANTY; without even the implied ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include main() { FILE *fin, *fout; char buf[200]; fin = fopen("maketmpl", "r"); fout = fopen("makefile", "w"); fprintf(fout, "# This file is generated from maketmpl by mm.c\n"); while (fgets(buf, 200, fin) != NULL) { if (strncmp(buf, "@dir ", 5) == 0) handle_dir(fout, buf+5); else fputs(buf, fout); } fclose(fin); fclose(fout); } int first; handle_dir(FILE *f, char *line) { char fname[100]; first = 1; sscanf(line, "%s", fname); handle_wild(f, fname, "*.c"); handle_wild(f, fname, "*.cc"); handle_wild(f, fname, "*.S"); fprintf(f, "\n"); } #include #include handle_wild(FILE *f, char *dir, char *wild) { struct ffblk ff; char buf[100], *cp; int done; sprintf(buf, "%s/%s", dir, wild); done = findfirst(buf, &ff, FA_ARCH | FA_RDONLY); while (!done) { if (first) first = 0; else fprintf(f, "\\\n"); sprintf(buf, "\t%s/%s", dir, ff.ff_name); strlwr(buf); cp = strrchr(buf, '.'); strcpy(cp, ".o"); fputs(buf, f); done = findnext(&ff); } }