runtime: introduce mvifdiff.sh script to replace GCC's move-if-change

This goes towards making libgo more self-contained.

From-SVN: r218198
This commit is contained in:
Ian Lance Taylor 2014-12-01 01:06:29 +00:00
parent 13d2541371
commit 4368bc4589
3 changed files with 27 additions and 12 deletions

View File

@ -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

View File

@ -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

15
libgo/mvifdiff.sh Normal file
View File

@ -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