Index: lldb/trunk/test/functionalities/load_unload/Makefile =================================================================== --- lldb/trunk/test/functionalities/load_unload/Makefile +++ lldb/trunk/test/functionalities/load_unload/Makefile @@ -1,84 +1,24 @@ -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif - -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif - -CFLAGS ?= -g -O0 -CWD := $(shell pwd) - -LIB_PREFIX := libloadunload_ - -ifeq "$(OS)" "Darwin" - CFLAGS += -arch $(ARCH) - DS := dsymutil - LD_FLAGS := -dynamiclib - LIB_A := $(LIB_PREFIX)a.dylib - LIB_B := $(LIB_PREFIX)b.dylib - LIB_C := $(LIB_PREFIX)c.dylib - LIB_D := $(LIB_PREFIX)d.dylib - EXEC_PATH := "@executable_path" - EXEC_PATH_A := -install_name $(EXEC_PATH)/$(LIB_A) - EXEC_PATH_B := -install_name $(EXEC_PATH)/$(LIB_B) - EXEC_PATH_C := -install_name $(EXEC_PATH)/$(LIB_C) - EXEC_PATH_D := -install_name $(CWD)/$(LIB_D) - - DS_IF_DARWIN = $(DS) -o $@.dSYM $@ -else - CFLAGS += -fPIC - LD_FLAGS := -shared - LIB_DL := -ldl - LIB_A := $(LIB_PREFIX)a.so - LIB_B := $(LIB_PREFIX)b.so - LIB_C := $(LIB_PREFIX)c.so - LIB_D := $(LIB_PREFIX)d.so -endif - -all: a.out $(LIB_A) $(LIB_B) $(LIB_C) $(LIB_D) hidden/$(LIB_D) - -a.out: main.o $(LIB_D) - $(CC) $(CFLAGS) -o a.out main.o -L. -pie -lloadunload_d $(LIB_DL) - -main.o: main.c - $(CC) $(CFLAGS) -c main.c - -hidden/$(LIB_D): dh.o - $(CC) $(CFLAGS) $(LD_FLAGS) -o hidden/$(LIB_D) dh.o - $(DS_IF_DARWIN) - -$(LIB_A): a.o $(LIB_B) - $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_A) -o $(LIB_A) a.o -L. -lloadunload_b - $(DS_IF_DARWIN) - -a.o: a.c - $(CC) $(CFLAGS) -c a.c - -$(LIB_B): b.o - $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_B) -o $(LIB_B) b.o - $(DS_IF_DARWIN) - -b.o: b.c - $(CC) $(CFLAGS) -c b.c - -$(LIB_C): c.o - $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_C) -o $(LIB_C) c.o - $(DS_IF_DARWIN) - -c.o: c.c - $(CC) $(CFLAGS) -c c.c - -$(LIB_D): d.o - $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_D) -o $(LIB_D) d.o - $(DS_IF_DARWIN) +LEVEL := ../../make -d.o: d.c - $(CC) $(CFLAGS) -c d.c +LIB_PREFIX := loadunload_ -dh.o: d.c - $(CC) $(CFLAGS) -DHIDDEN -c d.c -o dh.o +LD_EXTRAS := -L. -l$(LIB_PREFIX)d -ldl +C_SOURCES := main.c -clean: - rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM hidden/*) +include $(LEVEL)/Makefile.rules + +.PHONY: +a.out: lib_a lib_b lib_c lib_d hidden_lib_d + +lib_%: + $(MAKE) -f $*.mk + +hidden_lib_d: + $(MAKE) -C hidden + +clean:: + $(MAKE) -f a.mk clean + $(MAKE) -f b.mk clean + $(MAKE) -f c.mk clean + $(MAKE) -f d.mk clean + $(MAKE) -C hidden clean Index: lldb/trunk/test/functionalities/load_unload/a.mk =================================================================== --- lldb/trunk/test/functionalities/load_unload/a.mk +++ lldb/trunk/test/functionalities/load_unload/a.mk @@ -0,0 +1,21 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +CFLAGS_EXTRAS := -fPIC +LD_EXTRAS := -L. -l$(LIB_PREFIX)b + +DYLIB_NAME := $(LIB_PREFIX)a +DYLIB_C_SOURCES := a.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules + +.PHONY: +$(DYLIB_FILENAME): lib_b + +lib_b: + $(MAKE) -f b.mk + +clean:: + $(MAKE) -f b.mk clean Index: lldb/trunk/test/functionalities/load_unload/b.mk =================================================================== --- lldb/trunk/test/functionalities/load_unload/b.mk +++ lldb/trunk/test/functionalities/load_unload/b.mk @@ -0,0 +1,9 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)b +DYLIB_C_SOURCES := b.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules Index: lldb/trunk/test/functionalities/load_unload/c.mk =================================================================== --- lldb/trunk/test/functionalities/load_unload/c.mk +++ lldb/trunk/test/functionalities/load_unload/c.mk @@ -0,0 +1,9 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)c +DYLIB_C_SOURCES := c.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules Index: lldb/trunk/test/functionalities/load_unload/d.c =================================================================== --- lldb/trunk/test/functionalities/load_unload/d.c +++ lldb/trunk/test/functionalities/load_unload/d.c @@ -9,9 +9,5 @@ int d_function () { // Find this line number within d_dunction(). -#ifdef HIDDEN - return 12345; -#else return 700; -#endif } Index: lldb/trunk/test/functionalities/load_unload/d.mk =================================================================== --- lldb/trunk/test/functionalities/load_unload/d.mk +++ lldb/trunk/test/functionalities/load_unload/d.mk @@ -0,0 +1,11 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_EXECUTABLE_PATH := $(CURDIR) + +DYLIB_NAME := $(LIB_PREFIX)d +DYLIB_C_SOURCES := d.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules Index: lldb/trunk/test/functionalities/load_unload/hidden/Makefile =================================================================== --- lldb/trunk/test/functionalities/load_unload/hidden/Makefile +++ lldb/trunk/test/functionalities/load_unload/hidden/Makefile @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)d +DYLIB_C_SOURCES := d.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules Index: lldb/trunk/test/functionalities/load_unload/hidden/d.c =================================================================== --- lldb/trunk/test/functionalities/load_unload/hidden/d.c +++ lldb/trunk/test/functionalities/load_unload/hidden/d.c @@ -0,0 +1,13 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +d_function () +{ // Find this line number within d_dunction(). + return 12345; +} Index: lldb/trunk/test/make/Makefile.rules =================================================================== --- lldb/trunk/test/make/Makefile.rules +++ lldb/trunk/test/make/Makefile.rules @@ -200,6 +200,7 @@ ifneq "$(DYLIB_NAME)" "" ifeq "$(OS)" "Darwin" DYLIB_FILENAME = lib$(DYLIB_NAME).dylib + DYLIB_EXECUTABLE_PATH ?= @executable_path else ifeq "$(OS)" "Windows_NT" DYLIB_FILENAME = $(DYLIB_NAME).dll else @@ -452,7 +453,7 @@ $(DYLIB_FILENAME) : $(DYLIB_OBJECTS) ifeq "$(OS)" "Darwin" - $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "@executable_path/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)" + $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)" ifneq "$(MAKE_DSYM)" "NO" ifneq "$(DS)" "" "$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"