summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile39
1 files changed, 27 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 934422f..6a36129 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
LIBGCOMPAT_INCLUDE = \
- libgcompat/alias.h
+ libgcompat/alias.h \
+ libgcompat/internal.h
LIBGCOMPAT_SRC = \
libgcompat/ctype.c \
libgcompat/cxx_thread.c \
@@ -43,36 +44,50 @@ LOADER_OBJ = ${LOADER_SRC:.c=.o}
LOADER_NAME = ld-linux.so.2
LOADER_PATH = /lib/${LOADER_NAME}
-ifdef WITH_LIBUCONTEXT
+PKG_CONFIG ?= pkg-config
-LIBUCONTEXT_LIBS = -Wl,--no-as-needed -lucontext
+ifdef WITH_LIBUCONTEXT
LIBUCONTEXT_CFLAGS = -DWITH_LIBUCONTEXT
+LIBUCONTEXT_LIBS = -lucontext
+endif
+
+ifndef WITH_OBSTACK
+WITH_OBSTACK = $(shell \
+ for pkg in obstack obstack-standalone; do \
+ ${PKG_CONFIG} --exists "$$pkg" && { echo "$$pkg"; exit 0; } \
+ done; echo "no")
+endif
+ifneq (${WITH_OBSTACK},no)
+OBSTACK_CFLAGS = $(shell ${PKG_CONFIG} --cflags ${WITH_OBSTACK}) -DWITH_OBSTACK
+OBSTACK_LIBS = $(shell ${PKG_CONFIG} --libs ${WITH_OBSTACK})
endif
all: ${LIBGCOMPAT_NAME} ${LOADER_NAME}
${LIBGCOMPAT_NAME}: ${LIBGCOMPAT_OBJ}
- $(CC) -o ${LIBGCOMPAT_NAME} -Wl,-soname,${LIBGCOMPAT_NAME} \
- -shared ${LIBGCOMPAT_OBJ} ${LIBUCONTEXT_LIBS}
+ ${CC} ${CFLAGS} ${LDFLAGS} -shared -Wl,-soname,${LIBGCOMPAT_NAME} \
+ -o ${LIBGCOMPAT_NAME} ${LIBGCOMPAT_OBJ} \
+ -Wl,--no-as-needed ${LIBUCONTEXT_LIBS} ${OBSTACK_LIBS}
${LIBGCOMPAT_OBJ}: ${LIBGCOMPAT_INCLUDE}
${LOADER_NAME}: ${LOADER_OBJ}
- $(CC) -o ${LOADER_NAME} -fPIE -static ${LOADER_OBJ}
+ ${CC} ${CFLAGS} ${LDFLAGS} -static-pie -o ${LOADER_NAME} ${LOADER_OBJ}
.c.o:
- $(CC) -c -D_BSD_SOURCE -DLIBGCOMPAT=\"${LIBGCOMPAT_PATH}\" \
- -DLINKER=\"${LINKER_PATH}\" -DLOADER=\"${LOADER_NAME}\" \
- -Ilibgcompat ${LIBUCONTEXT_CFLAGS} \
- -fPIC -std=c99 -Wall -Wextra -Wno-frame-address \
- -Wno-unused-parameter ${CFLAGS} ${CPPFLAGS} -o $@ $<
+ ${CC} ${CPPFLAGS} ${CFLAGS} -c -D_BSD_SOURCE \
+ -DLIBGCOMPAT='"${LIBGCOMPAT_PATH}"' \
+ -DLINKER='"${LINKER_PATH}"' -DLOADER='"${LOADER_NAME}"' \
+ -fPIC -Ilibgcompat -std=c99 \
+ -Wall -Wextra -Wno-frame-address -Wno-unused-parameter \
+ ${LIBUCONTEXT_CFLAGS} ${OBSTACK_CFLAGS} -o $@ $<
clean:
rm -f libgcompat/*.o loader/*.o ${LIBGCOMPAT_NAME} ${LOADER_NAME}
format:
- clang-format -i ${LIBGCOMPAT_SRC} ${LOADER_SRC}
+ clang-format -i ${LIBGCOMPAT_INCLUDE} ${LIBGCOMPAT_SRC} ${LOADER_SRC}
install: all
install -D -m755 ${LIBGCOMPAT_NAME} ${DESTDIR}/${LIBGCOMPAT_PATH}