6809: build libm (sort of)
authorAlan Cox <alan@linux.intel.com>
Sun, 25 Feb 2018 17:29:42 +0000 (17:29 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 25 Feb 2018 17:29:42 +0000 (17:29 +0000)
There are some outstanding problems to fix

- We only build for float, but the C type promotion rules at this point then
  mess us up and turn the float into a double for varargs (blame the C spec)
- Several things use __NaN but that breaks on 6809 really and now we've got
  SDCC fixed we can probably switch to using 0/0 etc as we did before.

Library/include/6809/stdint.h
Library/include/math.h
Library/libs/Makefile.6809

index cd86d21..f7667e8 100644 (file)
@@ -16,4 +16,6 @@ typedef uint16_t uintptr_t;
 #define __SIZE_T_DEFINED
 #define NO_64BIT
 
+#define double float
+
 #endif
index 2e4aad6..5d25054 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _MATH_H
 #define _MATH_H
 
+#include <stdint.h>
+
 /* Large elements of this are drawn from MUSL */
 
 extern int signgam;
index 6739c8c..05a3357 100644 (file)
@@ -67,14 +67,27 @@ SRC_CT += termcap.c tgetent.c
 
 SRC_CURS = $(shell find curses -name '*.c')
 
-SRC_LM = vfscanf.c vfprintf.c
-OBJ_LM = vfscanf-libm.o vfprintf-libm.o
+SRC_LM += acosf.c acoshf.c asinf.c asinhf.c atan2f.c atanf.c atanhf.c
+SRC_LM += cbrtf.c ceilf.c copysignf.c erff.c expf.c expm1f.c
+SRC_LM += fabsf.c fdimf.c floorf.c fmaxf.c fminf.c fmodf.c frexpf.c
+SRC_LM += hypotf.c ilogbf.c j0f.c j1f.c jnf.c
+SRC_LM += ldexpf.c lgammaf.c lgammaf_r.c logf.c log2f.c log10f.c logbf.c
+SRC_LM += lrintf.c lroundf.c
+SRC_LM += modff.c nearbyintf.c nextafterf.c powf.c
+SRC_LM += remainderf.c remquof.c rintf.c roundf.c
+SRC_LM += scalbnf.c scalbinf.c
+SRC_LM += sinf.c sincosf.c sinhf.c
+SRC_LM += sqrtf.c tgammaf.c
+SRC_LM += vfscanf_m.c vfprintf_m.c
+SRC_LM += __expo2f.c __float_bits.c __fpclassifyf.c __log1pf.c __signgam.c
+
 
 OBJ_C = $(SRC_C:.c=.o)
 OBJ_CURS = $(SRC_CURS:.c=.o)
 OBJ_CT = $(SRC_CT:.c=.o)
+OBJ_LM = $(SRC_LM:.c=.o)
 OBJ_HARD = $(SRC_HARD:.c=.o)
-OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD)
+OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) $(OBJ_LM)
 
 all: syslib$(PLATFORM).lib liberror.txt $(OBJ_CRT0) curses$(PLATFORM).lib termcap$(PLATFORM).lib m$(PLATFORM).lib
 
@@ -136,11 +149,8 @@ $(OBJ_CT):%.o: %.c
 $(OBJ_CURS):%.o: %.c
        $(CC) $(CC_OPT) $(@:.o=.c) -o $@
 
-vfscanf-libm.o: vfscanf.c
-       $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@
-
-vfprintf-libm.o: vfprintf.c
-       $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@
+$(OBJ_LM):%.o: %.c
+       $(CC) $(CC_OPT) -DBUILD_LIBM $(@:.o=.c) -o $@
 
 $(OBJ_HARD):%.o: %.c
        $(CC) $(CC_NOOPT) $(@:.o=.c)