Search code examples
gnu-makeautoconfautomake

How do i set up 'make install' to check the md5 of the installed libs/bins and only installed if changed?


I've inherited a fairly large project that is built using autoconfigure/automake (the configure.ac/Makefile.am files have their own issues, but that's a separate question).

My problem is that a top level build + build install generates several static and dynamic libs as well as binaries. So far so good. The problem is that 'make install' will indiscriminately copy over every single one of those libs/bins. (This takes a while)

I'd like it to only copy over libs/bins that have changed - potentially by comparing the md5sum of the target and source files.

How can i hook this up in my configure.ac/Makefile.am?


Solution

  • The actual program to copy the files is install (usually /usr/bin/install); this is defined in the INSTALL Make-variable.

    Your install implementation might support the -C flag:

       -C, --compare
              compare each pair of source and destination files, 
              and in some cases, do not modify the destination at all
    

    you might have to So you could try to provide a script that does what you want (compare the source file with the destination file, and only copy if needed), by overriding this variable. You could also just injec tthe -C flag, to see if it gives you any speedup (I tend to agree with ldav1s' comment that it might not):

    make install INSTALL="/usr/bin/install -C"
    

    note, that install accepts quite a number of arguments, and if you are going to re-implement a compatible script, you might have to implement some sub-set thereof.