include Makefile.config
# Debug/Release
RELEASE := Debug
ifdef ENABLE_OPTIMIZED
  RELEASE := Release
endif
# Asserts
ifndef DISABLE_ASSERTIONS
  RELEASE := $(RELEASE)+Asserts
endif
# Checks
ifdef ENABLE_EXPENSIVE_CHECKS
  RELEASE := $(RELEASE)+Checks
endif
# lib path and libs
LDIR = $(LLVM_OBJ_ROOT)/$(RELEASE)/lib

LIBS = -lLLVMAsmParser -lLLVMBitReader -lLLVMCodasipCodeGen -lLLVMSelectionDAG -lLLVMCodasipDesc -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMCodasipInfo -lLLVMMC -lLLVMSupport -lpthread -ldl -lm -lLLVMTableGen -lLLVMMCJIT -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCDisassembler -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMDebugInfo -lLLVMCodasipCodeGen -lLLVMCodasipDesc -lLLVMCodasipInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMSelectionDAG -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMX86Info -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAsmParser -lLLVMArchive -lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport
# flags
FLAGS = -g -fno-exceptions -fPIC -Wl,-R,$(LLVM_OBJ_ROOT)/$(RELEASE)/bin,-export-dynamic

all:
	# compile backend
	$(MAKE) -f Makefile.llvm
	# link llc    local libs dir   build libs dir   main module                                list of libs
	g++ $(FLAGS) -L$(RELEASE)/lib -L$(LDIR) -o /home/wizzard/llvm3.0/llvm_obj/Debug+Asserts+Checks/bin/llc $(LLVM_OBJ_ROOT)/tools/llc/$(RELEASE)/llc.o $(LIBS)
	#g++ $(FLAGS) -L$(RELEASE)/lib -L$(LDIR) -o /home/wizzard/llvm3.0/llvm_install/bin/llc $(LLVM_OBJ_ROOT)/tools/llc/$(RELEASE)/llc.o $(LIBS)
clean:
	make -f Makefile.llvm clean
	rm llc -f
