Skip to content

Commit 79e3017

Browse files
committed
Makefile: replace MACHINE with ARCH, remove Makefile.machine
Use readelf to get arch target name from test binary, rename MACHINE to ARCH and remove the redundant Makefile.machine file Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent 1e62272 commit 79e3017

2 files changed

Lines changed: 16 additions & 34 deletions

File tree

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ COMPILER = scan-build
5353
override CC := $(CC) clang
5454
endif
5555

56+
READELF ?= readelf
57+
5658
#
5759
# check for ALT linux gcc, define HAVE_ALT_LINUX_GCC, see core-shim.c
5860
# https://github.com/ColinIanKing/stress-ng/issues/452
@@ -157,9 +159,17 @@ endif
157159
#
158160
# Test for hardening flags and apply them if applicable
159161
#
160-
MACHINE := $(shell make -f Makefile.machine)
162+
ARCH := $(shell if objdump -H > /dev/null 2>&1 ; then \
163+
$(CC) test/test-machine.c -o test-machine > /dev/null 2>&1 && \
164+
$(READELF) -h ./test-machine | grep Machine | tr '[:upper:]' '[:lower:]' | awk '{ print $$NF }' | sed 's/\///g' || echo "unknown"; \
165+
rm -f test-machine; \
166+
else echo "unknown"; fi)
167+
168+
all:
169+
@echo $(CFLAGS)
170+
161171
ifneq ($(PRESERVE_CFLAGS),1)
162-
ifneq ($(MACHINE),$(filter $(MACHINE),alpha hppa ia64))
172+
ifneq ($(ARCH),$(filter $(ARCH),alpha hppa ia64))
163173
flag = -Wformat -fstack-protector-strong -Werror=format-security
164174
#
165175
# add -D_FORTIFY_SOURCE=2 if _FORTIFY_SOURCE is not already defined
@@ -178,7 +188,7 @@ ifeq ($(BUILD_SMALL),1)
178188
ifneq ($(filter-out clang icc scan-build,$(COMPILER)),)
179189
override CFLAGS += $(foreach flag,-fipa-pta -fivopts,$(cc_supports_flag))
180190
override CFLAGS += $(foreach flag,-ftree-vectorize -ftree-slp-vectorize,$(cc_supports_flag))
181-
ifeq ($(filter $(MACHINE),ibms390 s390),)
191+
ifeq ($(filter $(ARCH),s390),)
182192
override CFLAGS += $(foreach flag,-fmodulo-sched,$(cc_supports_flag))
183193
endif
184194
endif
@@ -897,6 +907,7 @@ cov: cov_clean clean build_info config.h
897907

898908
build_info:
899909
$(PRE_Q)echo "Compiler: $(COMPILER)"
910+
$(PRE_Q)echo "Arch: $(ARCH)"
900911
$(PRE_Q)echo "CFLAGS: $(CFLAGS)"
901912
$(PRE_Q)echo "LDFLAGS: $(LDFLAGS)"
902913

@@ -1016,7 +1027,7 @@ git-commit-id.h:
10161027
echo "#define STRESS_GIT_COMMIT_ID \"\"" > $@ ; \
10171028
fi
10181029

1019-
$(OBJS): stress-ng.h Makefile Makefile.config Makefile.machine
1030+
$(OBJS): stress-ng.h Makefile Makefile.config
10201031

10211032
stress-ng.1.gz: stress-ng.1
10221033
$(PRE_V)gzip -n -c $< > $@
@@ -1025,7 +1036,7 @@ stress-ng.1.gz: stress-ng.1
10251036
dist:
10261037
rm -rf stress-ng-$(VERSION)
10271038
mkdir stress-ng-$(VERSION)
1028-
cp -rp Makefile Makefile.config Makefile.machine $(CORE_SRC) \
1039+
cp -rp Makefile Makefile.config $(CORE_SRC) \
10291040
$(STRESS_SRC) $(HEADERS) stress-ng.1 COPYING syscalls.txt \
10301041
mascot README.md CITATIONS.md \
10311042
Dockerfile README.Android test \

Makefile.machine

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)