From: Ian Lance Taylor Date: Mon, 1 Dec 2014 01:06:29 +0000 (+0000) Subject: runtime: introduce mvifdiff.sh script to replace GCC's move-if-change X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4368bc458974b45ad284780fef222242046ad9f9;p=gcc.git runtime: introduce mvifdiff.sh script to replace GCC's move-if-change This goes towards making libgo more self-contained. From-SVN: r218198 --- diff --git a/libgo/Makefile.am b/libgo/Makefile.am index c6ee01ba3d3..48114d11d50 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -1007,7 +1007,7 @@ s-version: Makefile echo 'const theVersion = "'`$(GOC) --version | sed 1q`'"' >> version.go.tmp echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp - $(SHELL) $(srcdir)/../move-if-change version.go.tmp version.go + $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ go_sort_files = \ @@ -1791,14 +1791,14 @@ s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files) rm -f libcalls.go.tmp files=`echo $^ | sed -e 's/libcalls-list//' -e 's|[^ ]*go/syscall/mksyscall.awk||'`; \ $(AWK) -f $(srcdir)/go/syscall/mksyscall.awk $${files} > libcalls.go.tmp - $(SHELL) $(srcdir)/../move-if-change libcalls.go.tmp libcalls.go + $(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go $(STAMP) $@ libcalls-list: s-libcalls-list; @true s-libcalls-list: Makefile rm -f libcalls-list.tmp echo $(go_base_syscall_files) > libcalls-list.tmp - $(SHELL) $(srcdir)/../move-if-change libcalls-list.tmp libcalls-list + $(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list $(STAMP) $@ syscall_arch.go: s-syscall_arch; @true @@ -1807,13 +1807,13 @@ s-syscall_arch: Makefile echo "package syscall" > syscall_arch.go.tmp echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp - $(SHELL) $(srcdir)/../move-if-change syscall_arch.go.tmp syscall_arch.go + $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh - $(SHELL) $(srcdir)/../move-if-change tmp-sysinfo.go sysinfo.go + $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ # The epoll struct has an embedded union and is packed on x86_64, @@ -1841,7 +1841,7 @@ s-epoll: Makefile exit 1; ;; \ esac echo '}' >> epoll.go.tmp - $(SHELL) $(srcdir)/../move-if-change epoll.go.tmp epoll.go + $(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go $(STAMP) $@ if LIBGO_IS_LINUX diff --git a/libgo/Makefile.in b/libgo/Makefile.in index f42c8f96fbd..259d134c914 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -4392,7 +4392,7 @@ s-version: Makefile echo 'const theVersion = "'`$(GOC) --version | sed 1q`'"' >> version.go.tmp echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp - $(SHELL) $(srcdir)/../move-if-change version.go.tmp version.go + $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ libcalls.go: s-libcalls; @true @@ -4400,14 +4400,14 @@ s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files) rm -f libcalls.go.tmp files=`echo $^ | sed -e 's/libcalls-list//' -e 's|[^ ]*go/syscall/mksyscall.awk||'`; \ $(AWK) -f $(srcdir)/go/syscall/mksyscall.awk $${files} > libcalls.go.tmp - $(SHELL) $(srcdir)/../move-if-change libcalls.go.tmp libcalls.go + $(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go $(STAMP) $@ libcalls-list: s-libcalls-list; @true s-libcalls-list: Makefile rm -f libcalls-list.tmp echo $(go_base_syscall_files) > libcalls-list.tmp - $(SHELL) $(srcdir)/../move-if-change libcalls-list.tmp libcalls-list + $(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list $(STAMP) $@ syscall_arch.go: s-syscall_arch; @true @@ -4416,13 +4416,13 @@ s-syscall_arch: Makefile echo "package syscall" > syscall_arch.go.tmp echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp - $(SHELL) $(srcdir)/../move-if-change syscall_arch.go.tmp syscall_arch.go + $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh - $(SHELL) $(srcdir)/../move-if-change tmp-sysinfo.go sysinfo.go + $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ # The epoll struct has an embedded union and is packed on x86_64, @@ -4450,7 +4450,7 @@ s-epoll: Makefile exit 1; ;; \ esac echo '}' >> epoll.go.tmp - $(SHELL) $(srcdir)/../move-if-change epoll.go.tmp epoll.go + $(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go $(STAMP) $@ @go_include@ bufio.lo.dep diff --git a/libgo/mvifdiff.sh b/libgo/mvifdiff.sh new file mode 100644 index 00000000000..6706e40de40 --- /dev/null +++ b/libgo/mvifdiff.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright 2014 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# The mvifdiff.sh script works like the mv(1) command, except +# that it does not touch the destination file if its contents +# are the same as the source file. + +if cmp -s "$1" "$2" ; then + rm "$1" +else + mv "$1" "$2" +fi