From 05f371e2370b60439f0681f9b36799338b2f80bf Mon Sep 17 00:00:00 2001
From: Tommy Olofsson <tommy.olofsson.90@gmail.com>
Date: Wed, 16 Apr 2014 16:12:50 +0200
Subject: [PATCH] Cleaned up the support for cross compilation of the C
 library.

---
 lib/c/Makefile | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/c/Makefile b/lib/c/Makefile
index c5af86b..46c7ad5 100644
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -4,21 +4,14 @@ ALL_DEPS=liblabcomm.a liblabcomm.so.1
 
 ifeq ($(UNAME_S),Linux)
   CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest
-  ifndef TARGET
-    CC=gcc	
-  else ifeq ($(TARGET),vx)
-    CC=i586-wrs-vxworks-gcc
-    LD=i586-wrs-vxworks-ld
-    ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS))
-    CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\"
-  else
-    @echo 'Invalid target.'
-  endif
+  CC=$(CROSS_COMPILE)gcc
+  LD=$(CROSS_COMPILE)ld
   LDFLAGS=-L.
   LDLIBS=-llabcomm -lrt
   MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt
 else ifeq ($(UNAME_S),Darwin)
-  CC=clang
+  CC=$(CROSS_COMPILE)clang
+  LD=$(CROSS_COMPILE)ld
   CFLAGS=-g -Wall -Werror -O3  -I. -Itest \
 	 -DLABCOMM_COMPAT=\"labcomm_compat_osx.h\" \
 	 -Wno-tautological-compare -Wno-unused-function
@@ -28,6 +21,13 @@ else ifeq ($(UNAME_S),Darwin)
 else
   $(error Unknown system $(UNAME_S))
 endif
+# TODO: How to handle Cygwin?
+
+ifeq ($(CROSS_COMPILE),i586-wrs-vxworks-)
+  ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # PIC is only supported for RTPs
+  CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\"
+endif
+# TODO: Support for Codesourcery ARM toolchain.
 
 OBJS=labcomm_memory.o \
      labcomm_error.o \
-- 
GitLab