Commit 70548ddb6673b3e86bcc992f6164ca808d945263
authorNeil Spring <nspring@cs.umd.edu>
Tue, 29 May 2018 15:32:49 +0000 (11:32 -0400)
committerNeil Spring <nspring@cs.umd.edu>
Tue, 29 May 2018 18:46:27 +0000 (14:46 -0400)
examplesbparts makefile rather than use the simavr
makefile, allowing installation of simavr (alone) on
machines without a working glut.

Fix RELEASE=1 option to additionally specify rpath (not
just rpath-link) if simavr will be installed in a special
directory.

Add detection and use of librt when available (e.g.,
RHEL 6.9).

7 files changed:
Makefile
Makefile.common
examples/parts/Makefile
examples/parts/simavrparts.pc [new file with mode: 0644]
simavr/Makefile
simavr/sim/avr_timer.c
simavr/simavrparts.pc [deleted file]

index 9109fb8111be05fbf921728dbc6213c9ed864518..34b719014f4a7bb1dfbd48c9fb9e099471300770 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@
 # For package building, you will need to pass RELEASE=1 to make
 RELEASE        ?= 0
 
+DESTDIR = /usr/local
+PREFIX = ${DESTDIR}
+
 .PHONY: doc
 
 all:   build-simavr build-tests build-examples build-parts
@@ -23,8 +26,13 @@ build-examples: build-simavr
 build-parts: build-examples
        $(MAKE) -C examples/parts RELEASE=$(RELEASE)
 
-install: build-parts
-       $(MAKE) -C simavr install RELEASE=$(RELEASE)
+install: install-simavr install-parts
+
+install-simavr:
+       $(MAKE) -C simavr install RELEASE=$(RELEASE) DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
+
+install-parts:
+       $(MAKE) -C examples/parts install RELEASE=$(RELEASE) DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
 
 doc:
        $(MAKE) -C doc RELEASE=$(RELEASE)
index 9b56e27606928699bcef2d9d8e42dbf940c809e6..8abf80c8e72f499e86a9c443452587181060cf10 100644 (file)
@@ -120,11 +120,16 @@ ifeq (${WIN}, Msys)
 LDFLAGS      += -lws2_32
 endif
 
+# for clock_gettime on RHEL 6.9
+ifneq ("$(wildcard /usr/lib/librt.so)","")
+LDFLAGS            += -lrt
+endif
+
 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}
+LFLAGS         += -Wl,-rpath-link,${LIBDIR} -Wl,-rpath,${PREFIX}/lib
 else
 # allow the shared library to be found in the build directory
 LFLAGS         += -Wl,-rpath,${LIBDIR}
index 153e64f32e3b1a11b21d76f43fe2b1a7b7d61bca..73de013f73f96ad662008bba3977b57b9bc1528f 100644 (file)
@@ -47,5 +47,16 @@ ifeq (${shell uname}, Linux)
 ${target}: ${OBJ}/${target}.so
 endif
 
+install: obj ${target}
+       $(MKDIR) $(DESTDIR)/include/simavr/parts
+       $(INSTALL) -m644 *.h $(DESTDIR)/include/simavr/parts/
+       $(INSTALL) ${OBJ}/libsimavrparts.a $(DESTDIR)/lib/
+       sed -e "s|PREFIX|${PREFIX}|g" -e "s|VERSION|${SIMAVR_VERSION}|g" \
+               simavrparts.pc >$(DESTDIR)/lib/pkgconfig/simavrparts.pc
+ifeq (${shell uname}, Linux)
+       $(INSTALL) ${OBJ}/libsimavrparts.so.1 $(DESTDIR)/lib/
+       ln -sf libsimavrparts.so.1 $(DESTDIR)/lib/libsimavrparts.so
+endif
+
 clean: clean-${OBJ}
        rm -rf *.hex *.a *.axf *.vcd .*.swo .*.swp .*.swm .*.swn *.so *.o
