usfmohy
usfmohy

Reputation: 43

Makefile with commands depending on each other

I'm a newbie with makefiles and i'm trying to write one that executes several commands. Each command outputs different files which are then passed to the next one.

SOURCE=sequencer
ENCODINGS= j a m o r
FILES= $(foreach enc,$(ENCODINGS),$(SOURCE)$(enc))

all: syf boom boog loon proof scapin 
syf : $(SOURCE).fsm
    for enc in j a m o u r ; do syf -CEV -$$enc $(SOURCE); done
boom : $(foreach file,$(FILES),$(file)_b.vbe)
boog : $(foreach file,$(FILES),$(file)_b.vst)
loon : $(foreach file,$(FILES),$(file)_b_l.vst)
proof : $(foreach file,$(FILES),$(file)_b_l_net.vbe)
scapin : $(foreach file,$(FILES),$(file)_b_l_scan.vst)


#------------------Behavioral Optimization---------------------#

%_b.vbe: %.vbe  
    @echo "    Boolean Optimization -> $@  "
    boom -d 50 $* $*_b

#------------------Standard Cell Mapping-----------------------#

%.vst : %.vbe
    @echo "    Logical Synthesis -> $@  "
    boog -x 0 -l paramfile $*

#------------------Netlist Optimization------------------------#

%_l.vst : %.vst paramfile.lax
    @echo "    Netlist Optimization -> $@ "
    loon -x 0 -l paramfile $* $*_l 

#------------------Netlist compare-----------------------------#

%_b_l_net.vbe : %_b_l.vst %.vbe
    @echo "    Formal checking -> $@ "
    flatbeh $*_b_l $*_b_l_net
    proof -d $* $*_b_l_net

#------------------Scan-path insertion-------------------------#

%_scan.vst : %.vst scan.path
    @echo "    scan-path insertion -> $@ "
    scapin -VRB $* scan $*_scan

clear :
    @echo "Erase all the files generated by the makefile" 
    rm -f *.vbe *.enc *.vst *.xsc

The previous code outputs the following error when I run make all for the first time.

make: *** No rule to make target 'sequencerj_b.vbe', needed by 'boom'.  Stop.

The first command syf is executed successfully and outputs the proper files. But, the command boom fails to run. However, when i run make all for a second time -without deleting the files- the makefile finishes its operation successfully. Am i missing something? Maybe boom doesn't wait for syf to finish running.

What the commands do :

foo.fsm -> syf -> fooj.vbe -> boom -> fooj_b.vbe -> boog -> fooj_b.vst -> loon -> fooj_b_l.vst

fooj_b_l.vst -> flatbeh -> fooj_b_l_net.vbe

fooj_b_l.vst -> scapin -> fooj_b_l_scan.vst

proof just compares 2 files with no outputs

Upvotes: 1

Views: 755

Answers (2)

Armali
Armali

Reputation: 19395

The first two paragraphs of Beta's answer are spot-on, only the proposed solution does not work.

To remedy the problem, replace the syf target name with the real target file names, and change the command line accordingly so that make gets the information about the file actually generated - i. e. replace

all: syf boom boog loon proof scapin 
syf : $(SOURCE).fsm
    for enc in j a m o u r ; do syf -CEV -$$enc $(SOURCE); done

with

# These are the files to be made by the command "syf ...":
syf=$(FILES:=.vbe) $(SOURCE)u.vbe

all: $(syf) boom boog loon proof scapin 
$(syf) : $(SOURCE).fsm
    syf -CEV -$(patsubst $(SOURCE)%.vbe,%,$@) $(SOURCE)

- now all the individual target files (sequencerj.vbe sequencera.vbe sequencerm.vbe sequencero.vbe sequencerr.vbe sequenceru.vbe) are specified in the rule, and the syf command line has to create just one of the files; the needed encoding option is extracted from the target name by the patsubst function for string substitution, e. g. $(patsubst sequencer%.vbe,%,sequencerj.vbe) produces j.

Upvotes: 0

Beta
Beta

Reputation: 99144

The visible error is caused by the fact that Make doesn't know what these rules produce. It knows that boom requires sequencerj_b.vbe, but it doesn't know how to build that file; the syf rule builds it, but Make doesn't know that.

This is exactly the kind of problem that Make is designed to solve, but the rules must be written to provide the needed information.

You have a complex build system which I can't reproduce, so this may take a few iterations. Start by removing everything above "Behaviour Optimization" and replacing it with this::

SOURCE=sequencer

TARGETS := $(patsubst %, $(SOURCE)%_b_l.vst, j a m o r)

all: $(TARGETS)

$(SOURCE)%.vbe: $(SOURCE)%.fsm
    syf -CEV -$* $(SOURCE)

Give that a try, and tell us how it goes (in a comment to this answer).

Upvotes: 1

Related Questions