Skip to content

Commit cbf9ce3

Browse files
Merge pull request #2 from kristjanvalur/dev
Dev
2 parents ac24664 + dd3c568 commit cbf9ce3

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
# custom
4747
bin/
48+
tmp/
4849
gen_asm.s
4950

5051
# Visual Studio noise
@@ -56,4 +57,7 @@ gen_asm.s
5657

5758
# Allow our release libraries
5859
!lib/**/*.lib
59-
!lib/**/*.a
60+
!lib/**/*.a
61+
62+
# vs code
63+
.vscode/

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LD = $(PLATFORM_PREFIX)ld
1818
AR = $(PLATFORM_PREFIX)ar
1919
endif
2020
# run c preprocessor with any cflags to get cross compilation result, then run regular compile in native
21-
ABI := $(shell set -x; mkdir -p bin; $(CC) -E $(CFLAGS) $(CPPFLAGS) -o bin/get_abi.c get_abi.c && $(OLDCC) -o bin/get_abi bin/get_abi.c && bin/get_abi)
21+
ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)")
2222
ifndef ABI
2323
$(error Could not determine platform)
2424
else
@@ -37,11 +37,11 @@ $(LIB)/libstackman.a: lib $(obj)
3737

3838
.PHONY: lib clean
3939
lib:
40-
mkdir -p $(LIB)
40+
mkdir -p $(LIB) bin
4141

4242
clean:
4343
rm -f src/*.o tests/*.o
44-
rm -f bin/*
44+
rm -f bin/* tmp
4545

4646
DEBUG = #-DDEBUG_DUMP
4747

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)