avr32-toolchain icon indicating copy to clipboard operation
avr32-toolchain copied to clipboard

Stamps do not work

Open kblomqvist opened this issue 13 years ago • 5 comments

Make still does things that have been already done. For example

make install-final-gcc

starts building the final-gcc despite the build-final-gcc stamp. I doubt that the phony target and the stamp file can be chained like this

.PHONY: install-final-gcc
install-final-gcc stamps/install-final-gcc: stamps/build-final-gcc
    # ...

maybe it should be like this

.PHONY: install-final-gcc
install-final-gcc: stamps/install-final-gcc
stamps/install-final-gcc: stamps/build-final-gcc
    # ...

See for example http://www.technovelty.org/linux/tips/make-stamp.html

kblomqvist avatar Jul 22 '12 17:07 kblomqvist

I have planned to start working on this. Adding some notes:

  • From GCC Coding Conventions: touch should never be used in GCC Makefiles. Instead of touch foo always use $(STAMP) foo.

kblomqvist avatar Jan 04 '13 11:01 kblomqvist

This is how stamps would work:

############# SUPP: AUTOCONF ############
.PHONY: download-autoconf
downloads/$(AUTOCONF_ARCHIVE) download-autoconf:
    [ -d downloads ] || mkdir downloads ;
    cd downloads && curl -LO $(AUTOCONF_URL)

.PHONY: extract-autoconf
extract-autoconf: stamps/extract-autoconf
stamps/extract-autoconf: downloads/$(AUTOCONF_ARCHIVE)
    @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
    [ "$$t1" = "$(AUTOCONF_MD5)" ] || \
    ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
    tar -jxf $< ;
    [ -d stamps ] || mkdir stamps
    touch stamps/extract-autoconf;

.PHONY: build-autoconf
build-autoconf: stamps/build-autoconf
stamps/build-autoconf: stamps/extract-autoconf
    mkdir -p build/autoconf && cd build/autoconf && \
    ../../autoconf-$(AUTOCONF_VERSION)/configure --prefix="$(SUPP_PREFIX)" && \
    $(MAKE) -j$(PROCS)
    [ -d stamps ] || mkdir stamps
    touch stamps/build-autoconf;

.PHONY: install-autoconf
install-autoconf: stamps/install-autoconf
stamps/install-autoconf: stamps/build-autoconf
    cd build/autoconf && \
    $(MAKE) install
    [ -d stamps ] || mkdir stamps
    touch stamps/install-autoconf;

Refactored version:

  • To reduce noise, I removed phony targets. Not really needed?
  • Used make -p, instead of [-d dir] || mkdir dir
############# SUPP: AUTOCONF ############
stamps/install-autoconf: stamps/build-autoconf
    $(MAKE) -C build/autoconf install
    mkdir -p stamps && touch $@

stamps/build-autoconf: stamps/extract-autoconf
    mkdir -p build/autoconf
    cd build/autoconf && ../../autoconf-$(AUTOCONF_VERSION)/configure --prefix="$(SUPP_PREFIX)" \
        && $(MAKE) -j$(PROCS)
    mkdir -p stamps && touch $@

stamps/extract-autoconf: downloads/$(AUTOCONF_ARCHIVE)
    @(t1=`openssl md5 $< | cut -f 2 -d " " -` && \
    [ "$$t1" = "$(AUTOCONF_MD5)" ] || \
    ( echo "Bad Checksum! Please remove the following file and retry: $<" && false ))
    tar -jxf $<
    mkdir -p stamps && touch $@

downloads/$(AUTOCONF_ARCHIVE):
    mkdir -p downloads
    cd downloads && curl -LO $(AUTOCONF_URL)

@jsnyder Do you like to keep all .phonies or could we just have stamp-targets?

kblomqvist avatar May 20 '13 18:05 kblomqvist

@jsnyder What's your preference about the change I proposed above? I'm asking before I'll fix all of these. So could be get rid off "unnecessary" phony-targets? Let's just keep install-cross etc.

kblomqvist avatar May 26 '13 13:05 kblomqvist

That looks good, you can remove the extra phony targets if you like.

So with this refactoring the stamps are actually working correctly?

(again sorry for delays in response)

jsnyder avatar Jun 02 '13 22:06 jsnyder

So with this refactoring the stamps are actually working correctly?

Yes. I'll open a pull request when I'm done with the refactoring.

kblomqvist avatar Jun 03 '13 14:06 kblomqvist