Skip to content

Commit 9a537aa

Browse files
committed
A dedicated script to find the abiname
1 parent 4cf72d5 commit 9a537aa

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dkms.conf
5353

5454
# custom
5555
bin/
56+
tmp/
5657
gen_asm.s
5758

5859
# Visual Studio noise
@@ -64,4 +65,7 @@ gen_asm.s
6465

6566
# Allow our release libraries
6667
!lib/**/*.lib
67-
!lib/**/*.a
68+
!lib/**/*.a
69+
70+
# vs code
71+
.vscode/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CFLAGS += $(NO_CET)
1111
CXXFLAGS += $(NO_CET)
1212

1313
# run c preprocessor with any cflags to get cross compilation result, then run regular compile in native
14-
ABI := $(shell mkdir -p bin; $(CC) -E $(CFLAGS) $(CPPFLAGS) -o bin/get_abi.c get_abi.c && $(CC) -o bin/get_abi bin/get_abi.c && bin/get_abi)
14+
ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)")
1515
ifndef ABI
1616
$(error Could not determine platform)
1717
else
@@ -34,7 +34,7 @@ lib:
3434

3535
clean:
3636
rm -f src/*.o tests/*.o
37-
rm -f bin/*
37+
rm -f bin/* tmp
3838

3939
DEBUG = #-DDEBUG_DUMP
4040

abiname.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
# this script compiles and runs src/abiname.c which merely prints
4+
# out the name of the abi. This can be used by makefiles to identify
5+
# the correct library path to use to link the library
6+
# Instead of just compiling and running, we will use the provided compiler
7+
# and flags to just invoke the pre-processor. We then use the default
8+
# compiler and linker to compile and link it. This ensures that the
9+
# script works in cross-compilation environments and can actually
10+
# run the provided code.
11+
set -eu
12+
here=$(dirname "$0")
13+
mkdir -p "${here}/tmp"
14+
tmp=$(mktemp "${here}/tmp/abinameXXX.c")
15+
16+
#1 create the preprocessed file
17+
CC=${1:-cc}
18+
CFLAGS=${2:-}
19+
${CC} ${CFLAGS} -E -I "${here}/src" -o "${tmp}" "${here}/src/abiname.c"
20+
#2 compile resulting file
21+
cc -o "${tmp}.out" "${tmp}"
22+
#3 run it
23+
"${tmp}.out"

get_abi.c renamed to src/abiname.c

File renamed without changes.

0 commit comments

Comments
 (0)