/* This cookfile contains the instructions on how to build all the "programs" required for the "wind_gen" project. ---- Fortran version ---- This cookfile 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.c" 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). */ fc = f77; fc_flags = -g -Wall -O; /* determine all src files (*.for *.fi, 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%.for [manifest] ] [match_mask %0%.fi [manifest] ] ]; #include-cooked [dep-files] /* echo "dependency files are: " [dep-files]; */ /* find all the object files from the manifest */ all_obj = [fromto %0%.for %0%.o [match_mask "%0%.for" [manifest] ] ]; /* echo "all object files are: " [all_obj]; */ /* find all the library object files from the manifest */ libf/liblibf.a_obj = [fromto %0%.for %0%.o [match_mask "libf/%0%.for" [manifest] ] ]; /* echo "library and src files are: " [libf/liblibf.a_obj]; */ /* find all the program files from the manifest */ programs = [fromto %/main.for % [match_mask %/main.for [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%.for %0%.o [match_mask [tmp_program]/%0%.for [manifest]] ] libf/liblibf.a ; /* echo "program obj files for each program are: " [bin/[tmp_program]_obj]; */ } /* echo "The program files are: " [programs]; */ /************** RECIPE section *********************/ /* recipe to build "dependency" files */ %0%.for.d: %0%.for set nocascade { c_incl -nc -ns -nrec "--l=optimistic" -I[dirname %0%.for] -Iinclude %0%.for -prefix "'cascade %0%.for ='" -suffix "';'" -o [target]; } /* recipe to build "dependency" files */ %0%.fi.d: %0%.fi set nocascade { c_incl -nc -ns -nrec "--l=optimistic" -I[dirname %0%.fi] -Iinclude %0%.fi -prefix "'cascade %0%.fi ='" -suffix "';'" -o [target]; } /* recipe to build "obj" files */ %0%.o: %0%.for { [fc] [fc_flags] -I[dirname %0%.for] -Iinclude -c %0%.for -o [target]; } /* recipe to build "library" files */ %/lib%.a: [[target]_obj] set unlink { ar cq [target] [[target]_obj]; } /* recipe to build "binary" files (programs) */ bin/%: [[target]_obj] set mkdir { [fc] -o [target] [[target]_obj]; } /************** TARGET section *********************/ /* tell cook to build all "programs" */ all: [addprefix bin/ [programs]]; test: { echo "[addprefix bin/ [programs]] " [addprefix bin/ [programs]]; } clean: /* get all intermediate and binary files */ { rm -f [addprefix bin/ [programs]] [all_obj] set clearstat; } clobber: clean /* get those dependency files as well */ { rm -f [dep-files] set clearstat; }