automake - autoconf substitute path in script -


Do I have to call a project where many assistant script worthy Chief Executive with various command-line options available, the script Executable thinks that is in the same directory, so the executable call in the script looks like ./ my_program . This, however, is not very flexible, if the program is installed in the / usr / bin directory, and not in the current directory, what will happen?

./ my_program or just my_program Transfers the call of executable with, depending on whether the executable is already installed or not?

must autotools the IMO the simplest solution with: Under the

  • m4 / create a new m4 macro that finds the path to your program, and sets it in a variable.

    For example, you create a macro:

      MY_PROGRAM_PATH_CHECK ([action-if-found],   

    If this path is found then this macro creates MY_PROGRAM_PATH variable.

    Configure .ac

      MY_PROGRAM_PATH_CHECK (, [AC_MSG_ERROR (did not [my_program path, woot?]) AC_SUBST (MY_PROGRAM_PATH) AC_CONFIG_FILES ( [Src / script1.sh], [chmod + x Src / script1.sh]) AC_CONFIG_FILES ([src / script2.sh], [chmod + x src / script2.sh])    
  • To convert your script .en files, then the replacement will be:

    src / Makefile.am < / p>

      bin_SCRIPTS = script1. sh script2.sh   

    src / script1.sh

      @ MY_PROGRAM_PATH @ / my_program --option1   

    src / script2.sh

      @ MY_PROGRAM_PATH @ / my_program --option2 < / Code>     

Comments