Permalink
Browse files

Add scripts for incremental builds.

I have created a build directory for holding the object files and
a config directory for configuration files.

The config/llvm.bash can be edited to specify the LLVM install
location.  The config/{linux,darwin}.make files are used to
configure the build for the detected OS.

In addition to allowing incremental builds, the make scripts are
written to arrange automatic tracking of C++ include-dependencies.
For this task, I've added the -MMD option to CXXFLAGS and I have
included a small perl script to collect dependency rules into one
file.

The installation instructions in INSTALL have been updated.
  • Loading branch information...
1 parent f3ef705 commit dde521b59bc1aff19b06cda7df657e5dc9e572e5 @ebb ebb committed with Feb 4, 2011
Showing with 227 additions and 46 deletions.
  1. +11 −17 INSTALL
  2. +12 −0 all.bash
  3. +0 −29 build.sh
  4. +1 −0 build/.gitignore
  5. +86 −0 build/mergedep.pl
  6. +3 −0 clean.bash
  7. +14 −0 config/darwin.make
  8. +8 −0 config/linux.make
  9. +1 −0 config/llvm.bash
  10. +21 −0 src/component.make
  11. +70 −0 top.make
View
28 INSTALL
@@ -11,16 +11,17 @@ On linux and OSX:
- pthread
- pcre (Perl Compatible Regular Expressions)
- glfw (a light weight opengl lib)
- - glut
On linux you will also need:
- portaudio
- mesa GL (opengl)
+ - glut
On OSX you also need the following frameworks:
- opengl
- coreaudio
- cocoa
+ - glut
Most of these are pretty standard and you will probably already have
them on your system (or they will be easy to install). The three that
@@ -43,20 +44,17 @@ configure/make should be sufficient in all cases.
PCRE and GLFW should be installed in the usual locations
(i.e. somewhere that gcc can find).
-LLVM is a special case and currently has it's own argument for the
-extempore build script which should just point directly to the top
-level LLVM source directory.
+LLVM is a special case and you'll need to tell the build system where
+it is installed by editing the config/llvm.bash file to look something
+like the following; where /path/to/llvm is the path to the top level
+LLVM source directory.
-Once all of the library dependencies for you platform are installed
-you can build extempore using the build.sh script. It currently takes
-two arguments, the first tells whether to build for "osx" or "linux"
-and the second points to the top level llvm directory.
+ export LLVM_DIR=/path/to/llvm
-So to build on osx for example you would do something like this:
+Once all of the library dependencies for your platform are installed,
+you can build extempore using:
- $ . ./build.sh osx /Users/andrew/Documents/Code/llvm-2.8
- compiling for osx ...
- done
+ ./all.bash
Voila ... you should be done.
@@ -80,11 +78,7 @@ Now you can build Extempore:
$ git clone https://github.com/digego/extempore.git
$ cd extempore/
- $ sh build.sh linux <PATH TO YOUR LLVM DIRECTORY HERE>
-
-Note you should enter the path where you install LLVM. In my case,
-I've installed at /home/vilson/Misc/llvm-2.8.
-
+ $ ./all.bash
NOTE: If you are running Ubuntu in VirtualBox (on OSX but also possibly
on other hosts as well) then you will need to make a small
View
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+case $(uname) in
+ Linux) EXTEMPORE_OS=linux ;;
+ Darwin) EXTEMPORE_OS=darwin ;;
+ *) echo Unsupported OS: $(uname) >&2 ; exit 1 ;;
+esac
+export EXTEMPORE_OS
+
+. config/llvm.bash
+
+make -f top.make extempore
View
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-if [ $# = 0 ]
-then
-echo "You must pass either 'linux' or 'osx'"
-return
-fi
-
-LLVM_DIR=""
-
-if [ $# -lt 2 ]
-then
-echo "You can optionally provide a path to llvm as second argument"
-else
-LLVM_DIR=$2
-fi
-
-if [ $1 = "osx" ]
-then
-echo "compiling for osx ..."
-# COMPILE OSX
-g++ -w -O3 -D_GNU_SOURCE -DTARGET_OS_MAC -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I$LLVM_DIR/include src/*.cpp -L$LLVM_DIR/Release/lib -lpthread -lm -lLLVMX86AsmParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmParser -lLLVMAsmPrinter -lLLVMXCoreInfo -lLLVMX86Info -lLLVMInterpreter -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMipo -lLLVMTransformUtils -lLLVMInstrumentation -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMSystem -lpcre -lglfw -framework opengl -framework glut -framework cocoa -framework coreaudio -o extempore
-echo "done"
-else
-echo "compiling for linux ..."
-# COMPILE LINUX
-g++ -w -O3 -D_GNU_SOURCE -DTARGET_OS_LINUX -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I$2/include src/*.cpp -L$2/Release/lib -lpthread -lm -lLLVMX86AsmParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmParser -lLLVMAsmPrinter -lLLVMXCoreInfo -lLLVMX86Info -lLLVMInterpreter -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMipo -lLLVMTransformUtils -lLLVMInstrumentation -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMSystem -lpcre -lportaudio -lglfw -lglut /usr/lib/mesa/libGL.so.1 -o extempore
-echo "done"
-fi
View
@@ -0,0 +1 @@
+obj
View
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+# Copyright 2003 Bryan Ford
+# Distributed under the GNU General Public License.
+#
+# Usage: mergedep <main-depfile> [<new-depfiles> ...]
+#
+# This script merges the contents of all <new-depfiles> specified
+# on the command line into the single file <main-depfile>,
+# which may or may not previously exist.
+# Dependencies in the <new-depfiles> will override
+# any existing dependencies for the same targets in <main-depfile>.
+# The <new-depfiles> are deleted after <main-depfile> is updated.
+#
+# The <new-depfiles> are typically generated by GCC with the -MD option,
+# and the <main-depfile> is typically included from a Makefile,
+# as shown here for GNU 'make':
+#
+# .deps: $(wildcard *.d)
+# perl mergedep $@ $^
+# -include .deps
+#
+# This script properly handles multiple dependencies per <new-depfile>,
+# including dependencies having no target,
+# so it is compatible with GCC3's -MP option.
+#
+
+sub readdeps {
+ my $filename = shift;
+
+ open(DEPFILE, $filename) or return 0;
+ while (<DEPFILE>) {
+ if (/([^:]*):([^\\:]*)([\\]?)$/) {
+ my $target = $1;
+ my $deplines = $2;
+ my $slash = $3;
+ while ($slash ne '') {
+ $_ = <DEPFILE>;
+ defined($_) or die
+ "Unterminated dependency in $filename";
+ /(^[ \t][^\\]*)([\\]?)$/ or die
+ "Bad continuation line in $filename";
+ $deplines = "$deplines\\\n$1";
+ $slash = $2;
+ }
+ #print "DEPENDENCY [[$target]]: [[$deplines]]\n";
+ $dephash{$target} = $deplines;
+ } elsif (/^[#]?[ \t]*$/) {
+ # ignore blank lines and comments
+ } else {
+ die "Bad dependency line in $filename: $_";
+ }
+ }
+ close DEPFILE;
+ return 1;
+}
+
+
+if ($#ARGV < 0) {
+ print "Usage: mergedep <main-depfile> [<new-depfiles> ..]\n";
+ exit(1);
+}
+
+%dephash = ();
+
+# Read the main dependency file
+$maindeps = $ARGV[0];
+readdeps($maindeps);
+
+# Read and merge in the new dependency files
+foreach $i (1 .. $#ARGV) {
+ readdeps($ARGV[$i]) or die "Can't open $ARGV[$i]";
+}
+
+# Update the main dependency file
+open(DEPFILE, ">$maindeps.tmp") or die "Can't open output file $maindeps.tmp";
+foreach $target (keys %dephash) {
+ print DEPFILE "$target:$dephash{$target}";
+}
+close DEPFILE;
+rename("$maindeps.tmp", "$maindeps") or die "Can't overwrite $maindeps";
+
+# Finally, delete the new dependency files
+foreach $i (1 .. $#ARGV) {
+ unlink($ARGV[$i]) or print "Error removing $ARGV[$i]\n";
+}
+
View
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+rm -rf extempore build/obj/{.deps,*}
View
@@ -0,0 +1,14 @@
+OSX_FRAMEWORKS := \
+ -framework cocoa \
+ -framework coreaudio \
+ -framework glut \
+ -framework opengl \
+
+PLATFORM_LIBS := $(OSX_FRAMEWORKS)
+
+PLATFORM_CXXFLAGS :=
+PLATFORM_LDFLAGS :=
+
+PLATFORM_DEFINES := -DTARGET_OS_MAC
+PLATFORM_CXX := g++
+PLATFORM_LD := g++
View
@@ -0,0 +1,8 @@
+PLATFORM_LIBS := -lportaudio -lglut /usr/lib/mesa/libGL.so.1
+
+PLATFORM_CXXFLAGS :=
+PLATFORM_LDFLAGS :=
+
+PLATFORM_DEFINES := -DTARGET_OS_LINUX
+PLATFORM_CXX := g++
+PLATFORM_LD := g++
View
@@ -0,0 +1 @@
+export LLVM_DIR=/Users/eric/Unix/support/llvm-2.8
View
@@ -0,0 +1,21 @@
+SRCFILES := \
+ src/AudioDevice.cpp \
+ src/EXTCondition.cpp \
+ src/Extempore.cpp \
+ src/EXTLLVM.cpp \
+ src/EXTMonitor.cpp \
+ src/EXTMutex.cpp \
+ src/EXTThread.cpp \
+ src/OSC.cpp \
+ src/Scheme.cpp \
+ src/SchemeFFI.cpp \
+ src/SchemeProcess.cpp \
+ src/TaskScheduler.cpp \
+ src/UNIV.cpp \
+
+OBJFILES := $(patsubst src/%.cpp, $(OBJDIR)/%.o, $(SRCFILES))
+
+$(OBJDIR)/%.o: src/%.cpp
+ @echo + cxx $<
+ @mkdir -p $(@D)
+ @$(CXX) $(CXXFLAGS) -c -o $@ $<
View
@@ -0,0 +1,70 @@
+OBJDIR := build/obj
+
+PERL := perl
+
+include config/$(EXTEMPORE_OS).make
+include src/component.make
+
+DEFINES := $(PLATFORM_DEFINES) \
+ -D_GNU_SOURCE \
+ -D__STDC_CONSTANT_MACROS \
+ -D__STDC_LIMIT_MACROS \
+
+LLVM_LIBS := \
+ -lLLVMAnalysis \
+ -lLLVMAsmParser \
+ -lLLVMAsmPrinter \
+ -lLLVMCodeGen \
+ -lLLVMCore \
+ -lLLVMExecutionEngine \
+ -lLLVMInstCombine \
+ -lLLVMInstrumentation \
+ -lLLVMInterpreter \
+ -lLLVMJIT \
+ -lLLVMMC \
+ -lLLVMScalarOpts \
+ -lLLVMSelectionDAG \
+ -lLLVMSupport \
+ -lLLVMSystem \
+ -lLLVMTarget \
+ -lLLVMTransformUtils \
+ -lLLVMX86AsmParser \
+ -lLLVMX86AsmPrinter \
+ -lLLVMX86CodeGen \
+ -lLLVMX86Info \
+ -lLLVMXCoreInfo \
+ -lLLVMipa \
+ -lLLVMipo \
+
+LIBS := \
+ -lpthread -lm -lpcre -lglfw \
+ $(LLVM_LIBS) \
+ $(PLATFORM_LIBS) \
+
+CXX := $(PLATFORM_CXX)
+LD := $(PLATFORM_LD)
+
+CXXFLAGS := \
+ -w -O3 -MMD \
+ $(DEFINES) \
+ -Iinclude \
+ -I$(LLVM_DIR)/include \
+ $(PLATFORM_CXXFLAGS) \
+
+LDFLAGS := \
+ -L$(LLVM_DIR)/Release/lib \
+ $(PLATFORM_LDFLAGS) \
+
+extempore: $(OBJFILES)
+ @echo + ld $@
+ @$(LD) $(LDFLAGS) -o $@ $(OBJFILES) $(LIBS)
+
+# C++ include-dependencies are tracked for us by the compiler. In the
+# following, we gather all the dependency information into one file and
+# include it.
+
+$(OBJDIR)/.deps: $(wildcard $(OBJDIR)/*.d)
+ @mkdir -p $(@D)
+ @$(PERL) build/mergedep.pl $@ $^
+
+-include $(OBJDIR)/.deps

0 comments on commit dde521b

Please sign in to comment.