[Cook] I did it this way

Dietmar Schaefer dietmar at ast.dfs.de
Thu Dec 8 19:29:20 EST 2005


Hi !


Thanks to Jerry Pendergraft I got a step further.

Jerry your perl "script" didn't work out of the box  and because I do 
not know anything about perl
I made it this way:


/*
 * NAME
 *    erl - the erlang compiler cookbook
 *
 * DESCRIPTION
 *    This cookbook describes how to work with erlang files.
 *    Include file dependencies are automatically determined.???
 *
 * RECIPES
 *    %.beam: %.erl    make beam files from erlang source files
 *
 *
 *
 * VARIABLES
 *    c_incl        The C++ include dependency sniffer command.
 *            Not altered if already defined.
 *    erlc        The erlang compiler command
 *            Not altered if already defined.
 *    erl_flags    options to pass to the erlang compiler command
 *            Not altered if already defined.
 *            The default is "???".
 *    erl_src        erlang source files in the current directory.
 *    dot_src        Source files constructable in the current directory
 *            (unioned with existing setting, if necessary).
 *    dot_beam    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.
 *
 * SEE ALSO
 *    program        The program cookbook:
 *
 * MANIFEST: cookbook for using erlang
 */

set tell-position;


#pragma once
if [not [defined c_incl]] then
    c_incl = [find_command c_incl];
if [not [defined erl_flags]] then
    erl_flags = -W +warn_unused_vars +warn_shadow_vars 
+warn_unused_import +debug_info +export_all;
if [not [defined erl_include_flags]] then
    erl_include_flags = ;
erl_src = [glob "*.erl" ];


if [not [defined dot_src]] then
    dot_src = ;
dot_src =
    [stringset
        [dot_src] [erl_src]
    -
        [fromto %.erl %.beam
        [erl_src]]
    ];
if [not [defined dot_obj]] then
    dot_obj = ;
dot_obj =
    [stringset
        [dot_obj]

        [fromto %.erl %.beam
        [erl_src]
        ]
    ];
if [not [defined dot_clean]] then
    dot_clean = ;



%0%.beam: %0%.erl
{
    [erl]  [erl_flags]   
        -o [target];
       
}


/*
 * if the c_incl command is available, then check dependencies
 */
#if [c_incl]

%0%.erl.d: %0%.erl
{
     echo "targets = " [targets];  
     sed -n [quote 's/-include[ \t]*(/#include /p' %.erl ] | [quote  
sed  's/).$//' -] | c_incl - > [target];

}

%.hrl.d: %.hrl
{
     echo "targets = " [targets];   
     sed -n [quote 's/-include[ /t]*(/#include /p' %.hrl ] | [quote sed  
's/).$//' -] | c_incl - > [target];
}   

erl_dep_files = [addsuffix ".d" [erl_src] [glob "*.hrl"]];

echo "erl_dep_files = " [erl_dep_files];

#endif







The marked line produces 6 error:

cook: cmmc_4dp.erl.d: 2: syntax error
cook: cmmc_com.erl.d: 2: syntax error
cook: cmmc_db.erl.d: 4: syntax error
cook: cmmc_snmp.erl.d: 3: syntax error
cook: cmmc_util.erl.d: 2: syntax error
cook: snmp_agentx.erl.d: 3: syntax error
cook: erl.cook: found 6 fatal errors

A few more questions ?


I only need to produce beam files   %.beam: %.erl


If I include "erl" in my cookbook shouldn' that be enough to get that ?

Why do I get
cook: no default target ?

How should it look like ?



best regards


Dietmar






More information about the Cook-users mailing list