macosmakefilereadlink

What alternatives are there for " readlink -e"


I use a makefile which in order to create a library uses a .pc file which looks like this

current_path=`readlink -e .`
cat > lib/libmy.pc << EOM
prefix=$current_path
includedir=\${prefix}/inc
libdir=\${prefix}/lib

Name: my
Description: My library
Version: 1.0
Cflags: -I\${includedir}
Libs: -L\${libdir} -lmy
Libs.private: -lm
EOM

The problem is that on mac the -e flag doesn't work (even I installed coreutils). I there a method to replace the flag?


Solution

  • The most portable way I could find:

    current_path=`python -c "import os; print(os.path.abspath('${MY_AWESOME_PATH}'))"`
    

    in your case:

    current_path=`python -c "import os; print(os.path.abspath('.'))"`