-# $OpenBSD: Makefile,v 1.72 2018/01/30 20:15:25 otto Exp $
+# $OpenBSD: Makefile,v 1.73 2018/08/29 15:56:46 robert Exp $
SUBDIR=ldconfig ldd
MAN= ld.so.1
issetugid mprotect munmap open pledge read readlink sendsyslog \
__set_tcb sysctl thrkill utrace write
+GEN_PREFIX=\t.file "${@:R}.c"\n\#include "SYS.h"
.for _i in ${syscall}
OBJS+=dl_${_i}.o
dl_${_i}.o: SYS.h
- printf '#include "SYS.h"\nDL_SYSCALL(${_i})\n' | \
+ printf '${GEN_PREFIX}\nDL_SYSCALL(${_i})\n' | \
${CC} ${DEBUG} -c -fPIC ${CFLAGS:M-[ID]*} ${CFLAGS:M-pipe} ${AINC} -P \
-x assembler-with-cpp - ${DFLAGS} -MF ${.TARGET:R}.d -o ${.TARGET}
.endfor
$(test_prog):
printf '#include <stdio.h>\nint main(int argc, char **argv){ printf("%%s: ", argv[0]); printf("%%s!\\n", argv[1] ? argv[1] : "foo"); }\n' | \
- $(CC) -x c - -Wl,-dynamic-linker,./$(candidate) -o $@
+ $(CC) -P -x c - -Wl,-dynamic-linker,./$(candidate) -o $@
$(PROG): $(test_prog) ${VERSION_SCRIPT} $(OBJS)
- $(LD) ${DEBUG} -x -e _dl_start $(ELF_LDFLAGS) -o $(candidate) \
+.if defined(SYSPATCH_PATH)
+ $(LD) ${DEBUG} -e _dl_start $(ELF_LDFLAGS) -o $(candidate) \
+ `readelf -Ws ${SYSPATCH_PATH}/usr/libexec/${.TARGET} | \
+ awk '/ FILE/{sub(".*/", "", $$NF); gsub(/\..*/, ".o", $$NF); print $$NF}' | \
+ awk '!x[$$0]++'`
+.else
+ $(LD) ${DEBUG} -e _dl_start $(ELF_LDFLAGS) -o $(candidate) \
`echo ${OBJS} | tr " " "\n" | sort -R`
+.endif
.ifndef CROSSDIR
ulimit -c 0; [ "`${.OBJDIR}/$(test_prog) ok`" = "${.OBJDIR}/$(test_prog): ok!" ]
.endif