misc: life_mngr: skip windows build if LDFLAGS contains -z option

Linker option "-z,relro" will be automatically added to LDFLAGS when
building debian packages. Since x86_64-w64-mingw32-ld does not support
"-z" option, it causes failure in building the life_mngr windows exe.
And compared with ld, only "-z" option is not supported. This patch
fixes it by skipping the windows build of life_mngr if LDFLAGS contains
any "-z" option.

Tracked-On: #8399
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Jiaqing Zhao 2023-05-12 09:27:49 +00:00 committed by acrnsi-robot
parent 6320977788
commit 1b2b20b07d
1 changed files with 6 additions and 3 deletions

View File

@ -40,6 +40,7 @@ LIFEMNGR_LDFLAGS += $(LDFLAGS)
# set cross compiler for Windows # set cross compiler for Windows
MINGWIN_CC := x86_64-w64-mingw32-gcc MINGWIN_CC := x86_64-w64-mingw32-gcc
MINGWIN_LD := x86_64-w64-mingw32-ld
CONF_DIR = $(sysconfdir)/life_mngr CONF_DIR = $(sysconfdir)/life_mngr
LM_C_SRCS += monitor.c LM_C_SRCS += monitor.c
@ -63,13 +64,15 @@ all-linux: life_mngr.service
# only build for Windows if cross compiler is installed # only build for Windows if cross compiler is installed
all-win: all-win:
ifneq ($(shell which $(MINGWIN_CC)),) ifeq ($(shell which $(MINGWIN_CC)),)
@echo "WARN: $(MINGWIN_CC) not installed, skipping life_mngr_win.exe" >&2
else ifneq ($(findstring -z,$(LDFLAGS)),)
@echo "WARN: $(MINGWIN_LD) does not support -z option, skipping life_mngr_win.exe" >&2
else
$(MINGWIN_CC) -g life_mngr_win.c -o $(OUT_DIR)/life_mngr_win.exe -Wall -O2 $(LDFLAGS) -lwsock32 $(MINGWIN_CC) -g life_mngr_win.c -o $(OUT_DIR)/life_mngr_win.exe -Wall -O2 $(LDFLAGS) -lwsock32
cp COPYING.MinGW-w64-runtime.txt $(OUT_DIR)/COPYING.MinGW-w64-runtime.txt cp COPYING.MinGW-w64-runtime.txt $(OUT_DIR)/COPYING.MinGW-w64-runtime.txt
cp s5_trigger_win.py $(OUT_DIR)/s5_trigger_win.py cp s5_trigger_win.py $(OUT_DIR)/s5_trigger_win.py
cp system_reboot_trigger_win.py $(OUT_DIR)/system_reboot_trigger_win.py cp system_reboot_trigger_win.py $(OUT_DIR)/system_reboot_trigger_win.py
else
@echo "WARN: $(MINGWIN_CC) not installed, skipping life_mngr_win.exe" >&2
endif endif
clean: clean: