首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Makefiles链乱七八糟:没有制定目标的规则。

Makefiles链乱七八糟:没有制定目标的规则。
EN

Stack Overflow用户
提问于 2017-06-14 11:42:55
回答 1查看 862关注 0票数 2

在一个转换项目中,我修改和删除了一个现有的makefile链,但成功地破坏了它。makefiles需要遵循不同的链,当我为一个没有Contiki的AVR项目编译时,以及一个带有(和一些扩展在顶部)的项目时。一个没有工作,一个已经不再,因为它也需要考虑到康蒂基的制作文件。我会尽量完整,但忽略不必要的细节。

使用/CerberOS/uJ/Build/的终端,我执行以下命令:

代码语言:javascript
复制
make cerberos CLASSES=Test_NodeToNode Location= OS=PERIPHERAL

并在最后给出以下信息:

代码语言:javascript
复制
make[2]: *** No rule to make target 'blank.u'.  Stop.
make[2]: Leaving directory '/home/sven/git/uJVM_PhD_Project/CerberOS/uJ/build'
../../UPNP/micropnp-contiki/build/Makefile_cerberos.include:159: recipe for target 'flash' failed
make[1]: *** [flash] Error 2
make[1]: Leaving directory '/home/sven/git/uJVM_PhD_Project/CerberOS/uJ/build'
Makefile:41: recipe for target 'cerberos' failed

我的目录结构如下:

代码语言:javascript
复制
/CerberOS/
-> /uJ/
---> /build/
-------> Makefile
-------> Makefile.target
-> /UPNP/
--->/contiki/
--------> Makefile.include
---> /micropnp/
--------> Makefile_cerberos.local
-------->/build/
-------------->Makefile_cerberos.include
-------->/cpu/
-------------->/avr/
--------------------> Makefile.avr

Makefile.target只包含"TARGET =,如下所示:

代码语言:javascript
复制
BUILDENV_JAVA = $(ROOT)/../uJ/buildenv_java/RT/

SRV = $(ROOT)/../uJ/Services/

CCVT    ?= $(ROOT)/../classCvt/classCvt
TOBIN   ?= $(ROOT)/../classCvt/tobinOTA
CMD = $(TOBIN) -c $(CCVT)


# By default, uJ is assumed to be in the same parent folder as uPnP
ROOT = ../..

ifndef UJ
  UJ = $(ROOT)/uJ
endif

# OS possibilities: UPNP (ID=0), PERIPHERAL (ID=1)
ifndef OS
    OS = UPNP
endif

ifeq ($(OS), UPNP)
CFLAGS += -DOS_ID=0
else ifeq ($(OS), PERIPHERAL)
CFLAGS += -DOS_ID=1
else
endif

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


cerberos: clean clean_uj __code.c
    make flash

$(info BUILDENV_JAVA is $(BUILDENV_JAVA))
$(info OS is $(OS))


include ../Makefile_uj.include

ifeq ($(OS), UPNP)

$(info Building as uPNP Platform)
include ../../UPNP/micropnp-contiki/build/Makefile_cerberos.include

else ifeq ($(OS), PERIPHERAL)

$(info Building as periperal)
include ../Makefile_peripheral.include

else
    $(info Including nothing)
endif

Makefile_cerberos.include是:

代码语言:javascript
复制
    $(info XXXXXXXXXXXXXXXXXXXXXXXX Starting Makefile_cerberos.include XXXXXXXXXXXXXXXXXXXXXXXX)

UPNP = $(ROOT)/UPNP/micropnp-contiki
CONTIKI_PROJECT = blank

# Duplicated from Contiki's Makefile. Necessary because we need the
# $TARGET var set earlier, and Contiki's Makefile is only included
# last minute.
ifeq ($(TARGET),)
  -include Makefile.target
  ifeq ($(TARGET),)
    ${info TARGET not defined, using target 'native'}
    TARGET=native
  else
    ${info using saved target '$(TARGET)'}
  endif
endif

# Allow uPnP wide local settings to be defined in a seperate Makefile
include $(UPNP)/Makefile_cerberos.local

