Don't overwrite testinstall.cc in testinstall.
Without the change, parallel testinstall fails occasionally when
testinstall.cc is written into obj/ twice:
$ make -j64 -l64 testinstall
cp: cannot create regular file 'obj/testinstall.cc': File exists
make: *** [Makefile:334: static-testinstall] Error 1
make: *** Waiting for unfinished jobs....
The change splits testinstall.cc into shared-testinstall.cc and
static-testinstall.cc.
Change-Id: I3e10d9b0b7b92db48c6315eb9f03b19996882bc1
Reviewed-on: https://code-review.googlesource.com/c/re2/+/59830
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/Makefile b/Makefile
index c7c8145..197c2b3 100644
--- a/Makefile
+++ b/Makefile
@@ -331,13 +331,13 @@
static-testinstall: LDFLAGS:=-pthread -L$(DESTDIR)$(libdir) -l:libre2.a $(LDICU) $(LDFLAGS)
static-testinstall:
@mkdir -p obj
- @cp testinstall.cc obj
+ @cp testinstall.cc obj/static-testinstall.cc
ifeq ($(shell uname),Darwin)
@echo Skipping test for libre2.a on Darwin.
else ifeq ($(shell uname),SunOS)
@echo Skipping test for libre2.a on SunOS.
else
- (cd obj && $(CXX) testinstall.cc -o static-testinstall $(CXXFLAGS) $(LDFLAGS))
+ (cd obj && $(CXX) static-testinstall.cc -o static-testinstall $(CXXFLAGS) $(LDFLAGS))
obj/static-testinstall
endif
@@ -346,8 +346,8 @@
shared-testinstall: LDFLAGS:=-pthread -L$(DESTDIR)$(libdir) -lre2 $(LDICU) $(LDFLAGS)
shared-testinstall:
@mkdir -p obj
- @cp testinstall.cc obj
- (cd obj && $(CXX) testinstall.cc -o shared-testinstall $(CXXFLAGS) $(LDFLAGS))
+ @cp testinstall.cc obj/shared-testinstall.cc
+ (cd obj && $(CXX) shared-testinstall.cc -o shared-testinstall $(CXXFLAGS) $(LDFLAGS))
ifeq ($(shell uname),Darwin)
DYLD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(DYLD_LIBRARY_PATH)" obj/shared-testinstall
else