build: fill in more details for freestanding builds

pull/21/head
Ariadne Conill 2020-12-06 03:31:48 -06:00
parent 2979186379
commit 0953d71ed1
4 changed files with 31 additions and 13 deletions

View File

@ -5,7 +5,7 @@ endif
LIBDIR := /lib LIBDIR := /lib
CFLAGS := -ggdb3 -O2 -Wall CFLAGS := -ggdb3 -O2 -Wall
CPPFLAGS := -Iarch/${ARCH} -Iarch/common CPPFLAGS := -Iinclude -Iarch/${ARCH} -Iarch/common
EXPORT_UNPREFIXED := yes EXPORT_UNPREFIXED := yes
FREESTANDING := no FREESTANDING := no
@ -28,13 +28,16 @@ LIBUCONTEXT_STATIC_NAME = libucontext.a
LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION} LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION}
LIBUCONTEXT_PATH = ${LIBDIR}/${LIBUCONTEXT_SONAME} LIBUCONTEXT_PATH = ${LIBDIR}/${LIBUCONTEXT_SONAME}
LIBUCONTEXT_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_STATIC_NAME} LIBUCONTEXT_STATIC_PATH = ${LIBDIR}/${LIBUCONTEXT_STATIC_NAME}
LIBUCONTEXT_HEADERS = \
include/libucontext/libucontext.h \
include/libucontext/bits.h
all: ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_STATIC_NAME} all: ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_STATIC_NAME}
${LIBUCONTEXT_STATIC_NAME}: ${LIBUCONTEXT_OBJ} ${LIBUCONTEXT_STATIC_NAME}: ${LIBUCONTEXT_OBJ}
$(AR) rcs ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_OBJ} $(AR) rcs ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_OBJ}
${LIBUCONTEXT_NAME}: ${LIBUCONTEXT_OBJ} ${LIBUCONTEXT_NAME}: ${LIBUCONTEXT_HEADERS} ${LIBUCONTEXT_OBJ}
$(CC) -o ${LIBUCONTEXT_NAME} -Wl,-soname,${LIBUCONTEXT_SONAME} \ $(CC) -o ${LIBUCONTEXT_NAME} -Wl,-soname,${LIBUCONTEXT_SONAME} \
-shared ${LIBUCONTEXT_OBJ} ${LDFLAGS} -shared ${LIBUCONTEXT_OBJ} ${LDFLAGS}
@ -62,4 +65,16 @@ check: test_libucontext ${LIBUCONTEXT_SONAME}
test_libucontext: test_libucontext.c ${LIBUCONTEXT_NAME} test_libucontext: test_libucontext.c ${LIBUCONTEXT_NAME}
$(CC) -std=c99 -D_BSD_SOURCE ${CFLAGS} ${CPPFLAGS} $@.c -o $@ -L. -lucontext $(CC) -std=c99 -D_BSD_SOURCE ${CFLAGS} ${CPPFLAGS} $@.c -o $@ -L. -lucontext
ifeq ($(FREESTANDING),no)
include/libucontext/bits.h: arch/common/bits.h
cp arch/common/bits.h $@
else
include/libucontext/bits.h: arch/${ARCH}/freestanding/bits.h
cp arch/${ARCH}/freestanding/bits.h
endif
.PHONY: check .PHONY: check

12
arch/common/bits.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef LIBUCONTEXT_BITS_H
#define LIBUCONTEXT_BITS_H
#ifndef FREESTANDING
#include <ucontext.h>
typedef ucontext_t libucontext_ucontext_t;
#endif
#endif

View File

@ -48,16 +48,7 @@ __proc: \
#ifndef LIBUCONTEXT_ASSEMBLY #ifndef LIBUCONTEXT_ASSEMBLY
#ifndef FREESTANDING #include <libucontext/libucontext.h>
typedef ucontext_t libucontext_ucontext_t;
#endif
int libucontext_getcontext(libucontext_ucontext_t *);
void libucontext_makecontext(libucontext_ucontext_t *, void (*)(), int, ...);
int libucontext_setcontext(const libucontext_ucontext_t *);
int libucontext_swapcontext(libucontext_ucontext_t *, const libucontext_ucontext_t *);
#endif #endif

View File

@ -24,7 +24,7 @@ extern void libucontext_trampoline(void);
void void
libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) libucontext_makecontext(libucontext_ucontext_t *ucp, void (*func)(void), int argc, ...)
{ {
greg_t *sp; greg_t *sp;
va_list va; va_list va;