| 
29
 | 
     1 #from dynload test
 | 
| 
 | 
     2 ## path to default libc.so file, easier to do via shell than in code (see main() in dynload_plain.c)
 | 
| 
 | 
     3 ## for compat: first gmake style, then assignment op which will use ! as part of var name on gmake<4
 | 
| 
 | 
     4 ##             and thus not override previously set var
 | 
| 
 | 
     5 #DEF_C_DYLIB=$(shell ((ldd `which ls` | 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)
 | 
| 
 | 
     6 #DEF_C_DYLIB!=((ldd `which ls` | 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 #
 | 
| 
 | 
     8 #APP        = dynload_plain
 | 
| 
 | 
     9 #OBJS       = dynload_plain.o
 | 
| 
 | 
    10 #TEST_U8_SO = dynload_plain_ß_test # @@@ unsure if every platform handles ß, here (ANSI, UTF-8, ...)
 | 
| 
 | 
    11 #SRCTOP     = ${VPATH}/../..
 | 
| 
 | 
    12 #BLDTOP     = ../..
 | 
| 
 | 
    13 #CFLAGS    += -I${SRCTOP}/dynload -DDEF_C_DYLIB=\"${DEF_C_DYLIB}\"
 | 
| 
 | 
    14 #LDLIBS_D  += -L${BLDTOP}/dynload -ldynload_s
 | 
| 
 | 
    15 #
 | 
| 
 | 
    16 ## Works on: Darwin, NetBSD.
 | 
| 
 | 
    17 # Linux: add '-ldl'
 | 
| 
 | 
    18 #.PHONY: all clean install
 | 
| 
 | 
    19 #all: ${APP} ${TEST_U8_SO}
 | 
| 
 | 
    20 #${APP}: ${OBJS}
 | 
| 
 | 
    21 #	${CC} ${LDFLAGS} ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP}
 | 
| 
 | 
    22 #${TEST_U8_SO}:
 | 
| 
 | 
    23 #	echo 'int dynload_plain_testfunc() { return 5; }' | ${CC} -`[ \`uname\` = Darwin ] && echo dynamiclib || echo shared` -x c - -o ${TEST_U8_SO}
 | 
| 
 | 
    24 #clean:
 | 
| 
 | 
    25 #	rm -f ${APP} ${OBJS} ${TEST_U8_SO}
 | 
| 
 | 
    26 #install:
 | 
| 
 | 
    27 #	mkdir -p ${PREFIX}/test
 | 
| 
 | 
    28 #	cp ${APP} ${TEST_U8_SO} ${PREFIX}/test
 | 
| 
 | 
    29 
 | 
| 
 | 
    30 .PHONY: test.so
 | 
| 
 | 
    31 
 | 
| 
 | 
    32 test.so:
 | 
| 
 | 
    33 	for i in char 'unsigned char' short 'unsigned short' int 'unsigned int' long 'unsigned long' 'long long' 'unsigned long long' float double 'const char*'; do \
 | 
| 
 | 
    34 		echo "$$i `echo $$i | sed -E 's/(^| )([a-z])[^ ]*/\2/g'`_plus_one($$i v) { return v+1; }"; \
 | 
| 
 | 
    35 	done | ${CC} -`[ \`uname\` = Darwin ] && echo dynamiclib || echo shared` -x c - -o $@
 | 
| 
 | 
    36 	echo Done! Now you can run types.py
 | 
| 
 | 
    37 
 |