总觉得PX的Firmware目录下的makefile文件有错误

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bolvtin/article/details/51770673
总觉得PX的Firmware目录下的makefile文件有错误,但是官网https://github.com/PX4/Firmware/blob/master/Makefile的代码一直没有更改,也不知道我的理解哪里有错误,暂时记录在此。
CMAKE_VER := $(shell Tools/check_cmake.sh; echo $$?)
ifneq ($(CMAKE_VER),0)
    $(warning Not a valid CMake version or CMake not installed.)
    $(warning On Ubuntu, install or upgrade via:)
    $(warning )
    $(warning 3rd party PPA:)
    $(warning sudo add-apt-repository ppa:george-edison55/cmake-3.x -y)
    $(warning sudo apt-get update)
    $(warning sudo apt-get install cmake)
    $(warning )
    $(warning Official website:)
    $(warning wget https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.sh)
    $(warning chmod +x cmake-3.4.3-Linux-x86_64.sh)
    $(warning sudo mkdir /opt/cmake-3.4.3)
    $(warning sudo ./cmake-3.4.3-Linux-x86_64.sh --prefix=/opt/cmake-3.4.3 --exclude-subdir)
    $(warning export PATH=/opt/cmake-3.4.3/bin:$$PATH)
    $(warning )
    $(error Fatal)
endif


shell Tools/check_cmake.sh; echo $$?
这句话,check_cmake.sh
文件内容
#!/bin/bash
cmake_ver=`cmake --version`

if [[ $cmake_ver == "" ]]
then
  exit 1;
fi

if [[ $cmake_ver == *" 2.8"* ]] || [[ $cmake_ver == *" 2.9"* ]] || [[ $cmake_ver == *" 3.0"* ]] || [[ $cmake_ver == *" 3.1"* ]]
then
  exit 1;
fi

exit 0;

exit命令使shell退出.参数n表示带返回值n退出
Shell命令下,反引号之间为可以先执行的指令,也可以用$()代替,
这样话,cmake –version 的返回值,无论是空字符串还是有2.8、2.9、3.0都会返回1的
而CMAKE_VER := $(shell Tools/check_cmake.sh; echo $$?)
这句话,最后还有个echo $$? 这个打印出来是进程pid?,进程的pid不可能是0呀,逻辑上都觉得是错误的。
那么ifneq ($(CMAKE_VER),0),为真,那么就会报警,怎么可能会运行下去呢。

猜你喜欢

转载自blog.csdn.net/bolvtin/article/details/51770673
今日推荐