libandroid-posix-semaphore: pass PREFIX as compiler flag

This commit is contained in:
Henrik Grimler 2022-02-11 11:15:02 +01:00
parent b26410dd57
commit a67899c977
No known key found for this signature in database
GPG Key ID: B0076E490B71616B
2 changed files with 7 additions and 2 deletions

View File

@ -7,7 +7,8 @@ TERMUX_PKG_SKIP_SRC_EXTRACT=true
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_make() {
$CC $CFLAGS $CPPFLAGS -I$TERMUX_PKG_BUILDER_DIR -c $TERMUX_PKG_BUILDER_DIR/semaphore.c
$CC $CFLAGS $CPPFLAGS -DPREFIX="\"$TERMUX_PREFIX\"" \
-c $TERMUX_PKG_BUILDER_DIR/semaphore.c
$CC $LDFLAGS -shared semaphore.o -o libandroid-posix-semaphore.so
$AR rcu libandroid-posix-semaphore.a semaphore.o
cp -f $TERMUX_PKG_BUILDER_DIR/LICENSE $TERMUX_PKG_SRCDIR/

View File

@ -43,6 +43,10 @@
#define SEM_NSEMS_MAX 256
#endif // !SEM_NSEMS_MAX
#ifndef PREFIX
#define PREFIX "/data/data/com.termux/files/usr"
#endif
static __inline__ char *__strchrnul(const char *s, int c)
{
c = (unsigned char)c;
@ -78,7 +82,7 @@ static char *__sem_mapname(const char *name, char *buf)
errno = ENAMETOOLONG;
return 0;
}
memcpy(buf, "/data/data/com.termux/files/usr/tmp/sem.", 40);
memcpy(buf, PREFIX"/tmp/sem.", 40);
memcpy(buf+40, name, p-name+1);
return buf;
}