# in the current directory. Also, if you want to build files in addition
# to the local files, you can use the ExtraSource variable
#
+# 5. SourceDir - If specified, this specifies a directory that the source files
+# are in, if they are not in the current directory. This should include a
+# trailing / character.
+#
#===-----------------------------------------------------------------------====
# Configuration file to set paths specific to local installation of LLVM
PURIFY := $(PURIFY) -cache-dir="$(BUILD_ROOT_TOP)/../purifycache" -chain-length="30" -messages=all
+ifdef ENABLE_PROFILING
+ ENABLE_OPTIMIZED = 1
+ CONFIGURATION := Profile
+else
+ ifdef ENABLE_OPTIMIZED
+ CONFIGURATION := Release
+ else
+ CONFIGURATION := Debug
+ endif
+endif
+
# Shorthand for commonly accessed directories
LIBDEBUG := $(BUILD_ROOT_TOP)/lib/Debug
LIBRELEASE := $(BUILD_ROOT_TOP)/lib/Release
LIBPROFILE := $(BUILD_ROOT_TOP)/lib/Profile
+LIBCURRENT := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION)
+
TOOLDEBUG := $(BUILD_ROOT_TOP)/tools/Debug
TOOLRELEASE := $(BUILD_ROOT_TOP)/tools/Release
TOOLPROFILE := $(BUILD_ROOT_TOP)/tools/Profile
+TOOLCURRENT := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION)
# Verbosity levels
-ifdef VERBOSE
-VERB :=
-else
+ifndef VERBOSE
VERB := @
endif
# Special tools used while building the LLVM tree. Burg is built as part of the
# utils directory.
#
-BURG := $(TOOLDEBUG)/burg
+BURG := $(TOOLCURRENT)/burg
RunBurg := $(BURG) $(BURG_OPTS)
# This automatically enables optimized builds.
ifdef ENABLE_PROFILING
PROFILE = -pg
- ENABLE_OPTIMIZED = 1
-else
- PROFILE =
endif
# By default, strip symbol information from executable
-ifdef KEEP_SYMBOLS
-STRIP =
-STRIP_WARN_MSG =
-else
+ifndef KEEP_SYMBOLS
STRIP = $(PLATFORMSTRIPOPTS)
STRIP_WARN_MSG = "(without symbols) "
endif
# -Wno-unused-parameter
CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
+CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
# Compile a cpp file, don't link...
Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
CompileG := $(Compile) -g -D_DEBUG
-CompileO := $(Compile) -O3 -DNDEBUG -finline-functions -felide-constructors -fshort-enums -fomit-frame-pointer
-CompileP := $(CompileO) $(PROFILE)
+CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
+CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
# Compile a c file, don't link...
CompileC := $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
CompileCG := $(CompileC) -g -D_DEBUG
-CompileCO := $(CompileC) -O3 -DNDEBUG -finline-functions -fshort-enums -fomit-frame-pointer
-CompileCP := $(CompileCO) $(PROFILE)
+CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
+CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
# Link final executable
Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
endif
-Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(basename $(Source)))))
+Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
ObjectsO := $(addprefix $(BUILD_ROOT)/Release/,$(Objs))
ObjectsP := $(addprefix $(BUILD_ROOT)/Profile/,$(Objs))
ObjectsG := $(addprefix $(BUILD_ROOT)/Debug/,$(Objs))
LIBNAME_OBJP := $(LIBPROFILE)/$(LIBRARYNAME).o
LIBNAME_OBJG := $(LIBDEBUG)/$(LIBRARYNAME).o
+# dynamic target builds a shared object version of the library...
+dynamic:: $(LIBCURRENT)/lib$(LIBRARYNAME).so
-ifndef ENABLE_OPTIMIZED
-BUILD_LIBNAME_G := $(LIBNAME_G)
+# Does the library want a .o version built?
ifndef DONT_BUILD_RELINKED
-BUILD_LIBNAME_OBJG := $(LIBNAME_OBJG)
-endif
-ifdef BUILD_ARCHIVE
-BUILD_LIBNAME_AG := $(LIBNAME_AG)
-endif
+all:: $(LIBCURRENT)/$(LIBRARYNAME).o
endif
-# If optimized builds are enabled...
-ifdef ENABLE_OPTIMIZED
- ifdef ENABLE_PROFILING
- BUILD_LIBNAME_O := $(LIBNAME_P)
- ifndef DONT_BUILD_RELINKED
- BUILD_LIBNAME_OBJO := $(LIBNAME_OBJP)
- endif
- ifdef BUILD_ARCHIVE
- BUILD_LIBNAME_AO := $(LIBNAME_AP)
- endif
- else
- BUILD_LIBNAME_O := $(LIBNAME_O)
- ifndef DONT_BUILD_RELINKED
- BUILD_LIBNAME_OBJO := $(LIBNAME_OBJO)
- endif
- ifdef BUILD_ARCHIVE
- BUILD_LIBNAME_AO := $(LIBNAME_AO)
- endif
- endif
+# Does the library want an archive version built?
+ifdef BUILD_ARCHIVE
+all:: $(LIBCURRENT)/lib$(LIBRARYNAME).a
endif
-all:: $(BUILD_LIBNAME_AG) $(BUILD_LIBNAME_OBJG) # Debug
-all:: $(BUILD_LIBNAME_AO) $(BUILD_LIBNAME_OBJO) # Release
-all:: $(BUILD_LIBNAME_AP) $(BUILD_LIBNAME_OBJP) # Profile
-dynamic:: $(BUILD_LIBNAME_G) $(BUILD_LIBNAME_O) $(BUILD_LIBNAME_P) # .so files
-
$(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir
@echo ======= Linking $(LIBRARYNAME) release library =======
$(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
TOOLEXENAME_G := $(BUILD_ROOT_TOP)/tools/Debug/$(TOOLNAME)
TOOLEXENAME_O := $(BUILD_ROOT_TOP)/tools/Release/$(TOOLNAME)
TOOLEXENAME_P := $(BUILD_ROOT_TOP)/tools/Profile/$(TOOLNAME)
-
-ifndef ENABLE_OPTIMIZED
- TOOLEXENAMES := $(TOOLEXENAME_G)
-else
- ifdef ENABLE_PROFILING
- TOOLEXENAMES := $(TOOLEXENAME_P)
- else
- TOOLEXENAMES := $(TOOLEXENAME_O)
- endif
-endif
+TOOLEXENAMES := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION)/$(TOOLNAME)
# USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
USED_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
.PRECIOUS: $(BUILD_ROOT)/Depend/.dir
.PRECIOUS: $(BUILD_ROOT)/Debug/.dir $(BUILD_ROOT)/Release/.dir
-# Create dependencies for the *.cpp files...
-$(BUILD_ROOT)/Depend/%.d: %.cpp $(BUILD_ROOT)/Depend/.dir
- $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Profile/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@
-
-# Create dependencies for the *.c files...
-$(BUILD_ROOT)/Depend/%.d: %.c $(BUILD_ROOT)/Depend/.dir
- $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
-
# Create .o files in the ObjectFiles directory from the .cpp and .c files...
-$(BUILD_ROOT)/Release/%.o: %.cpp $(BUILD_ROOT)/Release/.dir
+$(BUILD_ROOT)/Release/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Release/.dir
@echo "Compiling $<"
$(VERB) $(CompileO) $< -o $@
-$(BUILD_ROOT)/Release/%.o: %.c $(BUILD_ROOT)/Release/.dir
+$(BUILD_ROOT)/Release/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Release/.dir
$(VERB) $(CompileCO) $< -o $@
-$(BUILD_ROOT)/Profile/%.o: %.cpp $(BUILD_ROOT)/Profile/.dir
+$(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Profile/.dir
@echo "Compiling $<"
$(VERB) $(CompileP) $< -o $@
-$(BUILD_ROOT)/Profile/%.o: %.c $(BUILD_ROOT)/Profile/.dir
+$(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Profile/.dir
@echo "Compiling $<"
$(VERB) $(CompileCP) $< -o $@
-$(BUILD_ROOT)/Debug/%.o: %.cpp $(BUILD_ROOT)/Debug/.dir
+$(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Debug/.dir
@echo "Compiling $<"
$(VERB) $(CompileG) $< -o $@
-$(BUILD_ROOT)/Debug/%.o: %.c $(BUILD_ROOT)/Debug/.dir
+$(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Debug/.dir
$(VERB) $(CompileCG) $< -o $@
#
sed 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@
# Rule for building the bison parsers...
-
+%.c: %.y # Cancel built-in rules for yacc
+%.h: %.y # Cancel built-in rules for yacc
%.cpp %.h : %.y
+ @echo Bison\'ing $<...
$(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
$(VERB) mv -f $*.tab.c $*.cpp
$(VERB) mv -f $*.tab.h $*.h
$(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
$(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT)
-# If dependancies were generated for the file that included this file,
+# If dependencies were generated for the file that included this file,
# include the dependancies now...
#
-SourceDepend := $(addsuffix .d,$(addprefix $(BUILD_ROOT)/Depend/,$(basename $(filter-out Debug/%, $(Source)))))
+SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
+SourceDepend := $(SourceBaseNames:%=$(BUILD_ROOT)/Depend/%.d)
+
+# Create dependencies for the *.cpp files...
+#$(SourceDepend): \x
+$(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_ROOT)/Depend/.dir
+ $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Profile/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@
+
+# Create dependencies for the *.c files...
+#$(SourceDepend): \x
+$(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.c $(BUILD_ROOT)/Depend/.dir
+ $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
+
ifneq ($(SourceDepend),)
-include $(SourceDepend)
endif