Alex Lin 19025d77ad Standardize directory names
Reorganized.  Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory.  Created a libexec directory that holds all of the executables that users don't need to execute directly.  Changed all of the executables remaining in bin to start with "trick-".  In the sim_services directories changed all source files to find the Trick headers in their new location.  Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level.  Moved the makefiles, docs, man, and other architecture independent files into a top level share directory.  Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on.

refs #63
2015-06-09 08:44:42 -05:00

99 lines
2.8 KiB
Makefile

# The config_${HOST_TYPE}.mk file provides LLVM_HOME
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
RTTIFLAG := -fno-rtti
LLVM_VERSION := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --version)
ifneq ($(LLVM_HOME),)
CC := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --bindir)/clang
CXX := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --bindir)/clang++
CXXFLAGS := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --cxxflags) -I$(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --includedir) $(RTTIFLAG) -g -O0
LLVMLIBDIR := -L$(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --libdir)
endif
LLVMLDFLAGS := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --ldflags)
OBJ_DIR := object_$(TRICK_HOST_CPU)
CLANG_VERSION := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --version)
CLANG_MINOR_GTEQ5 := $(shell expr `$(LLVM_HOME)/bin/$(LLVM_CONFIG) --version | cut -f2 -d. ` \>= 5 )
CLANG_LIBDIR := $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --libdir)
ifeq ($(IS_CC_CLANG), 0)
CXXFLAGS += -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR)
endif
ICG := ${TRICK_HOME}/bin/trick-ICG
SOURCES = $(wildcard *.cpp)
OBJECTS = $(addprefix $(OBJ_DIR)/, $(subst .cpp,.o,$(SOURCES)))
# Include the units conversion source from trick_utils.
UNITS_CONV_SRC = ${TRICK_HOME}/trick_source/trick_utils/units/src/units_conv.c
UNITS_CONV_INCLUDE = -I${TRICK_HOME}/include
UNITS_CONV_OBJ = $(OBJ_DIR)/units_conv.o
ifeq ($(CLANG_MINOR_GTEQ5),1)
LLVMLDFLAGS += $(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --system-libs)
endif
ifeq ($(CLANG_VERSION),3.1)
CLANGLIBS = \
-lclangFrontend \
-lclangDriver \
-lclangSerialization \
-lclangParse \
-lclangSema \
-lclangAnalysis \
-lclangRewrite \
-lclangEdit \
-lclangAST \
-lclangLex \
-lclangBasic \
-lLLVMMC \
-lLLVMSupport
else
CLANGLIBS = \
-lclangFrontend \
-lclangDriver \
-lclangSerialization \
-lclangParse \
-lclangSema \
-lclangAnalysis \
-lclangEdit \
-lclangAST \
-lclangLex \
-lclangBasic \
$(shell $(LLVM_HOME)/bin/$(LLVM_CONFIG) --libs)
endif
all: $(ICG) lib/clang/$(LLVM_VERSION)
$(ICG): $(OBJECTS) $(UNITS_CONV_OBJ)
$(CXX) -o $@ $(OBJECTS) $(UNITS_CONV_OBJ) $(LLVMLIBDIR) $(CLANGLIBS) $(LLVMLDFLAGS)
lib/clang:
mkdir -p $@
lib/clang/$(LLVM_VERSION): | lib/clang
cp -r $(CLANG_LIBDIR)/clang/$(LLVM_VERSION) lib/clang
# Only FieldDescription.cpp includes the units conversion header.
$(OBJ_DIR)/FieldDescription.o : CXXFLAGS += $(UNITS_CONV_INCLUDE)
$(OBJ_DIR)/main.o : CXXFLAGS += $(UNITS_CONV_INCLUDE)
$(OBJECTS): $(OBJ_DIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
$(UNITS_CONV_OBJ): $(UNITS_CONV_SRC)
$(CC) $(UNITS_CONV_INCLUDE) -c $< -o $@
$(OBJECTS) $(UNITS_CONV_OBJ) : | $(OBJ_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
# if an LLVM_HOME is not specified, then ICG cannot be rebuilt... don't delete it
clean:
ifneq ($(LLVM_HOME),)
-rm -rf $(OBJ_DIR) $(ICG) lib
endif