Mercurial > pub > dyncall > dyncall
comparison test/dynload_plain/Makefile.embedded @ 570:3155ccc33cae
- test/dynload_plain: simplify makefile based build by deducing default c lib to test with from a simple helper build
author | Tassilo Philipp |
---|---|
date | Sun, 04 Sep 2022 15:57:28 +0200 |
parents | 7e00c173519d |
children | 996424e8a5fc |
comparison
equal
deleted
inserted
replaced
569:7e00c173519d | 570:3155ccc33cae |
---|---|
1 # path to default libc.so file, easier to do via shell than in code (see main() in dynload_plain.c) | |
2 # for compat: first gmake style, then assignment op which will use ! as part of var name on gmake<4 | |
3 # and thus not override previously set var; in a similar vein, the :sh line works on | |
4 # sun make flavors and sets the var using sunOS specific deduction if not already set | |
5 # (:sh also works on bmake, but != already sets the var) | |
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) | |
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 | |
8 DEF_C_DYLIB:sh=[ -z "${DEF_C_DYLIB}" ] && ls /lib/`isainfo -b`/libc.so || echo "${DEF_C_DYLIB}" | |
9 | |
10 APP = dynload_plain | 1 APP = dynload_plain |
11 OBJS = dynload_plain.o | 2 OBJS = dynload_plain.o |
12 TEST_U8_SO = dynload_plain_ß_test # @@@ unsure if every platform handles ß, here (ANSI, UTF-8, ...) | 3 TEST_U8_SO = dynload_plain_ß_test # @@@ unsure if every platform handles ß, here (ANSI, UTF-8, ...) |
13 | 4 |
14 TOP = ../.. | 5 TOP = ../.. |
16 LDFLAGS += -L${TOP}/dynload | 7 LDFLAGS += -L${TOP}/dynload |
17 LDLIBS += -ldynload_s | 8 LDLIBS += -ldynload_s |
18 # Works on: Darwin, NetBSD. | 9 # Works on: Darwin, NetBSD. |
19 # Linux: add '-ldl' | 10 # Linux: add '-ldl' |
20 | 11 |
21 all: ${APP} ${TEST_U8_SO} | 12 all: ${TEST_C_LD} ${TEST_U8_SO} |
13 # deduce path to default libc.so file, easier to do via shell than in code | |
14 # (see main() in dynload_plain.c); get from what ${TEST_C_LD} is linked | |
15 # against, then reinvoke make with actual build | |
16 export X=`((ldd ${TEST_C_LD} | 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`; \ | |
17 ${MAKE} DEF_C_DYLIB="$$X" ${APP} | |
22 | 18 |
23 .PHONY: all clean | 19 .PHONY: all clean |
20 | |
21 ${TEST_C_LD}: | |
22 # dummy bin built with same toolchain and flags to deduce default c lib this is linked with | |
23 echo 'int main() { return 0; }' | ${CC} -x c ${CFLAGS} ${LDFLAGS} -o ${TEST_C_LD} - | |
24 | 24 |
25 ${APP}: ${OBJS} | 25 ${APP}: ${OBJS} |
26 ${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@ | 26 ${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@ |
27 | 27 |
28 ${TEST_U8_SO}: | 28 ${TEST_U8_SO}: |