posaune
authorMichael Wagner <michael@wagnertech.de>
Fri, 10 Jul 2020 20:04:33 +0000 (22:04 +0200)
committerMichael Wagner <michael@wagnertech.de>
Fri, 10 Jul 2020 20:04:33 +0000 (22:04 +0200)
tools/make/c_configure.sh

index 9f21ef1..434eae8 100755 (executable)
@@ -13,12 +13,24 @@ function check_arch {
 
 function install_cpp_make {
 # $1: dir to install
+
+       # find makefile
+       if [ -f /usr/share/mbuild/cpp.make ]
+       then
+               makefile=/usr/share/mbuild/cpp.make
+       elif [ -f $cwd/projects/tools/make/cpp.make ]
+       then
+               makefile=$cwd/projects/tools/make/cpp.make
+       else
+               echo "cannot find cpp makefile." >&2
+               exit 1
+       fi
        src=$(pwd);
        pushd $1
        if [ -f makefile ]; then rm makefile; fi
        if [ -L makefile ]; then rm makefile; fi
        if [ -f make.post ]; then rm make.post; fi
-       ln -s $cwd/projects/tools/make/cpp.make makefile
+       ln -s $makefile makefile
        echo "SOURCE = \\" > make.pre
        for file in $(ls *.cpp)
        do
@@ -49,6 +61,12 @@ function append_dependency {
        echo "$3:" >> $1/make.post
        echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
        echo "" >> $1/make.post
+
+       # check for shared library
+       if [ "${3##*.}" == "so" ]
+       then
+               echo "CXXFLAGS += -fPIC" >> $2/make.pre
+       fi
 }
 
 function add_include {
@@ -96,5 +114,12 @@ function append_library {
        echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
        echo "  ln -sf $src/$2/$3 ." >> $1/make.post
        echo "" >> $1/make.post
+
+       # check for shared library
+       if [ "${3##*.}" == "so" ]
+       then
+               echo "CXXFLAGS += -fPIC" >> $2/make.pre
+       fi
+
 }