On Mon, Jun 06, 2016 at 04:01:53PM +0200, Paolo Bonzini wrote: > > > On 06/06/2016 14:50, Eduardo Habkost wrote: > > # Makes the definition constant after the first expansion > > DOCKER_SRC_COPY = $(eval DOCKER_SRC_COPY := > > docker-src.$(CUR_TIME))$(DOCKER_SRC_COPY) > > > > $(shell echo DEBUG: src_copy: $(DOCKER_SRC_COPY) >&2) > > > > $(DOCKER_SRC_COPY): > > @mkdir $@ > > $(call make-archive-maybe, $(SRC_PATH), $@/qemu.tgz) > > > > and I still get a failure: > > https://travis-ci.org/ehabkost/qemu/jobs/135574871 > > > > $ make -j3 && ${TEST_CMD} > > DEBUG: cur_time: 2016.13278 > > /home/travis/build/ehabkost/qemu/tests/docker/Makefile.include:37: *** > > unterminated variable reference. Stop. > > > > I am very confused by that code: using "=" to make a variable > > reference itself is not allowed, but in this case no error is > > reported because of the $(eval) trick. I have no idea what will > > happen the second time the variable is expanded. Isn't $(eval) > > going to be expanded again? > > No, the second time you'll get the expansion of > > DOCKER_SRC_COPY := docker-src.$(CUR_TIME)
And why it isn't enough to simply write the above line in the Makefile without any eval trick? > > > Why did you use this trick instead of just relying on ":=" to > > expand the shell command only once? > > I think initially the $(mkdir) was in DOCKER_SRC_COPY too. Also, too > many $(shell) end up slowing down make. And how exactly does the eval trick helps avoiding slowing down make, that wouldn't happen if using just: DOCKER_SRC_COPY = docker-src.$(CUR_TIME) ? -- Eduardo