Browse Source

automatic arch selection in Makefile

Keno Fischer 12 years ago
parent
commit
307d7361c5
11 changed files with 119 additions and 14 deletions
  1. 9 2
      Make.inc
  2. 27 10
      Makefile
  3. 6 0
      amd64/Make.files
  4. 1 0
      bsdsrc/Make.files
  5. 16 0
      i387/Make.files
  6. 1 0
      ld128/Make.files
  7. 1 1
      ld128/invtrig.c
  8. 2 0
      ld80/Make.files
  9. 1 1
      ld80/invtrig.c
  10. 54 0
      src/Make.files
  11. 1 0
      src/math_private.h

+ 9 - 2
Make.inc

@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS= -Wall -O2 -I. -I.. -I../include -I../ld128 -I../src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
+CFLAGS= -Wall -O2 -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/ld80 -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
 
 default: all
 
@@ -7,7 +7,7 @@ default: all
 	$(QUIET_CC)$(CC) $(CFLAGS) -c $< -o $@
 
 %.S.o: %.S
-	$(CC) $(filter -f% -m% -B% -I% -D%,$(CFLAGS)) -c $< -o $@
+	$(QUIET_ASM)$(CC) $(filter -f% -m% -B% -I% -D%,$(CFLAGS)) -c $< -o $@
 
 clean:
 	rm -f *.o *.c.o *.S.o *~
@@ -16,6 +16,13 @@ clean:
 OS = $(shell uname)
 ARCH = $(shell uname -m)
 
+ifeq ($(ARCH),i386)
+override ARCH = i387
+endif
+
+ifeq ($(ARCH),x86_64)
+override ARCH = amd64
+endif 
 
 ifeq ($(OS), MINGW32_NT-6.1)
 OS=WINNT

+ 27 - 10
Makefile

@@ -1,14 +1,31 @@
+OPENLIBM_HOME=$(abspath .)
 include ./Make.inc
 
