0

I am trying to compile openVPN for Apple Silicon + Intel, with the compilation process running on Intel for the moment, but I would like to make it compilable on Apple Silicon too. I have created a #!/bin/bash script that performs the whole process, but I still have one hard coded path in the script. Specifically it is:

./configure OPENSSL_LIBS="-L/Users/fofo/Desktop/Fat_OpenVPN/Fat_openSSL/OpenSSLFatLibraries -lssl -lcrypto"

I have tried for example:

./configure OPENSSL_LIBS="-L../Fat_openSSL/OpenSSLFatLibraries -lssl -lcrypto"

but it does not work. Everything works with the hard coded paths. I have tried everything, but I don't succeed to replace the hard coded path with a relative one that would make the script to work when its enclosing folder path is not specified. When writing the script, for the moment I have made the assumption that it must be run with the working directory set to its parent folder. Any help is greatly appreciated. Thanks

Alfonso Tesauro
  • 1,730
  • 13
  • 21
  • See [BashFAQ #28: "How do I determine the location of my script? I want to read some config files from the same place."](http://mywiki.wooledge.org/BashFAQ/028) This question is a possible duplicate of ["How to get the source directory of a Bash script from within the script itself?"](https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself?rq=1) – Gordon Davisson Dec 24 '20 at 00:42
  • @GordonDavisson, I know how to retrieve the path but I think that particular argument does not accept it because it does not work. I have tried some $PWD logic and echo did print the path correctly, but it still did not work in the mentioned ./configure command – Alfonso Tesauro Dec 24 '20 at 01:04
  • Does the path have any spaces or other "weird" characters in it? – Gordon Davisson Dec 24 '20 at 01:19
  • The path is exactly as you see it in the question. Only underscores are present. Thanks – Alfonso Tesauro Dec 24 '20 at 01:28
  • Try putting `set -x` before the relevant section of the script, so you can see exactly what it's doing as it runs. – Gordon Davisson Dec 24 '20 at 01:30
  • That was a very good suggestion @GordonDavisson. Thanks to that, I have discovered that if I use .. or a $ variable inside the double quotes, then the whole thing gets embedded in single quotes: 'OPENSSL_LIBS="-L../Fat_openSSL/OpenSSLFatLibraries -lssl -lcrypto" '. I don't know how to solve this problem for the moment. Thanks for any help. – Alfonso Tesauro Dec 24 '20 at 02:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/226371/discussion-between-alfonso-tesauro-and-gordon-davisson). – Alfonso Tesauro Dec 24 '20 at 05:33

0 Answers0