first, avoid include <endian.h> which is not found on macOS, fixes:
g++ -DHAVE_CONFIG_H -I. -I../.. -I../../include -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/usr/local/include -g -O2 -Wall -mmmx -msse -msse2 -D_FILE_OFFSET_BITS=64 -Wno-strict-aliasing -std=gnu++11 -c -o callback.o callback.cpp
In file included from callback.cpp:24:
In file included from ../../include/callback.h:24:
../../include/mem.h:34:11: fatal error: 'endian.h' file not found
# include <endian.h>
next, map some missing functions to macOS eqivalents, based on
https://gist.github.com/yinyin/2027912, fixes:
../../include/mem.h:115:9: error: use of undeclared identifier 'le16toh'
return le16toh((*(Bit16u *)off)); // BSD endian.h
^
../../include/mem.h:118:9: error: use of undeclared identifier 'le32toh'
return le32toh((*(Bit32u *)off)); // BSD endian.h
^
../../include/mem.h:121:9: error: use of undeclared identifier 'le64toh'
return le64toh((*(Bit64u *)off)); // BSD endian.h
^
../../include/mem.h:128:21: error: use of undeclared identifier 'htole16'
*(Bit16u *)(off) = htole16(val);
^
../../include/mem.h:131:21: error: use of undeclared identifier 'htole32'
*(Bit32u *)(off) = htole32(val);
^
../../include/mem.h:134:21: error: use of undeclared identifier 'htole64'
*(Bit64u *)(off) = htole64(val);
^