Mercurial > pub > dyncall > dyncall
annotate test/dynload_plain/Makefile.embedded @ 665:ef356272a1c7 default tip
- introduced Makefile var APP_SUFFIX to handle cases where compilers implicitly add an extension to executables (e.g. llvm/mingw64 adds .exe even of not specified via -o)
author | Tassilo Philipp |
---|---|
date | Thu, 20 Jun 2024 17:10:12 +0200 |
parents | 127b569978cc |
children |
rev | line source |
---|---|
214 | 1 APP = dynload_plain |
2 OBJS = dynload_plain.o | |
308 | 3 TEST_U8_SO = dynload_plain_ß_test # @@@ unsure if every platform handles ß, here (ANSI, UTF-8, ...) |
214 | 4 |
5 TOP = ../.. | |
308 | 6 CFLAGS += -I${TOP}/dynload -DDEF_C_DYLIB=\"${DEF_C_DYLIB}\" |
214 | 7 LDFLAGS += -L${TOP}/dynload |
8 LDLIBS += -ldynload_s | |
9 # Works on: Darwin, NetBSD. | |
10 # Linux: add '-ldl' | |
11 | |
570
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
12 all: ${TEST_C_LD} ${TEST_U8_SO} |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
13 # deduce path to default libc.so file, easier to do via shell than in code |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
14 # (see main() in dynload_plain.c); get from what ${TEST_C_LD} is linked |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
15 # against, then reinvoke make with actual build |
609
f2f0e53d8b02
- test/dynload_plain: fix to make rule for old ksh93 versions, which segfault on nested, forked subshells
Tassilo Philipp
parents:
596
diff
changeset
|
16 export X=`{ (ldd ${TEST_C_LD} | awk '/libc\.so/{for(i=1;i<=NF;++i){if($$i~"^/"){print $$i;++r}}}END{exit !r}' || ls /lib*/libc.so* || ls /usr/lib/libc.so*) | grep -v '\.a$$' | (sort -V -r || sort -t . -n -k 2) } 2>/dev/null | head -1`; \ |
570
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
17 ${MAKE} DEF_C_DYLIB="$$X" ${APP} |
214 | 18 |
19 .PHONY: all clean | |
20 | |
570
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
21 ${TEST_C_LD}: |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
22 # dummy bin built with same toolchain and flags to deduce default c lib this is linked with |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
23 echo 'int main() { return 0; }' | ${CC} -x c ${CFLAGS} ${LDFLAGS} -o ${TEST_C_LD} - |
3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
Tassilo Philipp
parents:
569
diff
changeset
|
24 |
214 | 25 ${APP}: ${OBJS} |
567
a94b985f9a91
- test/dynload_plain fix for some sunos platforms
Tassilo Philipp
parents:
319
diff
changeset
|
26 ${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@ |
214 | 27 |
308 | 28 ${TEST_U8_SO}: |
571
996424e8a5fc
test/dynload_plain: use same CFLAGS to build UTF-8 path helper lib with as for main build (fixes building this helper lib w/ incompatible instruction set on some platforms)
Tassilo Philipp
parents:
570
diff
changeset
|
29 echo 'int dynload_plain_testfunc() { return 5; }' | ${CC} ${CFLAGS} -`[ \`uname\` = Darwin ] && echo dynamiclib || echo shared` -x c - -o ${TEST_U8_SO} |
663
127b569978cc
- another tweak handling clang trying to be too smart (see last commit)
Tassilo Philipp
parents:
662
diff
changeset
|
30 # clang tries to be too smart, appending .exe on some platforms (e.g. *nix based mingw cross builds), despite -o being explicity |
127b569978cc
- another tweak handling clang trying to be too smart (see last commit)
Tassilo Philipp
parents:
662
diff
changeset
|
31 [ -f "${TEST_U8_SO}.exe" ] && mv "${TEST_U8_SO}.exe" "${TEST_U8_SO}" || true |
308 | 32 |
214 | 33 clean: |
308 | 34 rm -f ${APP} ${OBJS} ${TEST_U8_SO} |
214 | 35 |