ucontext implementation featuring glibc-compatible ABI

Makefile 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ARCH := $(shell uname -m)
  2. CFLAGS = -ggdb3 -O2 -Wall -Iarch/${ARCH}
  3. LIBUCONTEXT_C_SRC = \
  4. arch/${ARCH}/makecontext.c
  5. LIBUCONTEXT_S_SRC = \
  6. arch/${ARCH}/getcontext.S \
  7. arch/${ARCH}/setcontext.S \
  8. arch/${ARCH}/swapcontext.S \
  9. arch/${ARCH}/startcontext.S
  10. LIBUCONTEXT_OBJ = ${LIBUCONTEXT_C_SRC:.c=.o} ${LIBUCONTEXT_S_SRC:.S=.o}
  11. LIBUCONTEXT_SOVERSION = 0
  12. LIBUCONTEXT_NAME = libucontext.so
  13. LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION}
  14. LIBUCONTEXT_PATH = /lib/${LIBUCONTEXT_SONAME}
  15. all: ${LIBUCONTEXT_SONAME}
  16. ${LIBUCONTEXT_NAME}: ${LIBUCONTEXT_OBJ}
  17. $(CC) -o ${LIBUCONTEXT_NAME} -Wl,-soname,${LIBUCONTEXT_SONAME} \
  18. -shared ${LIBUCONTEXT_OBJ}
  19. ${LIBUCONTEXT_SONAME}: ${LIBUCONTEXT_NAME}
  20. ln -sf ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_SONAME}
  21. .c.o:
  22. $(CC) -std=c99 -D_BSD_SOURCE -fPIC -DPIC ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
  23. .S.o:
  24. $(CC) -fPIC -DPIC ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
  25. clean:
  26. rm -f ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_OBJ} test_libucontext
  27. install: all
  28. install -D -m755 ${LIBUCONTEXT_NAME} ${DESTDIR}/${LIBUCONTEXT_PATH}
  29. ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}/lib/${LIBUCONTEXT_NAME}
  30. check: test_libucontext ${LIBUCONTEXT_SONAME}
  31. env LD_LIBRARY_PATH=$(shell pwd) ./test_libucontext
  32. test_libucontext: test_libucontext.c ${LIBUCONTEXT_NAME}
  33. $(CC) -std=c99 -D_BSD_SOURCE ${CFLAGS} ${CPPFLAGS} $@.c -o $@ -L. -lucontext
  34. .PHONY: check