Add m4 directory.
Check for git binary before using it.
Rework some hardcoded dependencies.