Makefile: Introduce a release build
authorMichel Pollet <buserror@gmail.com>
Tue, 30 Oct 2012 15:09:37 +0000 (15:09 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 30 Oct 2012 15:09:37 +0000 (15:09 +0000)
make RELEASE=1 will use rpath-link to link the executable,
preventing simavr build path to be referenced. This requires
that simavr gets installed for it to work

Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile
Makefile.common

index 0b35fdf..cf4ceaa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,30 @@
+# Makefile
+
+# Normal build will link against the shared library for simavr
+# in the current build tree, so you don't have to 'install' to
+# run simavr or the examples.
+#
+# For package building, you will need to pass RELEASE=1 to make
+RELEASE        ?= 0
+
 .PHONY: doc
 
 all:   build-simavr build-tests build-examples
 
 build-simavr:
-       $(MAKE) -C simavr
+       $(MAKE) -C simavr RELEASE=$(RELEASE)
 
 build-tests: build-simavr
-       $(MAKE) -C tests
+       $(MAKE) -C tests RELEASE=$(RELEASE)
 
 build-examples: build-simavr
-       $(MAKE) -C examples
+       $(MAKE) -C examples RELEASE=$(RELEASE)
 
 install:
-       $(MAKE) -C simavr install
+       $(MAKE) -C simavr install RELEASE=$(RELEASE)
 
 doc:
-       $(MAKE) -C doc
+       $(MAKE) -C doc RELEASE=$(RELEASE)
 
 clean:
        $(MAKE) -C simavr clean
index 178c3c9..3658ae5 100644 (file)
@@ -27,7 +27,7 @@
 #      along with simavr.  If not, see <http://www.gnu.org/licenses/>.
 
 # simavr directory
-SIMAVR         ?= ${shell for p in . .. ../.. ../../..;do test -d $$p/simavr/sim && echo $$p/simavr; done}
+SIMAVR         := ${shell for p in . .. ../.. ../../..;do test -d $$p/simavr/sim && echo $$p/simavr; done}
 
 # You can override the build settings with local changes in this file
 # for example:
@@ -79,9 +79,15 @@ LDFLAGS      += -L${LIBDIR} -lsimavr
 LDFLAGS        += -lelf 
 
 ifeq (${shell uname}, Linux)
+ifeq ($(RELEASE),1)
+# allow the shared library to be found in the build directory
+# only for linking, the install time location is used at runtime
+LFLAGS         += -Wl,-rpath-link,${LIBDIR}
+else
 # allow the shared library to be found in the build directory
 LFLAGS         += -Wl,-rpath,${LIBDIR}
 endif
+endif
 
 # The code is compiled "optimized" to the max.
 #