0

I have a project that builds several artefacts, including shared libraries, static libraries, and unit-test executables. Most of the targets in that Makefile use Google's Protocol Buffers, which is built in a submodule of that project.

Now almost all targets of that Makefile require Protocol Buffers to be built, but having to add a prerequisite to all targets seems tedious. So is there a way to specify that a target in a Makefile should always exist before building any other target?

lindelof
  • 34,556
  • 31
  • 99
  • 140

1 Answers1

1

Something like the following could do the trick

PROTOBUF     := $(CURDIR)/protobuf
SHELL_OUTPUT := $(shell make -C $(PROTOBUF) 2>&1)

ifneq ($(filter Stop.,$(SHELL_OUTPUT)),)
    $(error $(SHELL_OUTPUT))
endif


all: a b

a:
    ...
b:
    ...

How to make a failing $(shell) command interrupt Make

aerkenemesis
  • 672
  • 4
  • 16