earlw@pesnta.UUCP (Earl Wallace) (01/07/86)
I am posting this for friend, please reply to him at: Marc A. Ries (FCOMP, Anaheim Hills, CA 92807-2321) ...!trwrb!fcomp!root ...!trwrb!trwrba!ries # ----cut_here----cut_here----cut_here-----cut_here----- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # ReadMe # newmake.c # Makefile # This archive created: Wed Dec 18 21:13:50 1985 # By: Marc A. Ries (FCOMP, Anaheim Hills, CA 92807-2321) export PATH; PATH=/bin:$PATH echo shar: extracting "'ReadMe'" '(1227 characters)' if test -f 'ReadMe' then echo shar: will not over-write existing file "'ReadMe'" else sed 's/^Z//' << \RIESES_PIECES > 'ReadMe' Z ZEnclosed is a program named "newmake" that creates a generic ZSCCS-style Makefile for its argument: Z Z Usage: newmake filename Z Output: Makefile for the file filename.c Z ZI looked at several automated Makefile generating programs, but Zfound them to be overkill. This is "quick and dirty", but fits Zmy needs. Z ZThis program was written for three purposes: first, to quickly Zautomate the compilation and archiving of single source C Zprograms; secondly, to provide a base skeleton for creating more Zcomplex makefiles; and thirdly, for fun :-). Z ZNotes; first, the "make shar" output assumes the shar you use Zsupports the "-v" option, since I use Gary Perlman's version; Zsecondly, if you want to include the current date (in the form of ZSaturday, December 7, 1985) compile with -DDAYTIME. My apologies Zto the author of the origional dtime.c routines, I've lost your Zname; thirdly, you'll certainly want to modify the output for Z*your* site; and lastly, I solved the BSD/USG "time.h" location Zdifferences on my machine by cross-linking the files. You may Zhave to explicitly #ifdef them. Z ZThings to do: Command-line arguments to drive the Makefile or ? Z Z Marc Ries Z ...!trwrb!fcomp!marc RIESES_PIECES chmod +x 'ReadMe' fi # end of overwriting check echo shar: extracting "'newmake.c'" '(3843 characters)' if test -f 'newmake.c' then echo shar: will not over-write existing file "'newmake.c'" else sed 's/^Z//' << \RIESES_PIECES > 'newmake.c' Z#ifndef lint Zstatic char *newmake_c = "@(#)newmake.c 1.4 85/12/14 [marc@fcomp]"; Z#endif Z Z/* Z * File name: newmake.c 1.4 Z * Created: Saturday, December 4, 1985 Z * By: Marc A. Ries (FCOMP, Anaheim Hills, CA) Z * Z * Latest change: 85/12/18 19:54:44 Z * Purpose of this file: Z * Z * create a new Makefile for a single program Z * Z */ Z Z#include "stdio.h" Z#include <sys/types.h> Z Z#define MAKE "Makefile" /* output file name */ Z#define MODE 0600 /* -rw-r--r-- */ Z Z# ifdef DAYTIME Z/* Z * "Created: Wednesday, December 11, 1985" Z */ Z#include <sys/times.h> /* system dependent */ Z#include <time.h> /* system dependent */ Z Zchar *dtime (), Z *dasctime (), Z *dtimezone (), Z *dtimenow (); Z Zstruct tws *dlocaltime (), Z *dparsetime (); Z# endif DAYTIME Z Z ZFILE *fp; Zmain(argc,argv) Zint argc; Zint **argv; Z{ Z char *getenv (); Z /* the following should be exported shell variables */ Z char *NAME = getenv ("NAME"); Z char *ORG = getenv ("ORGANIZATION"); Z Z if (argc <= 1) /* no command-line arguments */ Z usage(); Z if((fp=fopen("Makefile","w"))==0){ Z fprintf(stderr," %s: can not open %s\n", argv[0], MAKE); Z exit(1); Z } Z Z fprintf(fp,"#\n"); Z fprintf(fp,"# Makefile: %s\n", argv[1]); Z# ifdef DAYTIME Z fprintf(fp,"# Created: %s\n", dtimenow()); Z# endif DAYTIME Z if (NAME) Z fprintf (fp,"# By: %s (%s)\n", NAME, ORG ? ORG : ""); Z fprintf(fp,"#\n"); Z fprintf(fp,"CC = /bin/cc\n"); Z fprintf(fp,"CFLAGS = -O -s # Site Dependent\n"); Z fprintf(fp,"SRCS = %s.c\n", argv[1]); Z fprintf(fp,"OBJS = %s.o\n", argv[1]); Z fprintf(fp,"\n"); Z fprintf(fp,"all:\t%s\n", argv[1]); Z fprintf(fp,"\n"); Z fprintf(fp,"%s:\t$(OBJS)\n", argv[1]); Z fprintf(fp,"\t$(CC) $(CFLAGS) -o %s $(OBJS)\n", argv[1]); Z fprintf(fp,"\n"); Z fprintf(fp,"clean:\n"); Z fprintf(fp,"\trm -f $(OBJS) a.out core\n"); Z fprintf(fp,"\n"); Z fprintf(fp,"shar:\n"); Z fprintf(fp,"\tshar -v %s.[clyh] Makefile > %s.shr\n", argv[1], argv[1]); Z fprintf(fp,"\n"); Z fprintf(fp,"edit:\n"); Z fprintf(fp,"\tvi $(SRCS)\n"); Z fprintf(fp," \n"); Z fprintf(fp,"%s.o:\t%s.c\n", argv[1], argv[1]); Z printf(" %s: A %s has been produced for %s\n", argv[0], MAKE, argv[1]); Z exit(0); Z} Z Zusage() Z{ Z printf(" Usage: newmake filename\n"); Z printf(" Output: Makefile for the file filename.c\n"); Z exit(1); Z} Z Z# ifdef DAYTIME Z/* Z * ala dtime.c - routines to do time structures Z */ Z Zstruct tws { /* see <time.h> */ Z int tw_sec; Z int tw_min; Z int tw_hour; Z int tw_mday; Z int tw_mon; Z int tw_year; Z int tw_wday; Z int tw_yday; Z int tw_isdst; Z}; Z Zstatic char *month[] = { Z "January", Z "February", Z "March", Z "April", Z "May", Z "June", Z "July", Z "August", Z "September", Z "October", Z "November", Z "December" Z}; Z Zstatic char *day[] = { Z "Sunday", Z "Monday", Z "Tuesday", Z "Wednesday", Z "Thursday", Z "Friday", Z "Saturday" Z}; Z Zstruct keywd { Z char *key; Z int value; Z}; Z Zlong time (); Zstruct tm *localtime (); Z Zchar *dtime (clock) Zlong *clock; Z{ Z return dasctime (dlocaltime (clock)); Z} Z Zchar *dtimenow() Z{ Z long clock; Z time (&clock); Z return dtime (&clock); Z} Z Zstruct tws *dlocaltime (clock) Zlong *clock; Z{ Z struct tm *tm; Z static struct tws tw; Z Z if (!clock) Z return NULL; Z Z tm = localtime (clock); Z tw.tw_sec = tm -> tm_sec; Z tw.tw_min = tm -> tm_min; Z tw.tw_hour = tm -> tm_hour; Z tw.tw_mday = tm -> tm_mday; Z tw.tw_mon = tm -> tm_mon; Z tw.tw_year = tm -> tm_year; Z tw.tw_wday = tm -> tm_wday; Z tw.tw_yday = tm -> tm_yday; Z return (&tw); Z} Z Zchar *dasctime (tw) Zstruct tws *tw; Z{ Z static char buffer[80], Z result[80]; Z Z if (!tw) Z return NULL; Z Z sprintf (buffer, "%s %02d, 19%02d", Z month[tw -> tw_mon], tw -> tw_mday, tw -> tw_year); Z sprintf (result, "%s, %s", day[tw -> tw_wday], buffer); Z return result; Z} Z# endif DAYTIME RIESES_PIECES chmod +x 'newmake.c' fi # end of overwriting check echo shar: extracting "'Makefile'" '(411 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^Z//' << \RIESES_PIECES > 'Makefile' Z# Z# Makefile: newmake Z# Created: Wednesday, December 11, 1985 Z# By: Marc A. Ries (FCOMP, Anaheim Hills, CA 92807-2321) Z# ZCC = /bin/cc ZCFLAGS = -O -s -DDAYTIME ZSRCS = newmake.c ZOBJS = newmake.o Z Zall: newmake Z Znewmake: $(OBJS) Z $(CC) $(CFLAGS) -o newmake $(OBJS) Z Zclean: Z rm -f $(OBJS) a.out core Z Zshar: Z shar -v -p Z ReadMe newmake.[clyh] Makefile > newmake.shr Z Zedit: Z vi $(SRCS) Z Znewmake.o: newmake.c RIESES_PIECES chmod +x 'Makefile' fi # end of overwriting check # End of shell archive exit 0