jsnyder / avr32-toolchain

Makefile & supporting patches/scripts to build an AVR32 toolchain.
29 stars 30 forks source link

Stamps do not work #16

Open kblomqvist opened 12 years ago

kblomqvist commented 12 years ago

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 commented 11 years ago

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

kblomqvist commented 11 years ago

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:

############# 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 commented 11 years ago

@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.

jsnyder commented 11 years ago

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)

kblomqvist commented 11 years ago

So with this refactoring the stamps are actually working correctly?

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