-# $OpenBSD: Makefile,v 1.18 2021/06/02 07:32:34 semarie Exp $
+# $OpenBSD: Makefile,v 1.19 2022/08/20 14:13:48 sthen Exp $
SUBDIR+= elf hidden weak dlsym dlopen dlclose lazy
SUBDIR+= constructor
SUBDIR+= link-order edgecases initfirst
SUBDIR+= df_1_noopen randomdata subst dependencies
-SUBDIR+= init-env nodelete
+SUBDIR+= init-env nodelete noload
install:
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+SUBDIR += liba libb test1
+
+.include <bsd.subdir.mk>
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+LIB = a
+SRCS = liba.c
+
+regress: all
+
+.include <bsd.lib.mk>
+
--- /dev/null
+void
+functiona(void)
+{
+}
--- /dev/null
+major=0
+minor=0
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+LIB = b
+SRCS = libb.c
+
+regress: all
+
+.include <bsd.lib.mk>
+
--- /dev/null
+void
+functionb(void)
+{
+}
--- /dev/null
+major=0
+minor=0
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2022/08/20 14:13:48 sthen Exp $
+
+.include <bsd.obj.mk>
+
+PROG = test1
+
+LIBADIR != if test -d ${.CURDIR}/../liba/${__objdir}; then \
+ echo "${.CURDIR}/../liba/${__objdir}"; \
+ else \
+ echo "${.CURDIR}/../liba"; \
+ fi
+
+LIBBDIR != if test -d ${.CURDIR}/../libb/${__objdir}; then \
+ echo "${.CURDIR}/../libb/${__objdir}"; \
+ else \
+ echo "${.CURDIR}/../libb"; \
+ fi
+
+LIBANAME = ${LIBADIR}/liba.so.0.0
+LIBBNAME = ${LIBBDIR}/libb.so.0.0
+
+CFLAGS += -DLIBANAME=\"${LIBANAME}\" \
+ -DLIBBNAME=\"${LIBBNAME}\"
+
+REGRESS_TARGETS += run-regress
+
+run-regress: ${PROG}
+ if ./${PROG} | grep found; then echo failed; exit 1; fi
+ LD_PRELOAD=${LIBANAME} ./${PROG} | grep ${LIBANAME}.found
+ LD_PRELOAD=${LIBBNAME} ./${PROG} | grep ${LIBBNAME}.found
+
+.include <bsd.regress.mk>
--- /dev/null
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef LIBANAME
+#error "LIBANAME undefined"
+#endif
+
+#ifndef LIBBNAME
+#error "LIBBNAME undefined"
+#endif
+
+int
+main(int argc, char *argv[])
+{
+ void *handle;
+
+ printf("opening\n");
+ if ((handle = dlopen(LIBANAME, RTLD_NOW|RTLD_NOLOAD)))
+ printf("%s found\n", LIBANAME);
+ else if ((handle = dlopen(LIBBNAME, RTLD_NOW|RTLD_NOLOAD)))
+ printf("%s found\n", LIBBNAME);
+
+ return 0;
+}