研究pixhawk的makefile的结构(-)

首先研究pixhawk  的 makefile 的结构是怎样的 方便以后开发测试


1.按照官方解释需要在 arducopter 文件创建 make的目标
make px4-v2 
make px4-v2-upload

2.  打开arducopter 的makefile 显示为 
include ../mk/apm.mk 
引用其他mk 所以去看看apm.mk 是什么

3.  上代码解释了,
SYSTYPE := $(shell uname)
#系统环境是什么 我的是 linux 


#判断是什么环境 在win 下使用的是mingw32
ifneq ($(findstring CYGWIN, $(SYSTYPE)),) 
  MK_DIR := $(shell cygpath -m ../mk)
else
  MK_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
endif
#MK_DIR == ../mk


#引用environ.mk 文件 关键的环境变量在你面实现 这个在4
include $(MK_DIR)/environ.mk


# short-circuit build for the configure target
ifeq ($(MAKECMDGOALS),configure)
include $(MK_DIR)/configure.mk


else


# short-circuit build for the help target
include $(MK_DIR)/help.mk


# common makefile components
include $(MK_DIR)/targets.mk
include $(MK_DIR)/sketch_sources.mk


ifneq ($(MAKECMDGOALS),clean) 
 
ifeq ($(HAL_BOARD),HAL_BOARD_PX4)
include $(MK_DIR)/board_px4.mk
endif


4. 
# Save the system type for later use.
# 系统名字
SYSTYPE := $(shell uname)
#获得git 版本
GIT_VERSION := $(shell git rev-parse HEAD | cut -c1-8)
EXTRAFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""


# force LANG to C so awk works sanely on MacOS
export LANG=C


#
# Locate the sketch sources based on the initial Makefile's path
# 定位基于初始makefile的路径图来源
# 定位是那个sketch文件发出的 make 指令  所以在不同的地方发出的 make 指令直接影响着结果。
# 所以在libraries下的测试 makefile都是指向apm 


SRCROOT := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
  # Workaround a $(realpath ) bug on cygwin
  ifeq ($(SRCROOT),)
    SRCROOT := $(shell cygpath -m ${CURDIR})
    $(warning your realpath function is not working)
    $(warning > setting SRCROOT to $(SRCROOT))
  endif
endif


#
# We need to know the location of the sketchbook.  If it hasn't been overridden,
# try the parent of the current directory.  If there is no libraries directory
# there, assume that we are in a library's examples directory and try backing up
# further.
 


ifeq ($(SKETCHBOOK),)
  SKETCHBOOK := $(shell cd $(SRCROOT)/.. && pwd)
  ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
    SKETCHBOOK := $(shell cd $(SRCROOT)/../.. && pwd)
  endif
  ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
    SKETCHBOOK := $(shell cd $(SRCROOT)/../../.. && pwd)
  endif
  ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
    SKETCHBOOK := $(shell cd $(SRCROOT)/../../../.. && pwd)
  endif
  ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
    $(error ERROR: cannot determine sketchbook location - please specify on the commandline with SKETCHBOOK=<path>)
  endif
else
  ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
    $(warning WARNING: sketchbook directory $(SKETCHBOOK) contains no libraries)
  endif
endif
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
    # Convert cygwin path into a windows normal path
    SKETCHBOOK := $(shell cygpath ${SKETCHBOOK})
endif
#结果 就是 SKETCHBOOK == /e/ardupilot
#如果config.mk 不是空哦,include 他
ifneq ($(wildcard $(SKETCHBOOK)/config.mk),)
$(info Reading $(SKETCHBOOK)/config.mk)
include $(SKETCHBOOK)/config.mk
endif




ifneq ($(wildcard $(SKETCHBOOK)/developer.mk),)
$(info Reading $(SKETCHBOOK)/developer.mk)
include $(SKETCHBOOK)/developer.mk
endif


#
# Work out the sketch name from the name of the source directory.
# 找出是哪个sketch,他的名字  
SKETCH := $(lastword $(subst /, ,$(SRCROOT)))
# Workaround a $(lastword ) bug on cygwin
ifeq ($(SKETCH),)
  WORDLIST := $(subst /, ,$(SRCROOT))
  SKETCH := $(word $(words $(WORDLIST)),$(WORDLIST))
endif


#
# Work out where we are going to be building things
# 算出哪是我们要build的事
TMPDIR ?= /tmp
#MAKECMDGOALS 就是编译目标 比如 px4-v2
#BUILDROOT ==/e/ardupilot/Build.$(SKETCH)
ifneq ($(findstring px4, $(MAKECMDGOALS)),)
# when building px4 we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
 个人水平有限,如有争议,还望多多指教!!!
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值