现在的位置: 首页 > 综合 > 正文

Contiki2.6 Makefile.include拆解【图文】

2013年05月15日 ⁄ 综合 ⁄ 共 2913字 ⁄ 字号 评论关闭

此图文是以contiki2.6源代码makefile.include为基础,以变量,关键字,用法,声明来拆解,详细的功能说明以及难点注解会在下文说明,在此只做拆解。

 

先说明一下图文中用到的几种声明和定义:

一、ifdef,用法示例

ifdef UIP_CONF_IPV6
  CFLAGS += -DUIP_CONF_IPV6=1
  UIP   = uip6.c tcpip.c psock.c uip-udp-packet.c uip-split.c \
          resolv.c tcpdump.c uiplib.c simple-udp.c
  NET   += $(UIP) uip-icmp6.c uip-nd6.c uip-packetqueue.c \
          sicslowpan.c neighbor-attr.c neighbor-info.c uip-ds6.c
else # UIP_CONF_IPV6
  UIP   = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c uip-fw.c \
          uip-fw-drv.c uip_arp.c tcpdump.c uip-neighbor.c uip-udp-packet.c \
          uip-over-mesh.c dhcpc.c simple-udp.c
  NET   += $(UIP) uaodv.c uaodv-rt.c
endif # UIP_CONF_IPV6

 

二、ifndef,用法示例

ifndef CONTIKI_NO_NET
  CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(THREADS) $(DHCP) $(DEV)
else
  CONTIKIFILES = $(SYSTEM) $(LIBS) $(THREADS) $(DEV) sicslowpan.c fakeuip.c
endif

三、ifeq,用法示例

ifeq ($(TARGET),)
  ${info TARGET not defined, using target 'native'}
  TARGET=native
else
  ${info using saved target '$(TARGET)'}
endif

 

四、ifneq,用法示例

ifneq ($(MAKECMDGOALS),clean)
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
                   $(PROJECT_SOURCEFILES:.c=.d)}
endif

 

五、make命令。e.g. make clean

clean:
rm -f *~ *core core *.srec \
*.lst *.map \
       *.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
       *.ce *.co $(CLEAN)
-rm -rf $(OBJECTDIR)

 

六、变量.

    makefile的变量也就是一个字符串,可以理解成C语言里的宏定义。

    e.g.

SYSTEM  = process.c procinit.c autostart.c elfloader.c profile.c \
          timetable.c timetable-aggregate.c compower.c serial-line.c

    定义了SYSTEM变量,使用时以"$(SYSTEM)"的方式使用。

 

七、 引用。makefile使用 include关键字引用其他文件,类似C语言的#include.

    用法:include <filename>

include $(CONTIKI)/core/net/rime/Makefile.rime
include $(CONTIKI)/core/net/mac/Makefile.mac

 

    关键字,vpath(小写)

    用法 1、vpath <pattern> <directories>

    为符合模式<pattern>的文件指定搜索目录<directories>

    用法 2、vpath<pattern>

    清除符合模式<pattern>的文件的搜索目录

    用法 3、vpath

    清除所有已被设置好了的文件搜索目录。

vpath %.c $(SOURCEDIRS)
vpath %.S $(SOURCEDIRS)

 

整体makefile.include文件拆解如下图:

 

-----------------------------------------------------------------------------------【图一】------------------------------------------------------------------------------------------

 

 

 

------------------------------------------------------------------------------------【图二】---------------------------------------------------------------------------------------------

 

 

-------------------------------------------------------------------------------------【图三】---------------------------------------------------------------------------------------------

 

-------------------------------------------------------------------------------------【图四】-----------------------------------------------------------------------------------------------

---------------------------------------------------------------------------========我是分割线========-------------------------------------------------------------------------

Makefile.include 的源代码结构和功能详解后续接上。。。

抱歉!评论已关闭.