This comes up often enough that I think it's worth adding to bsd.port.mk rather than handling with custom commands. ok?
Index: ports/infrastructure/mk/bsd.port.mk =================================================================== RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v retrieving revision 1.1549 diff -u -p -r1.1549 bsd.port.mk --- ports/infrastructure/mk/bsd.port.mk 20 Feb 2021 18:05:04 -0000 1.1549 +++ ports/infrastructure/mk/bsd.port.mk 25 Feb 2021 20:23:27 -0000 @@ -2688,6 +2688,9 @@ _post-extract-finalize: .endfor .if ${FIX_EXTRACT_PERMISSIONS:L} == "yes" @chmod -R a+rX ${WRKDIR} +.endif +.if defined(FIX_CRLF_FILES) + @cd ${WRKSRC} && perl -i -pe 's/\r$$//' ${FIX_CRLF_FILES} .endif # run as _pbuild Index: src/share/man//man5/bsd.port.mk.5 =================================================================== RCS file: /cvs/src/share/man/man5/bsd.port.mk.5,v retrieving revision 1.537 diff -u -p -r1.537 bsd.port.mk.5 --- src/share/man//man5/bsd.port.mk.5 4 Feb 2021 22:12:03 -0000 1.537 +++ src/share/man//man5/bsd.port.mk.5 25 Feb 2021 20:23:06 -0000 @@ -1842,6 +1842,11 @@ to world-readable at the end of Used for some distfile contents which have paranoid permissions for no reason. Defaults to .Sq \&No . +.It Ev FIX_CRLF_FILES +Names of files with line endings that need to be corrected after extraction. +Sometimes a port will include files with MS-DOS line endings, +to avoid problems with patches (especially when sent by email) +these should be corrected. .It Ev FLAVOR The port's current options. Set by the user, and tested by the port to activate wanted functionalities.