Skip to content

Commit

Permalink
Merge pull request #486 from k-okada/use_dumpmachine
Browse files Browse the repository at this point in the history
use gcc -dumpmachine to detect target machine, instead of using uname -m.
  • Loading branch information
k-okada committed Apr 18, 2024
2 parents a7be672 + 065ebee commit 34d6e9c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
23 changes: 22 additions & 1 deletion lisp/Makefile.Linux
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,28 @@ ADD_LDFLAGS += -Wl,--no-as-needed
endif

# set CPU arch with -D
MACHINE=$(shell uname -m)
GCC_MACHINE=$(shell gcc -dumpmachine)
$(info "-- GCC_MACHINE = ${GCC_MACHINE}")
ifneq ($(GCC_MACHINE),)
ifneq (,$(findstring x86_64-linux-gnu,$(GCC_MACHINE)))
MACHINE=x86_64
endif
ifneq (,$(findstring i686-linux-gnu,$(GCC_MACHINE)))
MACHINE=i686
endif
ifneq (,$(findstring aarch64-linux-gnu,$(GCC_MACHINE)))
MACHINE=aarch64
endif
ifneq (,$(findstring arm-linux-gnu,$(GCC_MACHINE)))
MACHINE=arm
endif
ifneq (,$(findstring powerpc64le-linux-gnu,$(GCC_MACHINE)))
MACHINE=ppc64le
endif
ifneq (,$(findstring mips64el-linux-gnu,$(GCC_MACHINE)))
MACHINE=mips64
endif
endif
# need to set 'i486', for conditionals in c/*.[ch].
ifneq ($(shell gcc -dumpmachine | grep "i.*86-linux"),)
MACHINE=i486
Expand Down
2 changes: 1 addition & 1 deletion lisp/Makefile.Linux.thread
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ GLLIB= -L$(ADLIBDIR) -lGLU -lGL -lXext -leusgl
THREADDEP=mthread_posix.c
#THREADDEP=pthreads.c

ifeq ($(shell /bin/uname -m), x86_64)
ifeq ($(shell gcc -dumpmachine | sed 's/\(.*\)-.*-.*/\1/'), x86_64)
CC += -m32 -DUSE_MULTI_LIB
LD += -melf_i386
endif
Expand Down
3 changes: 2 additions & 1 deletion lisp/Makefile.LinuxARM
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ XVERSION=X_V11R6_1

#MACHINE=armv6
#MACHINE=armv5te
MACHINE=$(shell uname -m | sed 's/\(armv[0-9]\).*/\1/')
# gcc -dumpmachine retruns target triplet consists of three fields separated by a hyphen (-).
MACHINE=$(shell gcc -dumpmachine | sed 's/\(.*\)-.*-.*/\1/')

GCC_MAJOR_VERSION=$(shell gcc -dumpversion | sed -e 's/\([0-9]\)\.\([0-9]\)\([\.0-9]*\)/\1/')
GCC_MINOR_VERSION=$(shell gcc -dumpversion | sed -e 's/\([0-9]\)\.\([0-9]\)\([\.0-9]*\)/\2/')
Expand Down
10 changes: 8 additions & 2 deletions lisp/image/jpeg/makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# jpeg compression/decompression for euslisp
# copyright (c) 1997, Toshihiro Matsui, Electrotechnical Laboratory

OS = $(shell uname | sed s/-.*//)
ifeq ($(shell gcc -dumpmachine | sed 's/.*-\(.*\)-.*/\1/'), linux)
OS=Linux
else ifeq ($(shell gcc -dumpmachine | sed 's/.*-.*-\([a-zA-Z]*\).*/\1/'), darwin)
OS=Darwin
else ifeq ($(shell gcc -dumpmachine | sed 's/.*-.*-\(.*\)/\1/'), cygwin)
OS=Cygwin
endif
ifeq ($(OS), Linux)
LSFX = so
else
Expand All @@ -18,7 +24,7 @@ else
LD = gcc -dynamiclib
endif

ifeq ($(shell uname -m), x86_64)
ifeq ($(shell gcc -dumpmachine | sed 's/\(.*\)-.*-.*/\1/'), x86_64)
ifneq ($(ARCHDIR), Linux64)
ifneq ($(ARCHDIR), Darwin)
CC += -m32
Expand Down
8 changes: 7 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
GCC_MACHINE=$(shell gcc -dumpmachine)
$(info "-- GCC_MACHINE = ${GCC_MACHINE}")
OS=$(shell uname -s | sed 's/[^A-Za-z1-9].*//')
ifeq ($(shell echo $(GCC_MACHINE) | sed 's/.*-\(.*\)-.*/\1/'), linux)
OS=Linux
else ifeq ($(shell echo $(GCC_MACHINE) | sed 's/.*-.*-\([a-zA-Z]*\).*/\1/'), darwin)
OS=Darwin
else ifeq ($(shell echo $(GCC_MACHINE) | sed 's/.*-.*-\(.*\)/\1/'), cygwin)
OS=Cygwin
endif
$(info "-- OS = ${OS}")
ifeq ($(OS),Linux)
export MAKEFILE=Makefile.Linux
Expand Down

1 comment on commit 34d6e9c

@k-okada
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing EusLisp documentation

Please check latest documents before merging

PDF version of English manual: manual.pdf
PDF version of Japanese jmanual: jmanual.pdf
HTML version of English manual: manual.html
HTML version of Japanese manual: jmanual.html
Sphinx (ReST) version of English manual: manual.rst

Please sign in to comment.