1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/*
* NAME
* c - the C compiler cookbook
*
* DESCRIPTION
* This cookbook describes how to work with C files.
* Include file dependencies are automatically determined.
*
* RECIPES
* %.o: %.c make object files form C source files
* %.ln: %.c make lint object files from C source files
*
* VARIABLES
* c_incl The C indude dependency sniffer command.
* Not altered if already defined.
* cc The C compiler command
* Not altered if already defined.
* lint The lint command.
* Not altered if already defined.
* cc_flags options to pass to the C compiler command
* Not altered if already defined.
* The default is "-O".
* cc_include_flags Options passed to the C compiler and c_incl
* controlling include file searching.
* Not altered if already defined.
* The default is empty.
* cc_src C source files in the current directory.
* dot_src Source files constructable in the current directory
* (unioned with existing setting, if necessary).
* dot_obj Object files constructable in the current directory
* (unioned with existing setting, if necessary).
* dot_clean Files which may be removed from the current directory
* in a clean target.
* dot_lint_obj Lint object files constructable in the current directory
* (unioned with existing setting, if necessary).
*
* SEE ALSO
* program The program cookbook:
* ld The linker program
* ld_flags The linker flags, NOT libraries
* ld_libraries The linker flags (-L, -l) for libraries
*
* MANIFEST: cookbook for using C
*/
#pragma once
if [not [defined c_incl]] then
c_incl = [find_command c_incl];
if [not [defined cc]] then
cc = cc;
if [not [defined cc_flags]] then
cc_flags = -O;
if [not [defined cc_include_flags]] then
cc_include_flags = ;
if [not [defined cc_link_flags]] then
cc_link_flags = ;
if [not [defined lint]] then
lint = lint;
cc_src = [glob "*.c" ];
if [not [defined dot_src]] then
dot_src = ;
dot_src = [stringset [dot_src] [cc_src] - [fromto %.c %.s [cc_src]]];
if [not [defined dot_obj]] then
dot_obj = ;
dot_obj = [stringset [dot_obj] [fromto %.c %.o [cc_src]]];
if [not [defined dot_clean]] then
dot_clean = ;
dot_clean =
[stringset
[dot_clean]
[fromto %.c %.o [cc_src]]
[fromto %.c %.ln [cc_src]]
[fromto %.c %.s [cc_src]]
];
if [not [defined dot_lint_obj]] then
dot_lint_obj = ;
dot_lint_obj = [stringset [dot_lint_obj] [fromto %.c %.ln [cc_src]]];
%.o: %.c
{
[cc] [cc_include_flags] [cc_flags]
[addprefix "-I" [search_list]]
-c [resolve %.c];
}
%.ln: %.c
{
[lint] [cc_include_flags] [cc_flags]
[addprefix "-I" [search_list]]
-c [resolve %.c];
}
/*
* if the c_incl command is available, then check dependencies
*/
#if [c_incl]
%.c.d: %.c
{
[c_incl] -nc -ns -nrec
[cc_include_flags]
[resolve %.c]
[addprefix "-I" [search_list]]
-prefix "'cascade %.c ='"
-suffix "';'"
> [target];
}
%.c.h: %.c
{
[c_incl] -nc -ns -nrec
[cc_include_flags]
[resolve %.h]
[addprefix "-I" [search_list]]
-prefix "'cascade %.h ='"
-suffix "';'"
> [target];
}
cc_dep_files = [addsuffix ".d" [cc_src] [glob "*.h"]];
#include-cooked [cc_dep_files]
#endif
|