diff --git a/bin/csh/Makefile b/bin/csh/Makefile index e3df1d464193..51ef3dd9c306 100644 --- a/bin/csh/Makefile +++ b/bin/csh/Makefile @@ -93,7 +93,7 @@ GENHDRS+= iconv.h SRCS+= iconv_stub.c iconv.h: ${.CURDIR}/iconv_stub.h - cp -f ${.CURDIR}/iconv_stub.h ${.TARGET} + ${CP} ${.CURDIR}/iconv_stub.h ${.TARGET} .endif .endif diff --git a/etc/mail/Makefile b/etc/mail/Makefile index 510b0243f984..f8e5b7759c62 100644 --- a/etc/mail/Makefile +++ b/etc/mail/Makefile @@ -69,7 +69,7 @@ SENDMAIL_MC!= hostname SENDMAIL_MC:= ${SENDMAIL_MC}.mc ${SENDMAIL_MC}: - cp -f freebsd.mc ${SENDMAIL_MC} + ${CP} freebsd.mc ${SENDMAIL_MC} .endif .ifndef SENDMAIL_SUBMIT_MC @@ -77,7 +77,7 @@ SENDMAIL_SUBMIT_MC!= hostname SENDMAIL_SUBMIT_MC:= ${SENDMAIL_SUBMIT_MC}.submit.mc ${SENDMAIL_SUBMIT_MC}: - cp -f freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} + ${CP} freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} .endif INSTALL_CF= ${SENDMAIL_MC:R}.cf diff --git a/gnu/usr.bin/grep/Makefile b/gnu/usr.bin/grep/Makefile index ebdb32776fc2..93c7324ea863 100644 --- a/gnu/usr.bin/grep/Makefile +++ b/gnu/usr.bin/grep/Makefile @@ -43,7 +43,7 @@ MLINKS+=grep.1 zgrep.1 grep.1 zegrep.1 grep.1 zfgrep.1 .endif gnugrep.1: grep.1 - cp ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} check: all @failed=0; total=0; \ diff --git a/kerberos5/lib/libasn1/Makefile b/kerberos5/lib/libasn1/Makefile index d445b8b386d4..3d65eee40560 100644 --- a/kerberos5/lib/libasn1/Makefile +++ b/kerberos5/lib/libasn1/Makefile @@ -111,10 +111,10 @@ ${GEN_KX509}: kx509.asn1 .SUFFIXES: .h .c .x .hx .x.c: - cp -f ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .hx.h: - cp -f ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .include diff --git a/kerberos5/lib/libgssapi_spnego/Makefile b/kerberos5/lib/libgssapi_spnego/Makefile index 92168082b417..5e54e95f7e93 100644 --- a/kerberos5/lib/libgssapi_spnego/Makefile +++ b/kerberos5/lib/libgssapi_spnego/Makefile @@ -45,10 +45,10 @@ ${GEN}: spnego.asn1 spnego.opt .SUFFIXES: .h .c .x .hx .x.c: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .hx.h: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .include diff --git a/kerberos5/lib/libhdb/Makefile b/kerberos5/lib/libhdb/Makefile index 1f99fc451731..2b178b2445f5 100644 --- a/kerberos5/lib/libhdb/Makefile +++ b/kerberos5/lib/libhdb/Makefile @@ -91,10 +91,10 @@ ${GEN}: hdb.asn1 .SUFFIXES: .h .c .x .hx .x.c: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .hx.h: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .include diff --git a/kerberos5/lib/libhx509/Makefile b/kerberos5/lib/libhx509/Makefile index 66e456d88cc9..29c45e2462a4 100644 --- a/kerberos5/lib/libhx509/Makefile +++ b/kerberos5/lib/libhx509/Makefile @@ -285,10 +285,10 @@ ${GEN_CRMF}: crmf.asn1 .SUFFIXES: .h .c .x .hx .x.c: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .hx.h: - cp ${.IMPSRC} ${.TARGET} + ${CP} ${.IMPSRC} ${.TARGET} .include diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 906ace132f70..eed907011948 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -149,11 +149,11 @@ KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ libkern: libkern.gen libkern.${LIBC_ARCH} libkern.gen: ${KQSRCS} ${KSRCS} - cp -fp ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern + ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern libkern.${LIBC_ARCH}:: ${KMSRCS} .if defined(KMSRCS) && !empty(KMSRCS) - cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} + ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} .endif .if ${MK_SYSCALL_COMPAT} != "no" diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile index 523a74eacb80..0d4bef55e2f3 100644 --- a/lib/libexpat/Makefile +++ b/lib/libexpat/Makefile @@ -28,6 +28,6 @@ bsdxml.h: expat.h > ${.TARGET} bsdxml_external.h: expat_external.h - cp -f ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} .include diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile index 74e5f25929c1..fb593f2c954c 100644 --- a/lib/libunbound/Makefile +++ b/lib/libunbound/Makefile @@ -32,7 +32,7 @@ LIBADD= ssl crypto pthread # Misnamed file in upstream source configlexer.l: configlexer.lex - cp -fp ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} CLEANFILES+= configlexer.l # Symbol prefix for lex and yacc diff --git a/secure/lib/libcrypto/Makefile b/secure/lib/libcrypto/Makefile index c28c5102d3b1..fb4c4a88f197 100644 --- a/secure/lib/libcrypto/Makefile +++ b/secure/lib/libcrypto/Makefile @@ -400,7 +400,7 @@ opensslconf.h: opensslconf-x86.h .else opensslconf.h: opensslconf-${MACHINE_CPUARCH}.h .endif - cp -f ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} OLDSYMLINKS+= libdes.a libdes.so libdes.so.3 libdes_p.a afterinstall: diff --git a/share/mk/sys.mk b/share/mk/sys.mk index f69182045e66..0fca5109b4b5 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -67,6 +67,11 @@ CTFFLAGS ?= -L VERSION CTFCONVERT ?= ctfconvert CTFMERGE ?= ctfmerge + +# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle +# read-only files as non-root by passing -f. +CP ?= cp -f + DTRACE ?= dtrace .if defined(CFLAGS) && (${CFLAGS:M-g} != "") CTFFLAGS += -g diff --git a/tools/regression/execve/Makefile b/tools/regression/execve/Makefile index edb05efff729..018678cde02c 100644 --- a/tools/regression/execve/Makefile +++ b/tools/regression/execve/Makefile @@ -14,7 +14,7 @@ all: ${PROG} goodaout ${TESTSCRIPTS} .for x in ${TESTSCRIPTS} ${x}: ${TD}/${x} - cp ${TD}/${x} . + ${CP} ${TD}/${x} . chmod +x ${x} .endfor diff --git a/tools/test/dtrace/Makefile b/tools/test/dtrace/Makefile index 405d536b36fa..ca0547aabdbf 100644 --- a/tools/test/dtrace/Makefile +++ b/tools/test/dtrace/Makefile @@ -343,7 +343,7 @@ ${_f:T:S/c$/exe/} : ${_f} .for _f in ${ALL_TESTEXEFILES} ${_f:T} : ${_f} - cp -f ${_f} ${.TARGET} + ${CP} ${_f} ${.TARGET} chmod a+x ${.TARGET} .endfor diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile index 7dfde1409c40..fd27687c469a 100644 --- a/usr.bin/grep/Makefile +++ b/usr.bin/grep/Makefile @@ -11,7 +11,7 @@ PROG= bsdgrep CLEANFILES+= bsdgrep.1 bsdgrep.1: grep.1 - cp -f ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} .endif SRCS= file.c grep.c queue.c util.c diff --git a/usr.bin/lex/Makefile b/usr.bin/lex/Makefile index f89609210e49..faa503a1ec8a 100644 --- a/usr.bin/lex/Makefile +++ b/usr.bin/lex/Makefile @@ -51,7 +51,7 @@ bootstrap: ${GENFILES:S/^/init/g} @diff -I '^#line ' -I '\$$FreeBS[D]: .*\$$' -q \ ${.CURDIR}/init${_f} ${_f} 2> /dev/null || { \ echo "Bootstrapping ${_f}" ; \ - cp -f ${.CURDIR}/init${_f} ${_f} ; \ + ${CP} ${.CURDIR}/init${_f} ${_f} ; \ } .endfor diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index bfdeca04b5ef..1d366a5bbd1f 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -115,6 +115,6 @@ CFLAGS+= -DDEFSHELLNAME=\"${MAKE_SHELL}\" PROG= fmake CLEANFILES+= fmake.1 fmake.1: make.1 - cp ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} .include diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile index 4f23a7561076..6d060e2d28fd 100644 --- a/usr.sbin/mtree/Makefile +++ b/usr.sbin/mtree/Makefile @@ -16,6 +16,6 @@ LIBADD= md CLEANFILES+= fmtree.8 fmtree.8: mtree.8 - cp -f ${.ALLSRC} ${.TARGET} + ${CP} ${.ALLSRC} ${.TARGET} .include