From: Neil Spring Date: Tue, 29 May 2018 15:32:49 +0000 (-0400) Subject: Fix installation of examples/parts to occur within the X-Git-Tag: v1.7~44^2 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=70548ddb6673b3e86bcc992f6164ca808d945263;p=sx%2Fsimavr.git Fix installation of examples/parts to occur within the 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). --- diff --git a/Makefile b/Makefile index 9109fb8..34b7190 100644 --- 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) diff --git a/Makefile.common b/Makefile.common index 9b56e27..8abf80c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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} diff --git a/examples/parts/Makefile b/examples/parts/Makefile index 153e64f..73de013 100644 --- a/examples/parts/Makefile +++ b/examples/parts/Makefile @@ -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 index 0000000..ba7b80e --- /dev/null +++ b/examples/parts/simavrparts.pc @@ -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 diff --git a/simavr/Makefile b/simavr/Makefile index f7eccca..a754467 100644 --- a/simavr/Makefile +++ b/simavr/Makefile @@ -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 diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index 6be4a29..c05c7eb 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -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 index ba7b80e..0000000 --- a/simavr/simavrparts.pc +++ /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