libucontext/Makefile

53 lines
1.7 KiB
Makefile
Raw Normal View History

2018-01-31 05:58:26 +00:00
ARCH := $(shell uname -m)
2019-09-18 14:54:53 +00:00
ifeq ($(ARCH),$(filter $(ARCH),i386 i686))
override ARCH = x86
endif
2018-01-30 03:41:02 +00:00
2018-01-31 20:37:00 +00:00
CFLAGS = -ggdb3 -O2 -Wall -Iarch/${ARCH}
2018-01-30 03:41:02 +00:00
LIBUCONTEXT_C_SRC = $(wildcard arch/${ARCH}/*.c)
LIBUCONTEXT_S_SRC = $(wildcard arch/${ARCH}/*.S)
LIBUCONTEXT_OBJ = ${LIBUCONTEXT_C_SRC:.c=.o} ${LIBUCONTEXT_S_SRC:.S=.o}
LIBUCONTEXT_SOVERSION = 0
2018-01-30 03:53:04 +00:00
LIBUCONTEXT_NAME = libucontext.so
2019-04-09 13:07:39 +00:00
LIBUCONTEXT_STATIC_NAME = libucontext.a
2018-01-30 03:53:04 +00:00
LIBUCONTEXT_SONAME = libucontext.so.${LIBUCONTEXT_SOVERSION}
LIBUCONTEXT_PATH = /lib/${LIBUCONTEXT_SONAME}
LIBUCONTEXT_STATIC_PATH = /lib/${LIBUCONTEXT_STATIC_NAME}
2019-04-09 13:07:39 +00:00
all: ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_STATIC_NAME}
${LIBUCONTEXT_STATIC_NAME}: ${LIBUCONTEXT_OBJ}
$(AR) rcs ${LIBUCONTEXT_STATIC_NAME} ${LIBUCONTEXT_OBJ}
${LIBUCONTEXT_NAME}: ${LIBUCONTEXT_OBJ}
2018-01-30 03:53:04 +00:00
$(CC) -o ${LIBUCONTEXT_NAME} -Wl,-soname,${LIBUCONTEXT_SONAME} \
-shared ${LIBUCONTEXT_OBJ}
2018-01-30 03:53:04 +00:00
${LIBUCONTEXT_SONAME}: ${LIBUCONTEXT_NAME}
ln -sf ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_SONAME}
.c.o:
$(CC) -std=c99 -D_BSD_SOURCE -fPIC -DPIC ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
.S.o:
$(CC) -fPIC -DPIC ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
clean:
rm -f ${LIBUCONTEXT_NAME} ${LIBUCONTEXT_SONAME} ${LIBUCONTEXT_STATIC_NAME} \
${LIBUCONTEXT_OBJ} test_libucontext
install: all
install -D -m755 ${LIBUCONTEXT_NAME} ${DESTDIR}/${LIBUCONTEXT_PATH}
install -D -m664 ${LIBUCONTEXT_STATIC_NAME} ${DESTDIR}/${LIBUCONTEXT_STATIC_PATH}
2018-01-30 03:53:04 +00:00
ln -sf ${LIBUCONTEXT_SONAME} ${DESTDIR}/lib/${LIBUCONTEXT_NAME}
check: test_libucontext ${LIBUCONTEXT_SONAME}
env LD_LIBRARY_PATH=$(shell pwd) ./test_libucontext
2018-01-30 03:53:04 +00:00
test_libucontext: test_libucontext.c ${LIBUCONTEXT_NAME}
$(CC) -std=c99 -D_BSD_SOURCE ${CFLAGS} ${CPPFLAGS} $@.c -o $@ -L. -lucontext
2018-01-30 03:53:04 +00:00
.PHONY: check