gpt4 book ai didi

c - 用 cc -MM 替换 makedepend

转载 作者:行者123 更新时间:2023-12-04 06:22:49 25 4
gpt4 key购买 nike

我目前使用 makedepend,但我在使用它和一个库时遇到了一些问题,并决定我不妨切换到 cc -MM .我当前的 makefile 是基于 this 建模的.

我将如何进行更改?

当前生成文件

NAME := engine
C_SRCS := $(wildcard *.c) $(wildcard */*.c)
H_SRCS := $(wildcard *.h) $(wildcard */*.h)
C_OBJS := ${C_SRCS:.c=.o}
INCLUDE_DIRS := .
LIBRARY_DIRS :=
LIBRARIES := event

CFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L($librarydir))
LDFLAGS += $(foreach library,$(LIBRARIES),-l$(library))

.PHONY: all clean depend

all: $(NAME)

$(NAME): $(C_OBJS)
$(LINK.cc) $(C_OBJS) -o $(NAME)

clean:
@- $(RM) $(NAME)
@- $(RM) $(OBJS)

distclean: clean

depend:
makedepend -- $(CFLAGS) $(CFLAGS) -- $(C_SRCS)

# makedepend after this line
# DO NOT DELETE THIS LINE

engine.o: util/std.h /usr/include/stdlib.h /usr/include/Availability.h
engine.o: /usr/include/AvailabilityInternal.h /usr/include/_types.h
engine.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
engine.o: /usr/include/machine/_types.h /usr/include/i386/_types.h
engine.o: /usr/include/sys/wait.h /usr/include/sys/signal.h
engine.o: /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h
engine.o: /usr/include/i386/signal.h /usr/include/i386/_structs.h
engine.o: /usr/include/sys/_structs.h /usr/include/machine/_structs.h
engine.o: /usr/include/sys/resource.h /usr/include/machine/endian.h
engine.o: /usr/include/i386/endian.h /usr/include/sys/_endian.h
engine.o: /usr/include/libkern/_OSByteOrder.h
engine.o: /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h
engine.o: /usr/include/machine/types.h /usr/include/i386/types.h util/out.h
engine.o: /usr/include/stdio.h /usr/include/secure/_stdio.h
engine.o: /usr/include/secure/_common.h /usr/include/errno.h
engine.o: /usr/include/sys/errno.h /usr/include/string.h
engine.o: /usr/include/secure/_string.h util/lvl.h conf.h http/server.h
http/server.o: /usr/include/errno.h /usr/include/sys/errno.h
http/server.o: /usr/include/sys/cdefs.h /usr/include/stdlib.h
http/server.o: /usr/include/Availability.h
http/server.o: /usr/include/AvailabilityInternal.h /usr/include/_types.h
http/server.o: /usr/include/sys/_types.h /usr/include/machine/_types.h
http/server.o: /usr/include/i386/_types.h /usr/include/sys/wait.h
http/server.o: /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h
http/server.o: /usr/include/machine/signal.h /usr/include/i386/signal.h
http/server.o: /usr/include/i386/_structs.h /usr/include/sys/_structs.h
http/server.o: /usr/include/machine/_structs.h /usr/include/sys/resource.h
http/server.o: /usr/include/machine/endian.h /usr/include/i386/endian.h
http/server.o: /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h
http/server.o: /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h
http/server.o: /usr/include/machine/types.h /usr/include/i386/types.h
http/server.o: /usr/include/unistd.h /usr/include/sys/unistd.h
http/server.o: /usr/include/sys/select.h /usr/include/sys/_select.h
http/server.o: /usr/include/sys/socket.h /usr/include/sys/types.h
http/server.o: /usr/include/machine/_param.h /usr/include/i386/_param.h
http/server.o: /usr/include/netdb.h /usr/include/stdint.h
http/server.o: /usr/include/netinet/in.h /usr/include/netinet6/in6.h
http/server.o: /usr/include/arpa/inet.h /usr/include/fcntl.h
http/server.o: /usr/include/sys/fcntl.h http/request.h conf.h util/out.h
http/server.o: /usr/include/stdio.h /usr/include/secure/_stdio.h
http/server.o: /usr/include/secure/_common.h /usr/include/string.h
http/server.o: /usr/include/secure/_string.h util/lvl.h util/buf.h
http/server.o: /usr/include/stddef.h
util/buf.o: /usr/include/stdlib.h /usr/include/Availability.h
util/buf.o: /usr/include/AvailabilityInternal.h /usr/include/_types.h
util/buf.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
util/buf.o: /usr/include/machine/_types.h /usr/include/i386/_types.h
util/buf.o: /usr/include/sys/wait.h /usr/include/sys/signal.h
util/buf.o: /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h
util/buf.o: /usr/include/i386/signal.h /usr/include/i386/_structs.h
util/buf.o: /usr/include/sys/_structs.h /usr/include/machine/_structs.h
util/buf.o: /usr/include/sys/resource.h /usr/include/machine/endian.h
util/buf.o: /usr/include/i386/endian.h /usr/include/sys/_endian.h
util/buf.o: /usr/include/libkern/_OSByteOrder.h
util/buf.o: /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h
util/buf.o: /usr/include/machine/types.h /usr/include/i386/types.h util/buf.h
util/buf.o: /usr/include/stddef.h util/std.h util/out.h /usr/include/stdio.h
util/buf.o: /usr/include/secure/_stdio.h /usr/include/secure/_common.h
util/buf.o: /usr/include/errno.h /usr/include/sys/errno.h
util/buf.o: /usr/include/string.h /usr/include/secure/_string.h util/lvl.h
util/buf.o: conf.h

最佳答案

查看此页面的最后一部分 auto-dependencies .

如果您的编译器支持 -MMD 选项(就像 gcc 一样),那么您只需在编译器标志中包含 -MMD(创建依赖项)和 -MP(为 .d 文件中的每个先决条件创建虚假目标),并将以下内容添加到Makefile 的结尾:

# Use the dependency files created by the -MMD option to gcc.
-include $(SRCS:.c=.d)

我已经在 Cygwin/gcc 上使用了一段时间,并且对结果感到满意。

关于c - 用 cc -MM 替换 makedepend,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6362705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com