0001-Move-to-RIOT-Makefiles.patch 4.86 KB
From 07ab6c2cb9e4b03b3e413a733850f3f8199149d1 Mon Sep 17 00:00:00 2001
From: Martine Lenders <mail@martine-lenders.eu>
Date: Thu, 12 May 2016 14:55:13 +0200
Subject: [PATCH 1/3] Move to RIOT Makefiles

---
 Makefile            |  8 ++++++
 libfixmath/Makefile | 51 +++----------------------------------
 unittests/Makefile  | 73 ++---------------------------------------------------
 3 files changed, 13 insertions(+), 119 deletions(-)
 create mode 100644 Makefile

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b65e4b5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+ifneq (,$(filter libfixmath,$(USEMODULE)))
+    DIRS += libfixmath
+endif
+ifneq (,$(filter libfixmath-unittests,$(USEMODULE)))
+    DIRS += unittests
+endif
+
+include $(RIOTBASE)/Makefile.base
diff --git a/libfixmath/Makefile b/libfixmath/Makefile
index b284590..c875b98 100644
--- a/libfixmath/Makefile
+++ b/libfixmath/Makefile
@@ -1,48 +1,3 @@
-#Project settings
-PROJECT = libfixmath
-LIB =
-SRC = .
-INC =
-
-#Compiler settings
-CPP = gcc
-CC = gcc
-AS = gcc
-LD = gcc
-AR = ar
-CPP_FLAGS = -O2 $(INC) -Wall -Wextra -c
-CC_FLAGS  = -O2 $(INC) -Wall -Wextra -c
-AS_FLAGS  = $(CC_FLAGS) -D_ASSEMBLER_
-LD_FLAGS = -Wall
-
-# Find all source files
-SRC_CPP = $(foreach dir, $(SRC), $(wildcard $(dir)/*.cpp))
-SRC_C   = $(foreach dir, $(SRC), $(wildcard $(dir)/*.c))
-SRC_S   = $(foreach dir, $(SRC), $(wildcard $(dir)/*.S))
-OBJ_CPP = $(patsubst %.cpp, %.o, $(SRC_CPP))
-OBJ_C   = $(patsubst %.c, %.o, $(SRC_C))
-OBJ_S   = $(patsubst %.S, %.o, $(SRC_S))
-OBJ     = $(OBJ_CPP) $(OBJ_C) $(OBJ_S)
-
-# Compile rules.
-.PHONY : all
-all: $(PROJECT).a
-
-$(PROJECT).a: $(OBJ)
-	$(AR) rcs $(PROJECT).a $(OBJ)
-
-$(OBJ_CPP) : %.o : %.cpp
-	$(CPP) $(CPP_FLAGS) -o $@ $<
-
-$(OBJ_C) : %.o : %.c
-	$(CC) $(CC_FLAGS) -o $@ $<
-
-$(OBJ_S) : %.o : %.S
-	$(AS) $(AS_FLAGS) -o $@ $<
-
-
-
-# Clean rules
-.PHONY : clean
-clean:
-	rm -f $(PROJECT).a $(OBJ)
+MODULE = libfixmath
+
+include $(RIOTBASE)/Makefile.base
diff --git a/unittests/Makefile b/unittests/Makefile
index 329caf4..245ffb9 100644
--- a/unittests/Makefile
+++ b/unittests/Makefile
@@ -1,72 +1,3 @@
-# Makefile for running the unittests of libfixmath.
-CC = gcc
-
-# Basic CFLAGS for debugging
-CFLAGS = -g -O0 -I../libfixmath -Wall -Wextra -Werror
-
-# The files required for tests
-FIX16_SRC = ../libfixmath/fix16.c ../libfixmath/fix16_sqrt.c ../libfixmath/fix16_str.c \
-	../libfixmath/fix16_exp.c ../libfixmath/fix16.h
-
-all: run_fix16_unittests run_fix16_exp_unittests run_fix16_str_unittests run_fix16_macros_unittests
-
-clean:
-	rm -f fix16_unittests_????
-
-# The library is tested automatically under different compilations
-# options.
-#
-# Test naming:
-# r = rounding, n = no rounding
-# o = overflow detection, n = no overflow detection
-# 64 = int64_t math, 32 = int32_t math
-
-run_fix16_unittests: \
-	fix16_unittests_ro64 fix16_unittests_no64 \
-	fix16_unittests_rn64 fix16_unittests_nn64 \
-	fix16_unittests_ro32 fix16_unittests_no32 \
-	fix16_unittests_rn32 fix16_unittests_nn32 \
-	fix16_unittests_ro08 fix16_unittests_no08 \
-	fix16_unittests_rn08 fix16_unittests_nn08
-	$(foreach test, $^, \
-	echo $(test) && \
-	./$(test) > /dev/null && \
-	) true
-
-fix16_unittests_no64: DEFINES=-DFIXMATH_NO_ROUNDING
-fix16_unittests_rn64: DEFINES=-DFIXMATH_NO_OVERFLOW
-fix16_unittests_nn64: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_NO_OVERFLOW
-fix16_unittests_ro32: DEFINES=-DFIXMATH_NO_64BIT
-fix16_unittests_no32: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_NO_64BIT
-fix16_unittests_rn32: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_64BIT
-fix16_unittests_nn32: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_ROUNDING -DFIXMATH_NO_64BIT
-fix16_unittests_ro08: DEFINES=-DFIXMATH_OPTIMIZE_8BIT
-fix16_unittests_no08: DEFINES=-DFIXMATH_NO_ROUNDING -DFIXMATH_OPTIMIZE_8BIT
-fix16_unittests_rn08: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_OPTIMIZE_8BIT
-fix16_unittests_nn08: DEFINES=-DFIXMATH_NO_OVERFLOW -DFIXMATH_NO_ROUNDING -DFIXMATH_OPTIMIZE_8BIT
-
-fix16_unittests_% : fix16_unittests.c $(FIX16_SRC)
-	$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
-
-
-# Tests for the exponential function, run only in default config
-run_fix16_exp_unittests: fix16_exp_unittests
-	./fix16_exp_unittests > /dev/null
-
-fix16_exp_unittests: fix16_exp_unittests.c $(FIX16_SRC)
-	$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
-	
-# Tests for string conversion, run only in default config
-run_fix16_str_unittests: fix16_str_unittests
-	./fix16_str_unittests > /dev/null
-
-fix16_str_unittests: fix16_str_unittests.c $(FIX16_SRC)
-	$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
-
-# Tests for literal macros, run only in default config
-run_fix16_macros_unittests: fix16_macros_unittests
-	./fix16_macros_unittests > /dev/null
-
-fix16_macros_unittests: fix16_macros_unittests.c $(FIX16_SRC)
-	$(CC) $(CFLAGS) $(DEFINES) -o $@ $^ -lm
+MODULE = libfixmath-unittests
 
+include $(RIOTBASE)/Makefile.base
-- 
2.7.4