# This enables -ffunction-sections and -fdata-sections, and splits each
# .text and .data section in the object-files in subsections for each function.
# Next, the linker is instructed to garbage collect unused variables and
# functions. The result of this is smaller files, but functions not called in
# the core image will not be available for OTA deployed services.
SMALL=1

# Disable netstacks, except for IPv6 which is used for address parsing
CONTIKI_WITH_IPV6=1
CONTIKI_WITH_IPV4=0
CONTIKI_WITH_RPL=0

# Specify project-conf file (for Contiki settings specific to uPnP)
CFLAGS += -DPROJECT_CONF_H=\"upnp-conf.h\" -fshort-enums

######################################################################
# Setting a few defaults, customizable in Makefile.local
######################################################################

# By default, Contiki is assumed to be in the same parent folder as uPnP
ifndef CONTIKI
  CONTIKI = $(ROOT)/UPNP/contiki
endif

### UPNP UJ SVEN
APPDIRS += $(UPNP)/apps
APPS += er-coap rest-engine


######################################################################
# Including source files/directories
######################################################################

# uPnP Core sourcefiles/dirs
#PROJECT_SOURCEFILES += upnp.c vector.c twi_master.c rd-client.c controller.c \
                       hal.c buzzer.c pir-sensor.c temp-sensor.c relay-switch.c\
                       lamp.c accelerometer.c loudness-sensor.c rfid.c light-sensor.c\
                       battery_varta.c thermocouple.c
# Reduced set
PROJECT_SOURCEFILES += upnp.c vector.c twi_master.c rd-client.c controller.c \
                       hal.c buzzer.c pir-sensor.c temp-sensor.c relay-switch.c\
                       loudness-sensor.c 

PROJECTDIRS += $(UPNP) \
                $(UPNP)/lib \
                $(UPNP)/drivers/

MCU=atmega1284p

### Compiler definitions
CC       = avr-gcc
LD       = avr-gcc
AS       = avr-as
AR       = avr-ar
ELF_SIZE = avr-size -C --mcu=$(MCU)
OBJCOPY  = avr-objcopy
STRIP    = avr-strip
AVRDUDE  = avrdude

OPTI = s

CFLAGS   += -Wall -mmcu=$(MCU) -gdwarf-2 -fno-strict-aliasing -O$(OPTI)
ASFLAGS  += -mmcu=$(MCU)
LDFLAGS  += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
           -Wl,--section-start=.bootloader=$(BOOTLOADER_START)
MCU=atmega1284p

# Bootsection start address (byte address!) for linker. Fuses are
# set to the second smallest bootsection (1024 bytes) starting on 0xFC00
# (word address) //TODO see if we can bring this down again!
BOOTLOADER_START=0x1F800

# Avrdude settings
AVRDUDE_PROGRAMMER=atmelice_isp
AVRDUDE_MCU=m1284p
AVRDUDE_OPTIONS=-B 1

### These flags help significantly reduce the code size
ifeq ($(SMALL),1)
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
LDFLAGS += -Wl,--gc-sections
endif # SMALL

### Upload image to MCU
#Let avrdude use defaults if options not defined
ifdef AVRDUDE_PORT
 AVRDUDE_PORT:=-P $(AVRDUDE_PORT)
endif
ifdef AVRDUDE_PROGRAMMER
 AVRDUDE_PROGRAMMER:=-c $(AVRDUDE_PROGRAMMER)
endif
ifdef AVRDUDE_MCU
 AVRDUDE_MCU:=-p $(AVRDUDE_MCU)
endif

