[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
make build fails when DESTDIR is set in -current, bsd.prog.mk patch
- To: bugs_(_at_)_openbsd_(_dot_)_org
- Subject: make build fails when DESTDIR is set in -current, bsd.prog.mk patch
- From: Rob Pickering <rob_(_at_)_pickering_(_dot_)_org>
- Date: Mon, 23 Sep 2002 19:08:25 +0100
- Reply-to: Rob Pickering <rob_(_at_)_pickering_(_dot_)_org>
I've noticed for quite a while now that a make build of the source
tree fails when DESTDIR is set to in order produce a clean release
tree, this is true in -current, but ISTR it was also the case in
OPENBSD_3_1.
It always fails for me in the link of the ld.so binary in
src/gnu/usr.sbin/ld.so. I finally got around to trying to work out
why and found that it wasn't crud in my source tree!
bsd.prog.mk uses a special linker line with -nostdlib and a specific
link of $DESTDIR/usr/lib/crt0.o etc to link the $DESTDIR rather than
system versions of the C runtime if $DESTDIR is set.
The link of ld.so doesn't want the C startup files, so specifies
-nostartfiles in LDFLAGS. bsd.prog.mk overrides this when $DESTDIR is
set and puts $DESTDIR/usr/lib/crt0.o on the linker line, which causes
linkage errors and the build to fail.
The patch below fixes this, and adds what I believe is a more
correctly "-nostartfiles" to LDFLAGS for the normal DESTDIR case.
--
Rob.
Index: bsd.prog.mk
===================================================================
RCS file: /cvs/src/share/mk/bsd.prog.mk,v
retrieving revision 1.33
diff -C3 -r1.33 bsd.prog.mk
*** bsd.prog.mk 2002/07/25 18:19:06 1.33
--- bsd.prog.mk 2002/09/23 17:55:33
***************
*** 111,120 ****
.endif
.if defined(OBJS) && !empty(OBJS)
.if defined(DESTDIR)
${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
! ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib
-L${DESTDIR}/usr/lib ${LIBCRT0} ${CRTBEGIN} ${OBJS} ${LDADD} -lgcc
-lc -lgcc ${CRTEND}
.else
--- 111,128 ----
.endif
.if defined(OBJS) && !empty(OBJS)
+
+ .if !empty(LDFLAGS:M-nostartfiles)
+
+ ${PROG}: ${OBJS} ${LIBC} ${DPADD}
+ ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
+
+ .else
+
.if defined(DESTDIR)
${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${CRTBEGIN} ${CRTEND} ${DPADD}
! ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostartfiles
-nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${CRTBEGIN} ${OBJS}
${LDADD} -lgcc -lc -lgcc ${CRTEND}
.else
***************
*** 122,127 ****
--- 130,136 ----
${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
.endif # defined(DESTDIR)
+ .endif # !empty(${LDFLAGS:M-nostartfiles})
.endif # defined(OBJS) && !empty(OBJS)
.if !defined(MAN)
Visit your host, monkey.org