Q: Makefile remaking directory target I have this simple makefile:
% cat Makefile
all: dir_a dir_b

dir_a: dir_a.tar.gz
        tar xf dir_a.tar.gz

dir_b:
        tar xf dir_b.tar.gz

All the targets are already created:
% ls
dir_a  dir_a.tar.gz  dir_b  dir_b.tar.gz  Makefile

But when I run make it keeps rebuilding dir_a target:
% make
tar xf dir_a.tar.gz
% make
tar xf dir_a.tar.gz

The only difference is that dir_a has tar file specified as a dependency. This tar file is not changed. Any reason it keeps remaking dir_a?

A: By making dir_a depend on the archive you are telling make to re-run the recipe if it is older than the archive, which will always be true unless you touch some of the files inside the folder or the folder itself after extracting it, as by default tar will preserve the original file timestamps.
The --touch/ -m flag forces tar to set the timestamps to when the files were extracted rather than the archive timestamps. I've also taken the liberty of tidying up a couple of things.
.PHONY: all
all: dir_a dir_b

dir_a dir_b: %: %.tar.gz
        tar xmf $<

