aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2013-11-18 20:58:11 +0800
committerbapt <bapt@FreeBSD.org>2013-11-18 20:58:11 +0800
commitef21d21d21ff6c31168c853797b54c3e05ef5f51 (patch)
tree511dfd288d74953f98da32eaab26eada9214250a /Mk
parent82cc96dcc070b8f913847521c2976beb8853b245 (diff)
downloadfreebsd-ports-gnome-ef21d21d21ff6c31168c853797b54c3e05ef5f51.tar.gz
freebsd-ports-gnome-ef21d21d21ff6c31168c853797b54c3e05ef5f51.tar.zst
freebsd-ports-gnome-ef21d21d21ff6c31168c853797b54c3e05ef5f51.zip
New USES=dos2unix
It is intended to replace USE_DOS2UNIX By default it convert all the source files Use: DOS2UNIX_FILES= <a list of files> to convert files relative to ${WRKSRC} (globs allowed) DOS2UNIX_REGEX= <a regex> To convert files matching the regex (using find -R -iregex) DOS2UNIX_GLOB= <a glob pattern> To convert files matching the glob pattern (using find -name)
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Uses/dos2unix.mk40
1 files changed, 40 insertions, 0 deletions
diff --git a/Mk/Uses/dos2unix.mk b/Mk/Uses/dos2unix.mk
new file mode 100644
index 000000000000..6f31e56c9b9d
--- /dev/null
+++ b/Mk/Uses/dos2unix.mk
@@ -0,0 +1,40 @@
+# $FreeBSD$
+#
+# Provide support to convert files from dos2unix
+#
+# MAINTAINER: portmgr@FreeBSD.org
+#
+# DOS2UNIX_REGEX a regular expression to match files that needs to be converted
+# DOS2UNIX_FILES list of files of glob pattern relative to ${WRKSRC}
+# DOS2UNIX_GLOB list of glob pattern find(1) will match with
+
+.if !defined(_INCLUDE_USES_DOS2UNIX_MK)
+_INCLUDE_USES_DOS2UNIX_MK= yes
+
+.if !defined(DOS2UNIX_FILES) && !defined(DOS2UNIX_REGEX) && !defined(DOS2UNIX_GLOB)
+_DOS2UNIX_ALL= yes
+.endif
+
+pre-patch: dos2unix
+
+dos2unix:
+ @${ECHO_MSG} "===> Converting DOS text files to UNIX text files"
+.if defined(_DOS2UNIX_ALL)
+ @${FIND} ${WRKSRC} -type f -print0 | \
+ ${XARGS} -0 ${SED} -i '' -e 's/ $$//'
+.else
+.if defined(DOS2UNIX_FILES)
+ @(cd ${WRKSRC}; \
+ ${ECHO_CMD} ${DOS2UNIX_FILES} | ${XARGS} ${SED} -i '' -e 's/ $$//' )
+.elif defined(DOS2UNIX_REGEX)
+ @${FIND} -E ${WRKSRC} -type f -iregex '${DOS2UNIX_REGEX}' -print0 | \
+ ${XARGS} -0 ${SED} -i '' -e 's/ $$//'
+.else
+.for f in ${DOS2UNIX_GLOB}
+ @${FIND} ${SRCSRC} -type f -name '${f}' -print0 | \
+ ${XARGS} -0 ${SED} -i '' -e 's/ $$//'
+.endfor
+.endif
+.endif
+
+.endif