1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-21 01:47:11 +03:00

Makefile: avoid calling '$(shell)' on each $(CXX) execution

Before the change calls to $(shell git rev-parse) and $(shell pkg-config)
happened on every mold's .o file (as make's "A = $(B)" performs late
expansion).

After the change $(shell) calls are evaluated once with "A := $(B)"
assignment.

Noticed by chance when 'make' was complaining about missing pkg-config
tool on each build step.

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
This commit is contained in:
Sergei Trofimovich 2022-01-27 08:54:39 +00:00
parent 59826c197b
commit bc66d9a684

View File

@ -27,8 +27,8 @@ SRCS=$(wildcard *.cc elf/*.cc macho/*.cc)
HEADERS=$(wildcard *.h elf/*.h macho/*.h)
OBJS=$(SRCS:%.cc=out/%.o)
OS = $(shell uname -s)
ARCH = $(shell uname -m)
OS := $(shell uname -s)
ARCH := $(shell uname -m)
IS_ANDROID = 0
ifneq ($(findstring -android,$(shell $(CC) -dumpmachine)),)
@ -40,13 +40,13 @@ endif
CFLAGS = -O2
CXXFLAGS = -O2
MOLD_CXXFLAGS = -std=c++20 -fno-exceptions -fno-unwind-tables \
-fno-asynchronous-unwind-tables -DMOLD_VERSION=\"1.0.2\" \
-DLIBDIR="\"$(LIBDIR)\""
MOLD_CXXFLAGS := -std=c++20 -fno-exceptions -fno-unwind-tables \
-fno-asynchronous-unwind-tables -DMOLD_VERSION=\"1.0.2\" \
-DLIBDIR="\"$(LIBDIR)\""
MOLD_LDFLAGS = -pthread -lz -lm
MOLD_LDFLAGS := -pthread -lz -lm
GIT_HASH = $(shell [ -d .git ] && git rev-parse HEAD)
GIT_HASH := $(shell [ -d .git ] && git rev-parse HEAD)
ifneq ($(GIT_HASH),)
MOLD_CXXFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
endif