-all:
-	$(MAKE) -C src all
-	$(MAKE) -C ld128 all
-	$(MAKE) -C bsdsrc all
-	$(QUIET_LINK)ar -rcs libopenlibm.a src/*.c.o ld128/*.c.o bsdsrc/*.c.o
-	$(QUIET_LINK)$(CC) -shared -fPIC src/*.c.o ld128/*.c.o bsdsrc/*.c.o -o libopenlibm.$(SHLIB_EXT)
+SUBDIRS = src ld80 $(ARCH) bsdsrc
+
+define INC_template
+TEST=test
+override CUR_SRCS = $(1)_SRCS
+include $(1)/Make.files
+SRCS += $$(addprefix $(1)/,$$($(1)_SRCS))
+endef
+
+DIR=test
+
+$(foreach dir,$(SUBDIRS),$(eval $(call INC_template,$(dir))))
+
+DUPLICATE_NAMES = $(filter $(patsubst %.S,%,$($(ARCH)_SRCS)),$(patsubst %.c,%,$(src_SRCS)))
+DUPLICATE_SRCS = $(addsuffix .c,$(DUPLICATE_NAMES))
+
+OBJS = $(patsubst %.S,%.S.o,\
+	$(patsubst %.c,%.c.o,$(filter-out $(addprefix src/,$(DUPLICATE_SRCS)),$(SRCS))))
+all: libopenlibm.a libopenlibm.$(SHLIB_EXT) 
+libopenlibm.a: $(OBJS)  
+	$(QUIET_LINK)ar -rcs libopenlibm.a $(OBJS)
+libopenlibm.$(SHLIB_EXT): $(OBJS)
+	$(QUIET_LINK)$(CC) -shared -fPIC $(OBJS) -o libopenlibm.$(SHLIB_EXT)
+echo:
+	echo $(TEST)
 
 cleanall:
-	$(MAKE) -C src clean
-	$(MAKE) -C ld128 clean
-	$(MAKE) -C bsdsrc clean
-	rm -f *.a *.$(SHLIB_EXT)
+	rm -f $(OBJS) *.a *.$(SHLIB_EXT)

+ 6 - 0
amd64/Make.files

@@ -0,0 +1,6 @@
+$(CUR_SRCS) = e_remainder.S e_remainderf.S e_remainderl.S \
+	    e_sqrt.S e_sqrtf.S e_sqrtl.S \
+	    s_llrint.S s_llrintf.S s_llrintl.S \
+	    s_logbl.S s_lrint.S s_lrintf.S s_lrintl.S \
+	    s_remquo.S s_remquof.S s_remquol.S \
+	    s_rintl.S s_scalbn.S s_scalbnf.S s_scalbnl.S

+ 1 - 0
bsdsrc/Make.files

@@ -0,0 +1 @@
+$(CUR_SRCS) +=	b_exp.c    b_log.c    b_tgamma.c

+ 16 - 0
i387/Make.files

@@ -0,0 +1,16 @@
+ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \
+	    e_remainder.S e_sqrt.S s_ceil.S s_copysign.S \
+	    s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \
+	    s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S \
+	    s_trunc.S
+
+# float counterparts
+ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S \
+	    e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \
+	    s_llrintf.S s_logbf.S s_lrintf.S \
+	    s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S
+
+# long double counterparts
+ARCH_SRCS+= e_remainderl.S e_sqrtl.S s_ceill.S s_copysignl.S \
+	    s_floorl.S s_llrintl.S \
+	    s_logbl.S s_lrintl.S s_remquol.S s_rintl.S s_scalbnl.S s_truncl.S

+ 1 - 0
ld128/Make.files

@@ -0,0 +1 @@
+SRCS = invtrig.c k_cosl.c k_sinl.c k_tanl.c # s_nanl.c s_exp2l.c 

+ 1 - 1
ld128/invtrig.c

@@ -27,7 +27,7 @@
 #include "cdefs-compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/ld128/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $");
 
-#include "invtrig.h"
+#include "ld128/invtrig.h"
 
 /*
  * asinl() and acosl()

+ 2 - 0
ld80/Make.files

@@ -0,0 +1,2 @@
+$(CUR_SRCS) += 	invtrig.c k_cosl.c k_sinl.c\
+		k_tanl.c s_exp2l.c s_nanl.c

+ 1 - 1
ld80/invtrig.c

@@ -27,7 +27,7 @@
 #include "cdefs-compat.h"
 //__FBSDID("$FreeBSD: src/lib/msun/ld80/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $");
 
-#include "invtrig.h"
+#include "ld80/invtrig.h"
 
 /*
  * asinl() and acosl()

+ 54 - 0
src/Make.files

@@ -0,0 +1,54 @@
+$(CUR_SRCS) = \
+        e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
+        e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \
+        e_expf.c e_fmod.c e_fmodf.c e_gamma.c e_gamma_r.c e_gammaf.c \
+        e_gammaf_r.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c e_j1.c e_j1f.c \
+        e_jn.c e_jnf.c e_lgamma.c e_lgamma_r.c e_lgammaf.c e_lgammaf_r.c \
+        e_log.c e_log10.c e_log10f.c e_log2.c e_log2f.c e_logf.c \
+        e_pow.c e_powf.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
+        e_rem_pio2.c e_rem_pio2f.c \
+        e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c \
+        k_cos.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_tan.c \
+        k_cosf.c k_sinf.c k_tanf.c \
+        s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
+        s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \
+        s_copysign.c s_copysignf.c s_cos.c s_cosf.c \
+        s_csqrt.c s_csqrtf.c s_erf.c s_erff.c \
+        s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabs.c s_fabsf.c s_fdim.c \
+        s_finite.c s_finitef.c \
+        s_floor.c s_floorf.c s_fma.c s_fmaf.c \
+        s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \
+        s_fminf.c s_fminl.c s_fpclassify.c \
+        s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
+        s_ilogbl.c s_isinf.c s_isfinite.c s_isnormal.c s_isnan.c \
+        s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_llroundl.c \
+        s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \
+        s_lround.c s_lroundf.c s_lroundl.c s_modf.c s_modff.c \
+        s_nan.c s_nearbyint.c s_nextafter.c s_nextafterf.c \
+        s_nexttowardf.c s_remquo.c s_remquof.c \
+        s_rint.c s_rintf.c s_round.c s_roundf.c s_roundl.c \
+        s_scalbln.c s_scalbn.c s_scalbnf.c s_signbit.c \
+        s_signgam.c s_significand.c s_significandf.c s_sin.c s_sinf.c \
+        s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c s_trunc.c s_truncf.c \
+        w_cabs.c w_cabsf.c w_drem.c w_dremf.c
+
+# C99 long double functions
+$(CUR_SRCS) +=	s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
+
+# If long double != double use these; otherwise, we alias the double versions.
+$(CUR_SRCS) +=	e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
+        e_hypotl.c e_remainderl.c e_sqrtl.c \
+        s_atanl.c s_ceill.c s_cosl.c s_cprojl.c \
+        s_csqrtl.c s_floorl.c s_fmal.c \
+        s_frexpl.c s_logbl.c s_nexttoward.c \
+        s_remquol.c \
+        s_sinl.c s_tanl.c s_truncl.c w_cabsl.c \
+        s_nextafterl.c s_rintl.c s_scalbnl.c
+#	s_cbrtl.c
+
+# C99 complex functions
+$(CUR_SRCS) +=	s_ccosh.c s_ccoshf.c s_cexp.c s_cexpf.c \
+        s_cimag.c s_cimagf.c s_cimagl.c \
+        s_conj.c s_conjf.c s_conjl.c \
+        s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \
+        s_csinh.c s_csinhf.c s_ctanh.c s_ctanhf.c

+ 1 - 0
src/math_private.h

@@ -20,6 +20,7 @@
 #include "types-compat.h"
 #include "fpmath.h"
 #include <complex.h>
+#include <stdint.h>
 
 /*
  * The original fdlibm code used statements like: