0

Is it possible to add a prerequisite if another file is found in the workspace? Or how else could I achieve the following idea? Basically if my workspace has a lcf file in a specific location I need to make another file.. Something like this:

lcf := ../base_sw/lcf/base.lcf

.PHONY :
all : $(objects)

# if $(lcf) file exists then
all : $(objects) sup.a2l

sup.a2l :
    # Perl script runs here to produce sup.a2l
    @echo Chris > $@
Chris
  • 538
  • 8
  • 19

2 Answers2

1

This should do it:

lcf := $(wildcard ../base_sw/lcf/base.lcf)

.PHONY :
all : $(objects) $(lcf)
Beta
  • 96,650
  • 16
  • 149
  • 150
0

Think I've managed to answer this one myself!

The wildcard function returns nothing if lcf file does not exist:

  lcf := $(wildcard ../base_sw/lcf/base.lcf)

Start to build the files that need making:

make_these_file := $(obejcts)

If lcf variable is not empty, append to files list:

ifneq ($(lcf),)
   make_these_file += sup.a2l
endif

Now our target with files required to make:

.PHONY :
all : $(make_these_file)

sup.a2l :
   # Perl script here to produce sup.a2l
   @echo Chris > $@

Works for me :)

Chris
  • 538
  • 8
  • 19