Commit b2fd68da authored by Ivan Melnikov's avatar Ivan Melnikov
Browse files

Makefile: Fix race condition affecting parallel builds

When using `make -j4` (or more than 4) to speed up builds by
running jobs in parallel, I sometimes get compilation error
like this one:

jedec.c: In function ‘write_jedec_file’:
jedec.c:311:40: error: ‘VERSION’ undeclared (first use in this function)
  311 |               STX, jedec->device_name, VERSION, jedec->QP, jedec->QF, jedec->F,
      |                                        ^~~~~~~
jedec.c:311:40: note: each undeclared identifier is reported only once for each function it appears in

That's because `version.h` is not fully written yet when
compiler reads the C files.

This commit addresses this issue by adding a dependency
on version header to all the object files. Implicit rule
is still used to compile them, so no recipe is needed.
parent f5d979a2
Pipeline #253279336 passed with stage
in 22 seconds
......@@ -117,6 +117,8 @@ $(VERSION_STRINGS):
@echo "#include \"minipro.h\"" >> $@
@echo "#include \"version.h\"" >> $@
$(OBJECTS): version_header
minipro: $(VERSION_HEADER) $(VERSION_STRINGS) $(COMMON_OBJECTS) main.o
$(CC) $(COMMON_OBJECTS) main.o $(LIBS) -o $(MINIPRO)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment