# HG changeset patch # User John Tsiombikas # Date 1315184920 -10800 # Node ID 6bab2c0b0e4b5c3487ad7a8df7d41b265ca64666 # Parent d7d173fcd44ef1920279834dbc1e0d715348c7ad - added a shared library rule - changed all the names from dsys2 to dsys diff -r d7d173fcd44e -r 6bab2c0b0e4b Makefile --- a/Makefile Mon Sep 05 03:05:24 2011 +0300 +++ b/Makefile Mon Sep 05 04:08:40 2011 +0300 @@ -4,11 +4,29 @@ obj = $(src:.c=.o) dep = $(obj:.o=.d) -lib_a = libdsys2.a +lib_a = libdsys.a +soname = libdsys.so.$(somajor) +lib_so = $(lib_so_$(sys)) + +somajor = 0 +sominor = 0 + +lib_so_unix = $(soname).$(sominor) +lib_so_mac = libdsys.dylib + +sharedopt_unix = -shared -Wl,-soname,$(soname) +sharedopt_mac = -dynamiclib + +ifeq ($(shell uname -s), Darwin) + sys = mac +else + sys = unix +endif + CC = gcc AR = ar -CFLAGS = -pedantic -Wall -g -Isrc +CFLAGS = -pedantic -Wall -g -Isrc -fPIC ifeq ($(shell uname -s), Darwin) libgl = -framework OpenGL -framework GLUT @@ -16,12 +34,15 @@ libgl = -lGL -lGLU -lglut endif -test: test.o $(lib_a) +test: test.o $(lib_a) $(lib_so) $(CC) $(CFLAGS) -o $@ test.o $(lib_a) $(libgl) -lm $(lib_a): $(obj) $(AR) rcs $@ $(obj) +$(lib_so): $(obj) + $(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS) + -include $(dep) %.d: %.c @@ -29,7 +50,7 @@ .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(obj) $(bin) $(lib_a) $(lib_so) .PHONY: cleandep cleandep: @@ -39,8 +60,9 @@ install: $(lib_a) mkdir -p $(PREFIX)/include $(PREFIX)/lib cp $(lib_a) $(PREFIX)/lib/$(lib_a) - cp src/dsys2.h $(PREFIX)/include/dsys2.h + cp $(lib_so) $(PREFIX)/lib/$(lib_so) + cp src/dsys.h $(PREFIX)/include/dsys.h .PHONY: uninstall uninstall: - rm -f $(PREFIX)/include/dsys2.h $(PREFIX)/lib/$(lib_a) + rm -f $(PREFIX)/include/dsys.h $(PREFIX)/lib/$(lib_a) $(PREFIX)/lib/$(lib_so) diff -r d7d173fcd44e -r 6bab2c0b0e4b src/dsys.c --- a/src/dsys.c Mon Sep 05 03:05:24 2011 +0300 +++ b/src/dsys.c Mon Sep 05 04:08:40 2011 +0300 @@ -4,7 +4,7 @@ #include #include #include -#include "dsys2.h" +#include "dsys.h" #include "dsys_impl.h" static int read_script(struct dsys_demo *demo, FILE *fp, const char *fname); diff -r d7d173fcd44e -r 6bab2c0b0e4b src/dsys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dsys.h Mon Sep 05 04:08:40 2011 +0300 @@ -0,0 +1,71 @@ +#ifndef DSYS2_H_ +#define DSYS2_H_ + +#include + +struct dsys_demo; +struct dsys_event; + +typedef float demotime_t; + +enum dsys_evtype { + DSYS_SINGLE, + DSYS_PERIODIC +}; + +#ifdef __cplusplus +extern "C" { +#endif + +struct dsys_demo *dsys_open(const char *fname); +struct dsys_demo *dsys_open_stream(FILE *fp); +void dsys_close(struct dsys_demo *demo); + +void dsys_update(struct dsys_demo *demo, demotime_t tm); + + +void dsys_start(struct dsys_demo *demo); +void dsys_stop(struct dsys_demo *demo); +int dsys_is_running(struct dsys_demo *demo); + + +demotime_t dsys_duration(struct dsys_demo *demo); +demotime_t dsys_time(struct dsys_demo *demo); +float dsys_progress(struct dsys_demo *demo); + +/* seek without continuity */ +void dsys_seek(struct dsys_demo *demo, demotime_t tm); +void dsys_seek_norm(struct dsys_demo *demo, float t); + +/* seek by accelerating time */ +void dsys_warp(struct dsys_demo *demo, demotime_t tm); +void dsys_warp_norm(struct dsys_demo *demo, float t); + + +/* events */ +struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name); + +enum dsys_evtype dsys_event_type(struct dsys_event *ev); +float dsys_event_value(struct dsys_event *ev); + +int dsys_event_callback(struct dsys_event *ev, void (*func)(struct dsys_event*, void*), void *cls); +int dsys_event_link(struct dsys_event *ev, float *link); + +/* event evaluators */ +float dsys_eval_step(struct dsys_event *ev, demotime_t t); +float dsys_eval_lerp(struct dsys_event *ev, demotime_t t); +float dsys_eval_sigmoid(struct dsys_event *ev, demotime_t t); + +/* time conversion */ +demotime_t dsys_sec_to_dtime(float sec); +demotime_t dsys_msec_to_dtime(unsigned long msec); + +float dsys_dtime_to_sec(demotime_t tm); +unsigned long dsys_dtime_to_msec(demotime_t tm); + +#ifdef __cplusplus +} +#endif + + +#endif /* DSYS2_H_ */ diff -r d7d173fcd44e -r 6bab2c0b0e4b src/dsys2.h --- a/src/dsys2.h Mon Sep 05 03:05:24 2011 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -#ifndef DSYS2_H_ -#define DSYS2_H_ - -#include - -struct dsys_demo; -struct dsys_event; - -typedef float demotime_t; - -enum dsys_evtype { - DSYS_SINGLE, - DSYS_PERIODIC -}; - -#ifdef __cplusplus -extern "C" { -#endif - -struct dsys_demo *dsys_open(const char *fname); -struct dsys_demo *dsys_open_stream(FILE *fp); -void dsys_close(struct dsys_demo *demo); - -void dsys_update(struct dsys_demo *demo, demotime_t tm); - - -void dsys_start(struct dsys_demo *demo); -void dsys_stop(struct dsys_demo *demo); -int dsys_is_running(struct dsys_demo *demo); - - -demotime_t dsys_duration(struct dsys_demo *demo); -demotime_t dsys_time(struct dsys_demo *demo); -float dsys_progress(struct dsys_demo *demo); - -/* seek without continuity */ -void dsys_seek(struct dsys_demo *demo, demotime_t tm); -void dsys_seek_norm(struct dsys_demo *demo, float t); - -/* seek by accelerating time */ -void dsys_warp(struct dsys_demo *demo, demotime_t tm); -void dsys_warp_norm(struct dsys_demo *demo, float t); - - -/* events */ -struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name); - -enum dsys_evtype dsys_event_type(struct dsys_event *ev); -float dsys_event_value(struct dsys_event *ev); - -int dsys_event_callback(struct dsys_event *ev, void (*func)(struct dsys_event*, void*), void *cls); -int dsys_event_link(struct dsys_event *ev, float *link); - -/* event evaluators */ -float dsys_eval_step(struct dsys_event *ev, demotime_t t); -float dsys_eval_lerp(struct dsys_event *ev, demotime_t t); -float dsys_eval_sigmoid(struct dsys_event *ev, demotime_t t); - -/* time conversion */ -demotime_t dsys_sec_to_dtime(float sec); -demotime_t dsys_msec_to_dtime(unsigned long msec); - -float dsys_dtime_to_sec(demotime_t tm); -unsigned long dsys_dtime_to_msec(demotime_t tm); - -#ifdef __cplusplus -} -#endif - - -#endif /* DSYS2_H_ */ diff -r d7d173fcd44e -r 6bab2c0b0e4b src/dsys_impl.h --- a/src/dsys_impl.h Mon Sep 05 03:05:24 2011 +0300 +++ b/src/dsys_impl.h Mon Sep 05 04:08:40 2011 +0300 @@ -1,7 +1,7 @@ #ifndef DSYS_IMPL_H_ #define DSYS_IMPL_H_ -#include "dsys2.h" +#include "dsys.h" struct dsys_demo { demotime_t tm, src_tm, start_tm, stop_tm, duration;