make: Tweaks for freebsd
authorMichel Pollet <buserror@gmail.com>
Sat, 19 May 2012 14:20:10 +0000 (15:20 +0100)
committerMichel Pollet <buserror@gmail.com>
Sat, 19 May 2012 14:20:10 +0000 (15:20 +0100)
Use pkg-config if possible, don't use alloca()

Signed-off-by: Michel Pollet <buserror@gmail.com>
examples/Makefile.opengl [new file with mode: 0644]
examples/board_hd77480/Makefile
examples/board_ledramp/Makefile
examples/board_reprap/Makefile
examples/board_reprap/src/c3/c_utils.h
examples/board_simduino/Makefile
examples/board_timer_64led/Makefile

diff --git a/examples/Makefile.opengl b/examples/Makefile.opengl
new file mode 100644 (file)
index 0000000..4b1f3a8
--- /dev/null
@@ -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
index dcae864..9666fa0 100644 (file)
@@ -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} 
 
index 6a537d2..92dfc08 100644 (file)
@@ -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}
 
index 7a6ceb1..ccc3f4d 100644 (file)
@@ -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
index e6bad57..2360fd8 100644 (file)
@@ -26,6 +26,9 @@
 #ifndef __C_UTILS_H__
 #define __C_UTILS_H__
 
+#ifndef NO_ALLOCA
+#include <alloca.h>
+#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);
index 75de2bf..cf72f33 100644 (file)
@@ -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}
 
index 665025f..231ae92 100644 (file)
@@ -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}