From: Michel Pollet Date: Sat, 19 May 2012 14:20:10 +0000 (+0100) Subject: make: Tweaks for freebsd X-Git-Url: http://git.rot13.org/?p=simavr;a=commitdiff_plain;h=b49c5003f6f9dad3cae0cae0d334efc4c1e872e9 make: Tweaks for freebsd Use pkg-config if possible, don't use alloca() Signed-off-by: Michel Pollet --- diff --git a/examples/Makefile.opengl b/examples/Makefile.opengl new file mode 100644 index 0000000..4b1f3a8 --- /dev/null +++ b/examples/Makefile.opengl @@ -0,0 +1,18 @@ + +UNAME = ${shell uname} + +ifeq (${UNAME}, Darwin) +LDFLAGS += -framework GLUT -framework OpenGL +else +ifeq (${UNAME}, Linux) +CFLAGS += ${shell pkg-config --cflags glu} +LDFLAGS += ${shell pkg-config --libs glu} -lglut +else +CFLAGS += ${shell pkg-config --cflags glu glut} -DFREEBSD=1 +LDFLAGS += ${shell pkg-config --libs glu glut} +endif +endif + +ifeq (${UNAME}, FreeBSD) +CFLAGS += -DFREEBSD=1 -DNO_ALLOCA=1 +endif diff --git a/examples/board_hd77480/Makefile b/examples/board_hd77480/Makefile index dcae864..9666fa0 100644 --- a/examples/board_hd77480/Makefile +++ b/examples/board_hd77480/Makefile @@ -30,11 +30,8 @@ VPATH = . VPATH += ../parts LDFLAGS += -lpthread -ifneq (${shell uname}, Darwin) -LDFLAGS += -lGL -lglut -else -LDFLAGS += -framework GLUT -framework OpenGL -endif + +include ../Makefile.opengl all: obj atmega48_charlcd.axf ${target} diff --git a/examples/board_ledramp/Makefile b/examples/board_ledramp/Makefile index 6a537d2..92dfc08 100644 --- a/examples/board_ledramp/Makefile +++ b/examples/board_ledramp/Makefile @@ -30,11 +30,8 @@ VPATH = . VPATH += ../parts LDFLAGS += -lpthread -ifneq (${shell uname}, Darwin) -LDFLAGS += -lGL -lglut -else -LDFLAGS += -framework GLUT -framework OpenGL -endif + +include ../Makefile.opengl all: obj ${firmware} ${target} diff --git a/examples/board_reprap/Makefile b/examples/board_reprap/Makefile index 7a6ceb1..ccc3f4d 100644 --- a/examples/board_reprap/Makefile +++ b/examples/board_reprap/Makefile @@ -37,11 +37,8 @@ VPATH += ../shared CFLAGS += -DMOTHERBOARD=91 CFLAGS += ${shell pkg-config --cflags pangocairo} -ifneq (${shell uname}, Darwin) -LDFLAGS += -lGL -lglut -lGLU -else -LDFLAGS += -framework GLUT -framework OpenGL -endif +include ../Makefile.opengl + LDFLAGS += ${shell pkg-config --libs pangocairo} LDFLAGS += -lpthread -lutil -ldl LDFLAGS += -lm diff --git a/examples/board_reprap/src/c3/c_utils.h b/examples/board_reprap/src/c3/c_utils.h index e6bad57..2360fd8 100644 --- a/examples/board_reprap/src/c3/c_utils.h +++ b/examples/board_reprap/src/c3/c_utils.h @@ -26,6 +26,9 @@ #ifndef __C_UTILS_H__ #define __C_UTILS_H__ +#ifndef NO_ALLOCA +#include +#endif #include "c_array.h" /******************************************************************** @@ -107,6 +110,7 @@ static inline str_p str_dup(const str_p s) memcpy(r, s, l); return r; } +#ifndef NO_ALLOCA static inline str_p str_adup(const str_p s) { size_t l = sizeof(*s) + s->len + 1; @@ -115,6 +119,7 @@ static inline str_p str_adup(const str_p s) r->rom = 1; return r; } +#endif static inline uint16_t str_hash(str_p s) { if (!s->hash) s->hash = crc16_string(s->str); diff --git a/examples/board_simduino/Makefile b/examples/board_simduino/Makefile index 75de2bf..cf72f33 100644 --- a/examples/board_simduino/Makefile +++ b/examples/board_simduino/Makefile @@ -30,11 +30,8 @@ VPATH = . VPATH += ../parts LDFLAGS += -lpthread -lutil -ifneq (${shell uname}, Darwin) -LDFLAGS += -lGL -lglut -else -LDFLAGS += -framework GLUT -framework OpenGL -endif + +include ../Makefile.opengl all: obj ${firmware} ${target} diff --git a/examples/board_timer_64led/Makefile b/examples/board_timer_64led/Makefile index 665025f..231ae92 100644 --- a/examples/board_timer_64led/Makefile +++ b/examples/board_timer_64led/Makefile @@ -30,11 +30,8 @@ VPATH = . VPATH += ../parts LDFLAGS += -lpthread -ifneq (${shell uname}, Darwin) -LDFLAGS += -lGL -lglut -else -LDFLAGS += -framework GLUT -framework OpenGL -endif + +include ../Makefile.opengl all: obj ${firmware} ${target}