[Testsuite] Get rid of most of the recursive shared library Makefiles

Most of the secondary Makefiles we have are just a couple variable
definitions and then an include of Makefile.rules. This patch removes
most of the secondary Makefiles and replaces them with a direct
invocation of Makefile.rules in the main Makefile. The specificities
of each sub-build are listed right there on the recursive $(MAKE)
call. All the variables that matter are being passed automagically by
make as they have been passed on the command line. The only things you
need to specify are the variables customizating the Makefile.rules
logic for each image.

This patch also removes most of the clean logic from those Makefiles
and from Makefile.rules. The clean rule is not required anymore now
that we run the testsuite in a separate build directory that is wiped
with each run. The patch leaves a very crude version of clean in
Makefile.rules which removes everything inside of $(BUILDDIR). It does
this only when the $(BUILDDIR) looks like a sub-directory of our
standard testsuite build directory to be extra safe.

Reviewers: aprantl, labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68558

llvm-svn: 374076
This commit is contained in:
Frederic Riss 2019-10-08 16:23:28 +00:00
parent d1fe34cc93
commit 3fb4e49a68
28 changed files with 86 additions and 222 deletions

View File

@ -1,11 +1,10 @@
CXX_SOURCES := main.cpp test.cpp
all: dummy
include Makefile.rules
a.out: dummy
dummy: dummy.cpp
$(MAKE) -f $(MAKEFILE_RULES) \
CXX_SOURCES=dummy.cpp EXE=dummy
dummy:
$(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk
clean::
$(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean

View File

@ -1,4 +0,0 @@
CXX_SOURCES := dummy.cpp
EXE := dummy
include Makefile.rules

View File

@ -1,14 +1,10 @@
LIB_PREFIX := load_
LD_EXTRAS := -L. -l$(LIB_PREFIX)a
LD_EXTRAS := -L. -lload_a
CXX_SOURCES := main.cpp
a.out: libload_a
include Makefile.rules
a.out: lib_a
lib_%:
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/$*.mk
clean::
$(MAKE) -f $(SRCDIR)/a.mk clean
libload_a:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=load_a DYLIB_CXX_SOURCES=a.cpp

View File

@ -1,7 +0,0 @@
LIB_PREFIX := load_
DYLIB_NAME := $(LIB_PREFIX)a
DYLIB_CXX_SOURCES := a.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,11 +1,9 @@
CXX_SOURCES := main.cpp
all: a.out secondprog
all: secondprog
include Makefile.rules
secondprog:
$(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/secondprog.mk
clean::
$(MAKE) -f $(SRCDIR)/secondprog.mk clean
secondprog: secondprog.cpp
$(MAKE) -f $(MAKEFILE_RULES) \
CXX_SOURCES=secondprog.cpp EXE=secondprog

View File

@ -1,4 +0,0 @@
CXX_SOURCES := secondprog.cpp
EXE = secondprog
include Makefile.rules

View File

@ -5,7 +5,5 @@ all: a.out simple
include Makefile.rules
simple:
$(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/simple.mk
clean::
$(MAKE) -f $(SRCDIR)/simple.mk clean
$(MAKE) -f $(MAKEFILE_RULES) \
C_SOURCES=simple.c EXE=simple

View File

@ -1,4 +0,0 @@
C_SOURCES := simple.c
EXE = simple
include Makefile.rules

View File

@ -1,28 +1,32 @@
LIB_PREFIX := loadunload_
LD_EXTRAS := -L. -l$(LIB_PREFIX)d
LD_EXTRAS := -L. -lloadunload_d
CXX_SOURCES := main.cpp
USE_LIBDL := 1
a.out: lib_b lib_a lib_c lib_d hidden_lib_d
include Makefile.rules
a.out: lib_a lib_b lib_c lib_d hidden_lib_d install_name_tool
lib_a: lib_b
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=a.cpp DYLIB_NAME=loadunload_a \
LD_EXTRAS="-L. -lloadunload_b"
lib_%:
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/$*.mk
lib_b:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=b.cpp DYLIB_NAME=loadunload_b
install_name_tool:
lib_c:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=c.cpp DYLIB_NAME=loadunload_c
lib_d:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=d.cpp DYLIB_NAME=loadunload_d
ifeq ($(OS),Darwin)
install_name_tool -id @executable_path/libloadunload_d.dylib libloadunload_d.dylib
endif
hidden_lib_d:
$(MAKE) VPATH=$(SRCDIR)/hidden -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile
clean::
$(MAKE) -f $(SRCDIR)/a.mk clean
$(MAKE) -f $(SRCDIR)/b.mk clean
$(MAKE) -f $(SRCDIR)/c.mk clean
$(MAKE) -f $(SRCDIR)/d.mk clean
$(MAKE) -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean
mkdir -p hidden
$(MAKE) VPATH=$(SRCDIR)/hidden -C hidden -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=d.cpp DYLIB_NAME=loadunload_d

View File

@ -1,17 +0,0 @@
LIB_PREFIX := loadunload_
LD_EXTRAS := -L. -l$(LIB_PREFIX)b
DYLIB_NAME := $(LIB_PREFIX)a
DYLIB_CXX_SOURCES := a.cpp
DYLIB_ONLY := YES
include Makefile.rules
$(DYLIB_FILENAME): lib_b
.PHONY lib_b:
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/b.mk
clean::
$(MAKE) -I $(SRCDIR) -f $(SRCDIR)/b.mk clean

View File

@ -1,7 +0,0 @@
LIB_PREFIX := loadunload_
DYLIB_NAME := $(LIB_PREFIX)b
DYLIB_CXX_SOURCES := b.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,7 +0,0 @@
LIB_PREFIX := loadunload_
DYLIB_NAME := $(LIB_PREFIX)c
DYLIB_CXX_SOURCES := c.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,9 +0,0 @@
LIB_PREFIX := loadunload_
DYLIB_EXECUTABLE_PATH := $(CURDIR)
DYLIB_NAME := $(LIB_PREFIX)d
DYLIB_CXX_SOURCES := d.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,12 +1,11 @@
CXX_SOURCES := main.cpp
USE_LIBDL := 1
include Makefile.rules
all: hidden_lib a.out
hidden_lib:
$(MAKE) VPATH=$(SRCDIR)/hidden -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile
include Makefile.rules
hidden_lib:
$(MAKE) VPATH=$(SRCDIR)/hidden -C hidden -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_CXX_SOURCES=d.cpp DYLIB_NAME=loadunload
clean::
$(MAKE) -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean

View File

@ -1,17 +1,15 @@
LD_EXTRAS := -L. -l$(LIB_PREFIX)a -l$(LIB_PREFIX)b
LD_EXTRAS := -L. -la -lb
CXX_SOURCES := main.cpp
a.out: liba libb
include Makefile.rules
.PHONY:
a.out: lib_a lib_b
liba:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=a DYLIB_CXX_SOURCES=a.cpp
lib_%:
$(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/$*.mk
libb:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=b DYLIB_CXX_SOURCES=b.cpp
hidden_lib_d:
$(MAKE) -C hidden
clean::
$(MAKE) -f $(SRCDIR)/a.mk clean
$(MAKE) -f $(SRCDIR)/b.mk clean

View File

@ -1,5 +0,0 @@
DYLIB_NAME := a
DYLIB_CXX_SOURCES := a.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,5 +0,0 @@
DYLIB_NAME := b
DYLIB_CXX_SOURCES := b.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,21 +1,23 @@
LD_EXTRAS = -lobjc -framework Foundation
include Makefile.rules
LD_EXTRAS := -lobjc -framework Foundation -L. -lTest -lTestExt
OBJC_SOURCES := main.m
all: a.out
a.out: libTest.dylib libTestExt.dylib
include Makefile.rules
libTest.dylib: Test/Test.m
mkdir -p Test
$(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/Test/Test.mk all
$(MAKE) MAKE_DSYM=YES -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=Test DYLIB_OBJC_SOURCES=Test/Test.m \
LD_EXTRAS="-lobjc -framework Foundation" \
CFLAGS_EXTRAS=-I$(SRCDIR)
libTestExt.dylib: TestExt/TestExt.m
mkdir -p TestExt
$(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/TestExt/TestExt.mk all
$(MAKE) MAKE_DSYM=YES -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=TestExt DYLIB_OBJC_SOURCES=TestExt/TestExt.m \
LD_EXTRAS="-lobjc -framework Foundation -lTest -L." \
CFLAGS_EXTRAS=-I$(SRCDIR)
a.out: main.m libTest.dylib libTestExt.dylib
$(CC) $(LDFLAGS) -I$(SRCDIR) -L. -lTest -lTestExt -o a.out $<
clean::
rm -rf libTest.dylib libTestExt.dylib a.out Test.o TestExt.o libTest.dylib.dSYM libTestExt.dylib.dSYM
$(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/Test/Test.mk clean
$(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/TestExt/TestExt.mk clean

View File

@ -1,8 +0,0 @@
DYLIB_NAME := Test
DYLIB_ONLY := YES
CFLAGS_EXTRAS = -I$(SRCDIR)/..
LD_EXTRAS = -lobjc -framework Foundation
DYLIB_OBJC_SOURCES = Test/Test.m
include Makefile.rules

View File

@ -1,8 +0,0 @@
DYLIB_NAME := TestExt
DYLIB_ONLY := YES
CFLAGS_EXTRAS = -I$(SRCDIR)/..
LD_EXTRAS = -L. -lTest -lobjc -framework Foundation
DYLIB_OBJC_SOURCES = TestExt/TestExt.m
include Makefile.rules

View File

@ -5,9 +5,7 @@ C_SOURCES := main.c
all: a.out create-empty-corefile
create-empty-corefile:
$(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/create-empty-corefile.mk
clean::
$(MAKE) -f create-empty-corefile.mk clean
$(MAKE) -f $(MAKEFILE_RULES) EXE=create-empty-corefile \
C_SOURCES=create-empty-corefile.c
include Makefile.rules

View File

@ -1,6 +0,0 @@
MAKE_DSYM := NO
CXX_SOURCES := create-empty-corefile.cpp
EXE = create-empty-corefile
include Makefile.rules

View File

@ -8,11 +8,8 @@ CFLAGS_EXTRAS := -target $(TRIPLE)
all: libfoo.dylib a.out
lib%.dylib: %.c
$(MAKE) MAKE_DSYM=YES CC=$(CC) \
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
BASENAME=$(shell basename $< .c) \
TRIPLE=x86_64-apple-macosx10.15 SDKROOT=$(SDKROOT) \
VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all
libfoo.dylib: foo.c \
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES DYLIB_NAME=foo DYLIB_C_SOURCES=foo.c
include $(LEVEL)/Makefile.rules

View File

@ -1,6 +0,0 @@
LEVEL = ../../make
DYLIB_ONLY := YES
DYLIB_NAME := $(BASENAME)
DYLIB_C_SOURCES := $(DYLIB_NAME).c
include $(LEVEL)/Makefile.rules

View File

@ -36,7 +36,8 @@
SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))
BUILDDIR := $(shell pwd)
THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))
MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))
THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))
LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
#----------------------------------------------------------------------
@ -764,29 +765,10 @@ endif
dsym: $(DSYM)
all: $(EXE) $(DSYM)
clean::
$(RM) -rf $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(CLANG_MODULE_CACHE_DIR)
ifneq "$(DYLIB_NAME)" ""
$(RM) -r $(DYLIB_FILENAME).dSYM
$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
endif
ifneq "$(FRAMEWORK)" ""
$(RM) -rf $(FRAMEWORK).framework
endif
ifneq "$(PCH_OUTPUT)" ""
$(RM) $(PCH_OUTPUT)
endif
ifneq "$(DSYM)" ""
$(RM) -r "$(DSYM)"
endif
ifeq "$(OS)" "Windows_NT"
# http://llvm.org/pr24589
IF EXIST "$(EXE)" del "$(EXE)"
$(RM) $(wildcard *.manifest *.pdb *.ilk)
ifneq "$(DYLIB_NAME)" ""
$(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp
endif
ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
$(error Trying to invoke the clean rule, but not using the default build tree layout)
else
$(RM) "$(EXE)"
$(RM) -r $(wildcard $(BUILDDIR)/*)
endif
#----------------------------------------------------------------------

View File

@ -1,15 +1,19 @@
LIB_PREFIX := svr4lib
LD_EXTRAS := -L. -l$(LIB_PREFIX)_a -l$(LIB_PREFIX)_b\"
LD_EXTRAS := -L. -lsvr4lib_a -lsvr4lib_b\"
CXX_SOURCES := main.cpp
USE_LIBDL := 1
MAKE_DSYM := NO
a.out: svr4lib_a svr4lib_b_quote
include Makefile.rules
a.out: $(LIB_PREFIX)_a $(LIB_PREFIX)_b_quote
svr4lib_a:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_NAME=svr4lib_a DYLIB_CXX_SOURCES=svr4lib_a.cpp \
DYLIB_ONLY=YES
svr4lib_%:
$(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f "$(SRCDIR)/$(LIB_PREFIX)_$*.mk"
clean::
$(MAKE) -f $(SRCDIR)/$(LIB_PREFIX)_a.mk clean
svr4lib_b_quote:
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_NAME=svr4lib_b\\\" DYLIB_CXX_SOURCES=svr4lib_b_quote.cpp \
DYLIB_ONLY=YES

View File

@ -1,7 +0,0 @@
LIB_PREFIX := svr4lib
DYLIB_NAME := $(LIB_PREFIX)_a
DYLIB_CXX_SOURCES := $(LIB_PREFIX)_a.cpp
DYLIB_ONLY := YES
include Makefile.rules

View File

@ -1,7 +0,0 @@
LIB_PREFIX := svr4lib
DYLIB_NAME := $(LIB_PREFIX)_b\"
DYLIB_CXX_SOURCES := $(LIB_PREFIX)_b_quote.cpp
DYLIB_ONLY := YES
include Makefile.rules