我正在使用Eclipse为C项目设置一个makefile,但是我遇到了$(CURDIR)如何工作的问题。
我当前的目录包含冒号作为路径的一部分(由于路径在网络上)。我发现此链接解释了我认为我遇到的问题:"multiple target patterns" Makefile error
有没有办法改变$(CURDIR)以使其在此实例中有效?我可以使用绝对文件路径并在链接中应用修复,但我真的更喜欢保持相对。
编辑 - 添加了makefile。改编自http://jkuhlm.bplaced.net/hellobone/
PROJECT=IDM
# Two additional CFLAGS must be used for Angstrom
# They must not be used for Debian or Ubuntu. I couldn't find out why.
# The hint came from C:\gcc-linaro\share\doc\gcc-linaro-arm-linux-gnueabihf\README.txt
#
# Uncomment the following line if you use Angstrom on your BeagleBone. We use Debian Wheezy
#TARGET=angstrom
# Directory for C-Source
vpath %.c $(CURDIR)/source
# Directory for includes
CINCLUDE = $(CURDIR)/include
# Directory for object files. Built from C files.
OBJDIR = $(CURDIR)/object
# Other dependencies
DEPS = \
Makefile \
include/IDMBLUETOOTH.h \
include/IDMCMD.h \
include/IDMIMAGE.h \
include/IDMUART.h \
include/IDMSPIDEV.h
# Compiler object files. From the source C files.
COBJ = \
$(OBJDIR)/IDMMAIN.o
# gcc binaries to use. To cross-compile with Beaglebone Black
CC = "C:\gcc-linaro\bin\arm-linux-gnueabihf-gcc.exe"
LD = "C:\gcc-linaro\bin\arm-linux-gnueabihf-gcc.exe"
# rm is part of yagarto-tools
SHELL = cmd
REMOVE = rm -f
# Compiler options
# Two additional flags neccessary for Angstrom Linux. Don't use them with Ubuntu or Debian
CFLAGS = -marm
ifeq ($(TARGET),angstrom)
CFLAGS += -march=armv4t
CFLAGS += -mfloat-abi=soft
endif
CFLAGS += -O0
CFLAGS += -g
CFLAGS += -I.
CFLAGS += -I$(CINCLUDE)
CFLAGS += $(CDEFINE)
# for a better output
MSG_EMPTYLINE = .
MSG_COMPILING = ---COMPILE---
MSG_LINKING = ---LINK---
MSG_SUCCESS = ---SUCCESS---
# Our favourite
all: $(PROJECT)
# Linker call
$(PROJECT): $(COBJ)
@echo $(MSG_EMPTYLINE)
@echo $(MSG_LINKING)
# Need -nostartfiles in order to work. See https://stackoverflow.com/questions/11116399/crt1-o-in-function-start-undefined-reference-to-main-in-linux
$(LD) -nostartfiles -o $@ $^ $(CFLAGS)
@echo $(MSG_EMPTYLINE)
@echo $(MSG_SUCCESS) $(PROJECT)
# Compiler call
$(COBJ): $(OBJDIR)/%.o: %.c $(DEPS)
@echo $(MSG_EMPTYLINE)
@echo $(MSG_COMPILING) $<
$(CC) -c -o $@ $< $(CFLAGS)
clean:
$(REMOVE) $(OBJDIR)/*.o
$(REMOVE) $(PROJECT)