Erros BSD make
no meu Makefile
enquanto GNU make
menciona nenhum problema, e eu gostaria de saber se é possível torná-lo compatível com ele? Não que eu planeje portar o programa agora, mas presumo que tudo seja possível no futuro. Obrigado.
O erro exato produzido:
bmake: don't know how to make .force_rebuild. Stop
Meu Makefile
:
# Use the latest version of the compiler on Debian 12 OS, arm64 platform:
CXX=g++-12
# Use the official standard;
# Optimize for speed;
# Stop on all warnings;
# Do not include debug symbols:
CXXFLAGS=-std=c++17 -O3 -Wall -Wextra -Werror -Wpedantic -pedantic-errors
# The name of the resulting executable file:
APP_NAME=auto-fan-control
# The name of the C++ source code file:
SRC_FILE=$(APP_NAME).cpp
# Possibly not doing anything when using GNU make;
# You may see this for an explanation:
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#index-POSIX_002dconforming-mode_002c-setting
.POSIX:
# You may see this for an explanation:
# https://stackoverflow.com/a/70199176/1997354
# Force re-build work-around:
.PHONY: .force_rebuild
$(APP_NAME): .force_rebuild
$(APP_NAME): $(SRC_FILE)
@printf '%s' 'Compiling...'
@$(CXX) $(CXXFLAGS) $(SRC_FILE) -o $(APP_NAME)
@printf '%s\n' ' Done.'
@strip -s $(APP_NAME)
@printf '%s\n' 'Running program... '
@./$(APP_NAME)
No meu PC de teste, minha make
versão GNU é:
$ apt-cache policy make
make:
Installed: 4.3-4.1build2
Candidate: 4.3-4.1build2
Version table:
*** 4.3-4.1build2 500
500 https://archive.ubuntu.com/ubuntu noble/main amd64 Packages
100 /var/lib/dpkg/status
E ele constrói meu binário e o executa perfeitamente:
$ learn-cpp
/home/vlastimil/Development/cpp/rpi4-temperature-moninor--and-fan-control
$ make
Compiling... Done.
Running program...
25.0°C
Duvido que isso
Makefile
tenha sucesso no GNU make. O alvo.force_rebuild
está faltando, pois isso é relatado, e tanto o GNU make quanto o BSD bmake falham. Adicione o alvo como no link referenciado noMakefile
.