annotate test/dynload_plain/Makefile.embedded @ 569:7e00c173519d

- test/dynload_plain: make build deduce native libc to use for testing from more elemental tool (using [(1) now instead of ls(1), reason is that on some x64 sunos platforms, ls is 32bit; yes, hacky fix)
author Tassilo Philipp
date Sun, 04 Sep 2022 15:28:13 +0200
parents 4a3fab7712fb
children 3155ccc33cae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
1 # path to default libc.so file, easier to do via shell than in code (see main() in dynload_plain.c)
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
2 # for compat: first gmake style, then assignment op which will use ! as part of var name on gmake<4
568
4a3fab7712fb - test/dynload_plain: fix on some sunos platforms selecting libc to test
Tassilo Philipp
parents: 567
diff changeset
3 # and thus not override previously set var; in a similar vein, the :sh line works on
4a3fab7712fb - test/dynload_plain: fix on some sunos platforms selecting libc to test
Tassilo Philipp
parents: 567
diff changeset
4 # sun make flavors and sets the var using sunOS specific deduction if not already set
4a3fab7712fb - test/dynload_plain: fix on some sunos platforms selecting libc to test
Tassilo Philipp
parents: 567
diff changeset
5 # (:sh also works on bmake, but != already sets the var)
569
7e00c173519d - test/dynload_plain: make build deduce native libc to use for testing from more elemental tool (using [(1) now instead of ls(1), reason is that on some x64 sunos platforms, ls is 32bit; yes, hacky fix)
Tassilo Philipp
parents: 568
diff changeset
6 DEF_C_DYLIB=$(shell ((ldd `which [` | grep -o '/.*/libc.so[^ ]*' || 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)
7e00c173519d - test/dynload_plain: make build deduce native libc to use for testing from more elemental tool (using [(1) now instead of ls(1), reason is that on some x64 sunos platforms, ls is 32bit; yes, hacky fix)
Tassilo Philipp
parents: 568
diff changeset
7 DEF_C_DYLIB!=((ldd `which [` | grep -o '/.*/libc.so[^ ]*' || 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
568
4a3fab7712fb - test/dynload_plain: fix on some sunos platforms selecting libc to test
Tassilo Philipp
parents: 567
diff changeset
8 DEF_C_DYLIB:sh=[ -z "${DEF_C_DYLIB}" ] && ls /lib/`isainfo -b`/libc.so || echo "${DEF_C_DYLIB}"
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
9
214
Tassilo Philipp
parents:
diff changeset
10 APP = dynload_plain
Tassilo Philipp
parents:
diff changeset
11 OBJS = dynload_plain.o
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
12 TEST_U8_SO = dynload_plain_ß_test # @@@ unsure if every platform handles ß, here (ANSI, UTF-8, ...)
214
Tassilo Philipp
parents:
diff changeset
13
Tassilo Philipp
parents:
diff changeset
14 TOP = ../..
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
15 CFLAGS += -I${TOP}/dynload -DDEF_C_DYLIB=\"${DEF_C_DYLIB}\"
214
Tassilo Philipp
parents:
diff changeset
16 LDFLAGS += -L${TOP}/dynload
Tassilo Philipp
parents:
diff changeset
17 LDLIBS += -ldynload_s
Tassilo Philipp
parents:
diff changeset
18 # Works on: Darwin, NetBSD.
Tassilo Philipp
parents:
diff changeset
19 # Linux: add '-ldl'
Tassilo Philipp
parents:
diff changeset
20
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
21 all: ${APP} ${TEST_U8_SO}
214
Tassilo Philipp
parents:
diff changeset
22
Tassilo Philipp
parents:
diff changeset
23 .PHONY: all clean
Tassilo Philipp
parents:
diff changeset
24
Tassilo Philipp
parents:
diff changeset
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
Tassilo Philipp
parents:
diff changeset
27
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
28 ${TEST_U8_SO}:
319
993550558ac5 - test/dynload_plain build fix for Darwin cc (use flag -dynamiclib instead of -shared to build test .dylib)
Tassilo Philipp
parents: 313
diff changeset
29 echo 'int dynload_plain_testfunc() { return 5; }' | ${CC} -`[ \`uname\` = Darwin ] && echo dynamiclib || echo shared` -x c - -o ${TEST_U8_SO}
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
30
214
Tassilo Philipp
parents:
diff changeset
31 clean:
308
7c6f19d42b31 dynload UTF-8 support for library paths:
Tassilo Philipp
parents: 214
diff changeset
32 rm -f ${APP} ${OBJS} ${TEST_U8_SO}
214
Tassilo Philipp
parents:
diff changeset
33