make 文件中的日志输出(stdout)

make 文件中的日志输出(stdout)

如何从 make 文件内将输出(stdout)发送到日志文件?我对诸如“make > build.log”之类的命令行解决方案不感兴趣。下面列出的是我的通用 make 文件。

#  +--------------------------------------------------------------------------+
#  :      Uncomment the appropriate section below (comment all others)        :
#  +--------------------------------------------------------------------------+

# --- For TERMINAL program library files ---
# LIBS := -lm


# --- For RAYLIB program library files ---
LIBS := -l:raylib/libraylib.a -lm


# --- For NCURSES program library files ---
# LIBS := -lform -lmenu -lncurses -lm


# --- For SDL program library files ---
# SDLALL := -lSDL2_image -lSDL2_mixer -lSDL2_net -lSDL2_ttf -lSDL2_gfx
# LIBS := `sdl2-config --libs --cflags` $(SDLALL) -lm

# ------------------------- End of user editable code -------------------------
DASH    := "  +--------------------------+"
VERSION := "  :    Script: 2024.02.12    :"
TARGET  := "  :   For Raylib Makefiles   :"
AUTHOR  := "  :    By: Jan W. Zumwalt    :"

# set compiler
CC := gcc

# additional header files
HDRS :=

# additional include files
INCS :=

# additional source files
SRCS := main.c

# name of executable
EXEC := test

# generate object file names
OBJS := $(SRCS:.c=.o)

# set compiler flags
CFLAGS :=  -ggdb3 -O0 $(LIBS) --std=c17 -Wall

# default recipe
all: $(EXEC)

# recipe for building final executable
$(EXEC): $(OBJS) $(HDRS) $(INCS) Makefile > build.log
    $(CC) -o $@ $(OBJS) $(CFLAGS)
    make clean
    @echo $(\n)
    @echo $(DASH)
    @echo $(VERSION)
    @echo $(TARGET)
    @echo $(AUTHOR)
    @echo $(DASH)
    @echo $(\n)

# recipe for building object files
  # $(OBJS): $(@:.o=.c) $(HDRS) Makefile
  # $(CC) -o $@ $(@:.o=.c) -c $(CFLAGS)

# recipe to clean workspace
clean:
    rm -f $(OBJS)

# recipe to clean workspace
test: test
    ./test

.PHONY: all clean test

相关内容