/* This cookfile contains the instructions on how to build all the "programs" required for this version of "cli_gen" (5.110). Note that this code is not broken down into multiple source files, except for a few include files, which were put into the source directory. Thus, the "include" directory is not currently being used. Also, their is no library being created so the "libf" directory is also empty. To keep cook from complaining, the section of the cook program that builds the src file list of library components is commented out. (Since there are no library files, the recipes for building libraries has not been tested in this cookbook) This cookfile for Fortran builds assumes: All shared project source files are in the "libf" directory. All program specific source files are in their respective "program" directories. All shared project include files are in the "include" directory. All program specific include files are in their respective "program" directories. All program binaries for the project are named according to their respective program directory names. Each program binary must have a "main[F]" (main.f) residing in their respective program directory. All built binaries from the project will end up in the "bin" directory. The benefits of this directory structure/scheme is that additional files/programs can be added to the project without any changes to the "cookfile" being required (usually). To include the "debug" flags", run with the DEBUG=1 on the commandline: cook DEBUG=1 */ F = ".f"; /* extension used on source files */ INC = ".inc"; /* extension used on include files */ fc_dflags = ; ld_dflags = ; fc_oflags = ; UNIX_SYS = [shell uname -s]; setenv UNIX_SYS = [UNIX_SYS]; /* determine the OS architecture - compiler is assumed for each OS */ #if [in [UNIX_SYS] SunOS] fc = f95; /* fc_flags = -u -U -C -dalign -w2 -fast; */ fc_flags = "-C -dalign -w2 -fast"; fc_dflags = ; ld_flags = "-fast"; /* must be used if compiled with it */ ld_dflags = ; ld_libs = ; LIB = lib; /* library prefix */ A = .a; /* library suffix */ OBJ = .o; /* object file suffix */ EXE = ; /* executable suffix */ fc_exe_flag = "-o"; #elif [in [UNIX_SYS] Linux] /* default debugging stuff (use if [DEBUG] set) */ fc_dflags += --chk; /* subscript bounds checking (disable for speed) */ fc_dflags += --g; /* Lahey debugging information */ fc_dflags += --trace; /* generate traceback if error */ fc_dflags += --w; /* issue warnings and informational messages */ fc_dflags += -stchk; /* stack checking */ fc_dflags += --o0; /* disable optimizations (helpful for debugging) */ /* default debugging stuff (use if [DEBUG] set) */ ld_dflags = -g; ld_dflags += --trace; /* ld_dflags += --fullwarn; enable more warnings */ /* "optimization" flags (use if [OPT] is set) */ fc_oflags += --ntrace; /* turns off tracing */ fc_oflags += --nchk; /* turns off subscript bounds checking */ fc_oflags += --nstchk; /* turns off stack checking */ fc_oflags += --o1; /* turns on optimization */ /* Linux Lahey compiler - lf95 */ fc = lf95; /* Lahey Fortran 95 compiler */ fc_flags = --warn; /* issue warnings and informational messages */ fc_flags += --trap ; /* runtime traps for divide-by-zero (d), invalid */ /* operand (i), overflow (o), and underflow (u) */ fc_flags += --trace; /* generate traceback if error */ fc_flags += --ap; /* reload registers always to guard numeric precision*/ ld_flags = --warn; /* enable warnings */ ld_flags += --ap; /* reload registers always to guard numeric precision*/ fc_exe_flag = "--out"; A = .a; OBJ = .o; EXE = ; LIB = ; #else /* [in [UNIX_SYS] CYGWIN_NT-*.*] */ /* 4.1, 5.0, and 5.1 */ fc = lf95; /* assuming Lahey Fortran 95 compiler */ fc_flags = -nomap -w -fullwarn -ntrace -nchk -nstchk; fc_dflags = ; ld_flags = ; ld_dflags = ; ld_libs = ; LIB = ; A = .lib; OBJ = .obj; EXE = .exe; fc_exe_flag = "-out"; #endif if [defined DEBUG] then { echo "compiling with DEBUG options enabled"; fc_flags = [fc_flags] [fc_dflags]; ld_flags = [ld_flags] [ld_dflags]; } else if [defined OPT] then /* include optimization flags if OPT is set */ { fc_flags += [fc_oflags]; } /* determine all src files (*[F] *[INC], etc.) of project */ manifest = [fromto ./%0% %0% [collect find . ! -type d -print] ]; /* echo "manifest list is: " [manifest]; */ /* find the dependency files from the manifest */ /* and "magically include them (#include-cooked) */ dep-files = [addsuffix .d [match_mask %0%[F] [manifest] ] [match_mask %0%[INC] [manifest] ] ]; #include-cooked [dep-files] /* echo "dependency files are: " [dep-files]; */ /* find all the object files from the manifest */ all_obj = [fromto %0%[F] %0%[OBJ] [match_mask %0%[F] [manifest] ] ]; /* echo "all object files are: " [all_obj]; */ /* find all the library object files from the manifest */ libf/[LIB]libf[A]_obj = [fromto %0%[F] %0%[OBJ] [match_mask "libf/%0%[F]" [manifest] ] ]; /* echo "library and src files are: " [libf/[LIB]libf[A]_obj]; */ /* find all the program files from the manifest */ programs = [fromto %/main[F] % [match_mask %/main[F] [manifest] ] ]; /* echo "The program files are: " [programs]; */ /* determine all the src files (and libraries) */ /* needed for each program (exe) file from the manifest */ /* Note the need for temporary variables as they get destroyed in the loop */ tmp_program_list = [programs]; loop { tmp_program = [head [tmp_program_list]]; if [not [count [tmp_program]]] then loopstop; /* remove first (leading) program from list each time through loop */ tmp_program_list = [tail [tmp_program_list]]; bin/[tmp_program]_obj = [fromto %0%[F] %0%[OBJ] [match_mask [tmp_program]/%0%[F] [manifest]] ] /* Commented out since there are no library src files in this program */ /* libf/[LIB]libf[A] */ ; /* echo "program obj files for each program are: " [bin/[tmp_program]_obj]; */ } /************** RECIPE section *********************/ /* recipe to build src "dependency" files */ %0%[F].d: %0%[F] set nocascade { c_incl -nc -ns -nrec "--l=optimistic" -I [dirname %0%[F]] -Iinclude %0%[F] -prefix "'cascade %0%[F] ='" -suffix "';'" -o [target]; } /* recipe to build include "dependency" files */ %0%[INC].d: %0%[INC] set nocascade { c_incl -nc -ns -nrec "--l=optimistic" -I[dirname %0%[INC]] -Iinclude %0%[INC] -prefix "'cascade %0%[INC] ='" -suffix "';'" -o [target]; } /* recipe to build "obj" files */ %0%[OBJ]: %0%[F] { [fc] -I[dirname %0%[F]] -Iinclude [fc_flags] -c %0%[F] -o [target]; } /* recipe to build "library" files */ %/[LIB]%[A]: [[target]_obj] set unlink { echo "%[LIB]%[A]" [[target]_obj]; ar cq [target] [[target]_obj]; } /* recipe to build "binary" files (programs) */ bin/%: [[target]_obj] set mkdir { [fc] [fc_exe_flag] [target][EXE] [ld_flags] [[target]_obj]; } /************** TARGET section *********************/ /* tell cook to build all "programs" */ all: [addprefix bin/ [programs]]; test: { echo "The program files are: " [programs]; echo "[addprefix bin/ [programs]] " [addprefix bin/ [programs]]; echo "library and src files are: " [libf/[LIB]libf[A]_obj]; echo "all object files are: " [all_obj]; echo "dependency files are: " [dep-files]; echo "manifest list is: " [manifest]; } clean: /* get all intermediate and binary files */ { rm -f [addprefix bin/ [programs]] [all_obj] set clearstat; } clobber: clean /* get those dependency and extraneous files as well */ { rm -f [dep-files] rm -f [match_mask %0%.map [manifest] ] cookfile.list set clearstat; }