You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a makefile that uses a specific matter to trigger a full rebuild when the Makefile itself changes, like so
include config.mk
# rebuild when makefile changes
-include dummy.rebuild
EXE := bench
.PHONY: all clean
CXX ?= g++
CC ?= gcc
ASM ?= nasm
ASM_FLAGS ?= -DNASM_ENABLE_DEBUG=$(NASM_DEBUG) -w+all
ARCH_FLAGS := -march=$(CPU_ARCH)
# make submakes use the specified compiler also
export CXX
export CC
INCLUDES += -Ifmt/include
COMMON_FLAGS := -MMD -Wall $(ARCH_FLAGS) -g $(O_LEVEL) $(INCLUDES) $(NDEBUG)
CPPFLAGS +=
CFLAGS += $(COMMON_FLAGS)
CXXFLAGS += $(COMMON_FLAGS) -Wno-unused-variable
SRC_FILES := $(wildcard *.cpp) $(wildcard *.c) fmt/src/format.cc
# on most compilers we should use no-pie since the nasm stuff isn't position independent
# but since old compilers don't support it, you can override it with PIE= on the command line
PIE ?= -no-pie
LDFLAGS += $(PIE) -lpthread
EXTRA_DEPS :=
OBJECTS := $(SRC_FILES:.cpp=.o) $(ASM_FILES:.asm=.o)
OBJECTS := $(OBJECTS:.cc=.o)
OBJECTS := $(OBJECTS:.c=.o)
DEPFILES = $(OBJECTS:.o=.d)
# $(info OBJECTS=$(OBJECTS))
# VPATH = test:$(PSNIP_DIR)/cpu
###########
# Targets #
###########
all: bench
-include $(DEPFILES)
clean:
rm -f *.d *.o $(EXE)
$(EXE): $(OBJECTS) $(EXTRA_DEPS)
$(CXX) $(OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
%.o : %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
%.o: %.asm
$(ASM) $(ASM_FLAGS) -f elf64 $<
# https://stackoverflow.com/a/3892826/149138
dummy.rebuild: Makefile
touch $@
$(MAKE) -s clean
Note the dummy.rebuild target. It causes $(MAKE) -s clean to be called up front, cleaning the project so the build rebuilds everything. When running compiledb make on this project it takes almost a minute and errors out like so:
$ compiledb make
## Building [make]...
make: Nothing to be done for 'all'.
make[3593]: Warning: File 'dummy.rebuild' has modification time 1.1 s in the future
make[9854]: fork: Resource temporarily unavailable
make[9854]: fork: Resource temporarily unavailable
/bin/sh: 1: Cannot fork
make[9853]: *** [Makefile:56: clean] Error 2
Looks like an infinite recursion.
The text was updated successfully, but these errors were encountered:
I have a makefile that uses a specific matter to trigger a full rebuild when the
Makefile
itself changes, like soNote the
dummy.rebuild
target. It causes$(MAKE) -s clean
to be called up front, cleaning the project so the build rebuilds everything. When runningcompiledb make
on this project it takes almost a minute and errors out like so:Looks like an infinite recursion.
The text was updated successfully, but these errors were encountered: