c-Makefile.o文件规则问题



我正试图制作一个简单的makefile来编译我在linux中开发的示例应用程序(只是为了学习一些东西),但我遇到了一个奇怪的问题,我不明白为什么会发生这种情况。。

我有这个makefile:

# Easily adaptable makefile for Advanced Programming
# Compiler flags
CFLAGS=-Wall -W -g -Wmissing-prototypes
# Indentation flags
IFLAGS=-br -brs -npsl -ce -cli4
# Name of the executable
PROGRAM=ex2
# Prefix for the gengetopt file (if gengetopt is used)
PROGRAM_OPT=config
# Object files required to build the executable
PROGRAM_OBJS=debug.o ${PROGRAM_OPT}.o
# Clean and all are not files
.PHONY: clean all docs indent
all: ${PROGRAM} 
# compile with debug
debugon: CFLAGS += -D SHOW_DEBUG -g
debugon: ${PROGRAM}
${PROGRAM}: ${PROGRAM_OBJS}
    ${CC} -o $@ ${PROGRAM_OBJS}
# Generates command line arguments code from gengetopt configuration file
${PROGRAM_OPT}.h: ${PROGRAM_OPT}.ggo
    gengetopt < ${PROGRAM_OPT}.ggo --file-name=${PROGRAM_OPT}
# Dependencies
${PROGRAM_OPT}.o: ${PROGRAM_OPT}.c ${PROGRAM_OPT}.h
debug.o: debug.c debug.h
main.o: debug.h ${PROGRAM_OPT}.h
#how to create an object file (.o) from C file (.c)
.c.o:
    ${CC} ${CFLAGS} -c $<
clean:
    rm -f *.o core.* *~ ${PROGRAM} *.bak ${PROGRAM_OPT}.h ${PROGRAM_OPT}.c
indent:
    indent ${IFLAGS} *.c *.h

一旦我输入make,我就会收到一个错误,告诉我:

make: *** No rule to make target `config.c', needed by `config.o'.  Stop.

我可能遗漏了一些东西,但如果我没有错的话,这行代码明确地在PROGRAM_OPT 下

以下是目录中的文件列表:

  • config.ggo
  • main.c
  • debug.h
  • debug.c
  • 生成文件

这表示make找不到源文件config.c。你有一个制作config.h的规则,但我看不出有一个可以制作config.c的规则。

我很确定${PROGRAM_OPT}.c不应该被引用。

最新更新