Hash :
1b7ff817
Author :
Thomas de Grivel
Date :
2025-07-05T15:11:33
wip linux build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#!/bin/sh
set -e
CONFIGURE_H=configure.h.tmp
CONFIGURE_MK=configure.mk.tmp
echo "// generated by ./configure" > ${CONFIGURE_H}
echo "#ifndef CONFIGURE_H" >> ${CONFIGURE_H}
echo "#define CONFIGURE_H" >> ${CONFIGURE_H}
echo "# generated by ./configure" > ${CONFIGURE_MK}
if [ "x$CC" = "x" ]; then
if which cc >/dev/null 2>&1; then
CC=cc
elif which gcc >/dev/null 2>&1; then
CC=gcc
else
CC=cc
fi
fi
echo "CC = ${CC}" >> ${CONFIGURE_MK}
configure_sizeof_long() {
OUT_C=".configure_sizeof_long.c"
OUT=".configure_sizeof_long"
echo "// gen by configure" > ${OUT_C}
echo "#include <stdio.h>" >> ${OUT_C}
echo "int main (void) {" >> ${OUT_C}
echo " printf(\"%lu\", sizeof(long));" >> ${OUT_C}
echo " return 0;" >> ${OUT_C}
echo "}" >> ${OUT_C}
${CC} ${CPPFLAGS} ${CFLAGS} ${OUT_C} -o ${OUT}
SIZEOF_LONG=$(./${OUT})
echo "#define CONFIGURE_SIZEOF_LONG ${SIZEOF_LONG}" >> ${CONFIGURE_H}
if [ "x${SIZEOF_LONG}" = "x4" ]; then
echo "#define CONFIGURE_FMT_INT64 \"%lld\"" >> ${CONFIGURE_H}
echo "#define CONFIGURE_FMT_UINT64 \"%llu\"" >> ${CONFIGURE_H}
elif [ "x${SIZEOF_LONG}" = "x8" ]; then
echo "#define CONFIGURE_FMT_INT64 \"%ld\"" >> ${CONFIGURE_H}
echo "#define CONFIGURE_FMT_UINT64 \"%lu\"" >> ${CONFIGURE_H}
fi
rm -f ${OUT} ${OUT_C}
}
update_configure_h() {
echo "#endif // CONFIGURE_H" >> ${CONFIGURE_H}
if [ -f configure.h ] && diff configure.h "${CONFIGURE_H}"; then
rm "${CONFIGURE_H}"
else
echo "${PWD}/configure.h"
mv "${CONFIGURE_H}" configure.h
fi
}
update_configure_mk() {
if [ -f configure.mk ] && diff configure.mk "${CONFIGURE_MK}"; then
rm "${CONFIGURE_MK}"
else
echo "${PWD}/configure.mk"
mv "${CONFIGURE_MK}" configure.mk
fi
}