diff --git a/examples/parts/simavrparts.pc b/examples/parts/simavrparts.pc
new file mode 100644 (file)
index 0000000..ba7b80e
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=PREFIX
+exec_prefix=${prefix}
+includedir=${prefix}/include/
+libdir=${exec_prefix}/lib
+
+Name: simavr
+Description: Virtual parts library for simavr
+Version: VERSION
+Cflags: -I${includedir}/simavr/parts
+Libs: -L${libdir} -lsimavrparts -lsimavr
index f7eccca58015256e11f108570c4b91a4b91773e6..a754467f1cc6cf516c4f1f30480f54bac6b7e93d 100644 (file)
@@ -74,31 +74,21 @@ clean: clean-${OBJ}
        rm -rf ${target} *.a *.so *.exe
        rm -f sim_core_*.h
 
-DESTDIR = /usr/local
-PREFIX = ${DESTDIR}
-
 install : all
        $(MKDIR) $(DESTDIR)/include/simavr/avr
-       $(MKDIR) $(DESTDIR)/include/simavr/parts
        $(INSTALL) -m644 sim/*.h $(DESTDIR)/include/simavr/
        $(INSTALL) -m644 sim_core_*.h $(DESTDIR)/include/simavr/
        $(INSTALL) -m644 sim/avr/*.h $(DESTDIR)/include/simavr/avr/
-       $(INSTALL) -m644 ../examples/parts/*.h $(DESTDIR)/include/simavr/parts/
        $(MKDIR) $(DESTDIR)/lib
        $(INSTALL) ${OBJ}/libsimavr.a $(DESTDIR)/lib/
-       $(INSTALL) ../examples/parts/${OBJ}/libsimavrparts.a $(DESTDIR)/lib/
        $(MKDIR) $(DESTDIR)/lib/pkgconfig/
        sed -e "s|PREFIX|${PREFIX}|g" -e "s|VERSION|${SIMAVR_VERSION}|g" \
                simavr-avr.pc >$(DESTDIR)/lib/pkgconfig/simavr-avr.pc
        sed -e "s|PREFIX|${PREFIX}|g" -e "s|VERSION|${SIMAVR_VERSION}|g" \
                simavr.pc >$(DESTDIR)/lib/pkgconfig/simavr.pc
-       sed -e "s|PREFIX|${PREFIX}|g" -e "s|VERSION|${SIMAVR_VERSION}|g" \
-               simavrparts.pc >$(DESTDIR)/lib/pkgconfig/simavrparts.pc
 ifeq (${shell uname}, Linux)
        $(INSTALL) ${OBJ}/libsimavr.so.1 $(DESTDIR)/lib/
-       $(INSTALL) ../examples/parts/${OBJ}/libsimavrparts.so.1 $(DESTDIR)/lib/
        ln -sf libsimavr.so.1 $(DESTDIR)/lib/libsimavr.so
-       ln -sf libsimavrparts.so.1 $(DESTDIR)/lib/libsimavrparts.so
 endif
        $(MKDIR) $(DESTDIR)/bin
        $(INSTALL) ${OBJ}/${target}.elf $(DESTDIR)/bin/simavr
index 6be4a2931cb8fb0ab648ed8a7108ca03a761b997..c05c7ebc7b2a91f784776103cc03883054e51118 100644 (file)
@@ -437,7 +437,7 @@ avr_timer_configure(
 
        avr_t * avr = p->io.avr;
        float resulting_clock = 0.0f; // used only for trace
-       float tov_cycles_exact;
+       float tov_cycles_exact = 0;
 
        uint8_t as2 = p->ext_clock_flags & AVR_TIMER_EXTCLK_FLAG_AS2;
        uint8_t use_ext_clock = as2 || (p->ext_clock_flags & AVR_TIMER_EXTCLK_FLAG_TN);
diff --git a/simavr/simavrparts.pc b/simavr/simavrparts.pc
deleted file mode 100644 (file)
index ba7b80e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=PREFIX
-exec_prefix=${prefix}
-includedir=${prefix}/include/
-libdir=${exec_prefix}/lib
-
-Name: simavr
-Description: Virtual parts library for simavr
-Version: VERSION
-Cflags: -I${includedir}/simavr/parts
-Libs: -L${libdir} -lsimavrparts -lsimavr