SOURCES=$(wildcard *.c $(PROJECT_SOURCEFILES)/*.c)
SOURCES=$(wildcard *_avr.S $(PROJECT_SOURCEFILES)/*_avr.S)

OBJECTS=$(PROJECT_SOURCEFILES:.c=.o)
OBJECTS=$(PROJECT_SOURCEFILES:_avr.S=.o)

HEADERS=$(PROJECT_SOURCEFILES:.c=.h)
HEADERS=$(PROJECT_SOURCEFILES:_avr.S=.h)

### Compilation rules
#Use all standard contiki compile rules, except add .elf rule that prints size
%.elf: %.$(TARGET)
    cp $< $@
    $(ELF_SIZE) $@

#Prepare images from ELF
%.fuses.bin: %.$(TARGET)
    $(OBJCOPY) $< -j .fuse -O binary --change-section-lma .fuse=0 $@

%.eep: %.$(TARGET)
    $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
    --change-section-lma .eeprom=0 -O ihex $^ $@

%.hex: %.$(TARGET)
    $(OBJCOPY) $^ -j .text -j .data -j .bootloader -O ihex $@

#Flash targets
%.fu: %.fuses.bin
    $(eval LFUSE = $(shell od -A none --format=x1 --read-bytes=1 $<))
    $(eval HFUSE = $(shell od -A none --format=x1 --read-bytes=1 -j1 $<))
    $(eval EFUSE = $(shell od -A none --format=x1 --read-bytes=1 -j2 $<))
    $(AVRDUDE) $(AVRDUDE_MCU) -B 4 $(AVRDUDE_PORT) $(AVRDUDE_PROGRAMMER) \
        -U lfuse:w:0x$(LFUSE):m -U hfuse:w:0x$(HFUSE):m -U efuse:w:0x$(EFUSE):m

%.u: %.hex
    $(AVRDUDE) $(AVRDUDE_MCU) $(AVRDUDE_OPTIONS) $(AVRDUDE_PORT) $(AVRDUDE_PROGRAMMER) -U flash:w:$<

%.eu: %.eep
    $(AVRDUDE) $(AVRDUDE_MCU) ${AVRDUDE_OPTIONS} ${AVRDUDE_PORT} ${AVRDUDE_PROGRAMMER} -U eeprom:w:$<

flash:
    make blank.u

# Include uPnP specific platform files
include $(UPNP)/platform/$(TARGET)/Makefile.early.$(TARGET)

# Include Contiki
include $(CONTIKI)/Makefile.include

# Party overrides compilation rules of Contiki with uPnP specific rules for target platform
include $(UPNP)/platform/$(TARGET)/Makefile.$(TARGET)

根据我的理解,这是没有意义的,它没有找到一个规则,使目标空白。其他的制作人员也会做一些事情,但我已经把它们添加到巴斯泰宾中了。有关Makefile_cerberos.local,请参阅https://pastebin.com/nT4TmwPY

对于Makefile.avr (包括在$(UPNP)/platform/ makefile中):https://pastebin.com/SKz2FmjP

和Makefile.include:https://pastebin.com/NACUiv4Q

我不知所措。有人能帮忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-14 11:59:00

看看你的makefile:

代码语言:javascript
复制
%.hex: %.$(TARGET)
    $(OBJCOPY) $^ -j .text -j .data -j .bootloader -O ihex $@

%.u: %.hex
    $(AVRDUDE) $(AVRDUDE_MCU) $(AVRDUDE_OPTIONS) $(AVRDUDE_PORT) $(AVRDUDE_PROGRAMMER) -U flash:w:$<

flash:
    make blank.u

因此,flash依赖于blank.ublank.u可以依赖于静态模式规则%.u: %.hex,而静态模式规则%.u: %.hex可能依赖于静态模式规则%.hex: %.$(TARGET) --但是如果blank.$(TARGET)不存在,那么Make (正确)就决定它没有生成blank.u的规则,并且由于您提到的错误而失败。

我注意到,如果没有定义顶级Makefile,就会设置TARGET

代码语言:javascript
复制
  ifeq ($(TARGET),)
    ${info TARGET not defined, using target 'native'}
    TARGET=native

但是,我没有看到您将TARGET导出到子生成进程的任何地方。最简单的方法是在设置目标之后,将export TARGET添加到顶级makefile中。GNU制作手册有更多的细节。

顺便说一句,每当您在makefile中调用make时,您都应该这样做

代码语言:javascript
复制
$(MAKE) blank.u

而不是

代码语言:javascript
复制
make blank.u

这确保了Make被正确地调用,即使您使用的是一个非标准的二进制名称,并且为不同的命令行参数添加了一些额外的处理。同样,GNU制作手册也有详细信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44543824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档