f5a08fa37a3d4b1cc4ad753be6612ff338efae48 hiram Sat Mar 30 13:43:21 2013 -0700 using new style minimal makefile for ordinary programs, not fixing CGI rules yet, removing obsolete CVS business, refs #9104 diff --git src/utils/newProg/newProg.c src/utils/newProg/newProg.c index a8ceb3b..90a1bb4 100644 --- src/utils/newProg/newProg.c +++ src/utils/newProg/newProg.c @@ -1,48 +1,44 @@ /* newProg - make a new C source skeleton. */ #include "common.h" #include "portable.h" #include "dystring.h" #include "options.h" boolean jkhgap = FALSE; boolean cgi = FALSE; -boolean cvs = FALSE; void usage() /* Explain usage and exit. */ { errAbort( "newProg - make a new C source skeleton.\n" "usage:\n" " newProg progName description words\n" "This will make a directory 'progName' and a file in it 'progName.c'\n" "with a standard skeleton\n" "\n" "Options:\n" " -jkhgap - include jkhgap.a and mysql libraries as well as jkweb.a archives \n" - " -cgi - create shell of a CGI script for web\n" - " -cvs - also check source into CVS, 'progName' must include full\n" - " - path in source repository starting with 'kent/'"); + " -cgi - create shell of a CGI script for web"); } /* Command line validation table. */ static struct optionSpec options[] = { {"jkhgap", OPTION_BOOLEAN}, {"cgi", OPTION_BOOLEAN}, - {"cvs", OPTION_BOOLEAN}, {NULL, 0}, }; void makeCgiBody(char *name, char *description, FILE *f) /* Create most of the C file for a CGI. */ { fprintf(f, "/* Global Variables */\n" "struct cart *cart; /* CGI and other variables */\n" "struct hash *oldVars = NULL;\n" "\n" ); fprintf(f, "void doMiddle(struct cart *theCart)\n" @@ -171,128 +167,92 @@ warn("WARNING: can not find inc/common.mk 1 to 4 directories up, fix the makefile"); upLevel = cloneString("../../../../.."); } if (jkhgap || cgi) { L = cloneString("L += $(MYSQLLIBS) -lm"); myLibs = cloneString("MYLIBS = $(MYLIBDIR)/jkhgap.a ${MYLIBDIR}/jkweb.a"); } else { L = cloneString("L += -lm"); myLibs = cloneString("MYLIBS = ${MYLIBDIR}/jkweb.a"); } +if (cgi) + { fprintf(f, "include %s/inc/common.mk\n" "\n" "%s\n" "MYLIBDIR = %s/lib/${MACHTYPE}\n" "%s\n" "\n" "A = %s\n" "O = %s.o\n" "\n" , upLevel, L, upLevel, myLibs, progName, progName); -if (cgi) - { fprintf(f, "A = %s\n" "\n" "include %s/inc/cgi_build_rules.mk\n" "\n" , progName, upLevel); fprintf(f, "compile:: $O\n" "\t${CC} $O ${MYLIBS} ${L}\n" "\tmv ${AOUT} $A${EXE}\n" "\n"); } else { fprintf(f, - "%s: ${O} ${MYLIBS}\n" - "\t${CC} ${COPT} -o ${DESTDIR}${BINDIR}/${A}${EXE} $O ${MYLIBS} $L\n" - "\t${STRIP} ${DESTDIR}${BINDIR}/${A}${EXE}\n" - "\n" - "compile:: ${O}\n" - "\t${CC} ${COPT} -o ${A}${EXE} ${O} ${MYLIBS} $L\n" - "\n" - "clean::\n" - "\trm -f ${A}${EXE} ${O}\n", progName); + "kentSrc = %s\n" + "A = %s\n" + "include $(kentSrc)/inc/userApp.mk\n", upLevel, progName); } - fclose(f); } void newProg(char *module, char *description) /* newProg - make a new C source skeleton. */ { char fileName[512]; char dirName[512]; char fileOnly[128]; -char command[512]; -if (cvs) - { - char *homeDir = getenv("HOME"); - if (homeDir == NULL) - errAbort("Can't find environment variable 'HOME'"); - if (!startsWith("kent", module)) - errAbort("Need to include full module name with cvs option, not just relative path"); - safef(dirName, sizeof(dirName), "%s/kent%s", homeDir, module+strlen("kent")); - } -else safef(dirName, sizeof(dirName), "%s", module); makeDir(dirName); splitPath(dirName, NULL, fileOnly, NULL); safef(fileName, sizeof(fileName), "%s/%s.c", dirName, fileOnly); makeC(fileOnly, description, fileName); /* makefile is now constructed properly with ../.. paths */ setCurrentDir(dirName); makeMakefile(fileOnly, "makefile"); - -if (cvs) - { - /* Set current directory. Return FALSE if it fails. */ - printf("Adding %s to CVS\n", module); - setCurrentDir(".."); - safef(command, sizeof(command), "cvs add %s", fileOnly); - if (system(command) != 0) - errAbort("system call '%s' returned non-zero", command); - safef(command, sizeof(command), "cvs commit -m \"%s\" %s", description, fileOnly); - if (system(command) != 0) - errAbort("system call '%s' returned non-zero", command); - setCurrentDir(dirName); - safef(command, sizeof(command), "cvs add %s.c makefile", fileOnly); - if (system(command) != 0) - errAbort("system call '%s' returned non-zero", command); - } } int main(int argc, char *argv[]) /* Process command line. */ { struct dyString *ds = newDyString(1024); int i; optionInit(&argc, argv, options); cgi = optionExists("cgi"); -cvs = optionExists("cvs"); jkhgap = optionExists("jkhgap"); if (argc < 3) usage(); for (i=2; i<argc; ++i) { dyStringAppend(ds, argv[i]); if (i != argc-1) dyStringAppend(ds, " "); } newProg(argv[1], ds->string); return 0; }