OSDN Git Service

Split up the .o and .os rules, so all the sources are created if DOPIC is disabled.
[uclinux-h8/uClibc.git] / libm / Makefile.in
index 1a90c56..b026644 100644 (file)
@@ -1,16 +1,38 @@
-# Makefile.in for uClibc
+# Makefile for uClibc
 #
-# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+# The routines included in this math library are derived from the
+# math library for Apple's MacOS X/Darwin math library, which was
+# itself swiped from FreeBSD.  The original copyright information
+# is as follows:
+#
+#     Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+#
+#     Developed at SunPro, a Sun Microsystems, Inc. business.
+#     Permission to use, copy, modify, and distribute this
+#     software is freely granted, provided that this notice
+#     is preserved.
+#
+# It has been ported to work with uClibc and generally behave
+# by Erik Andersen <andersen@codepoet.org>
 #
 
 CFLAGS+=$(SSP_ALL_CFLAGS)
 
 CFLAGS+=-D_IEEE_LIBM -D_ISOC99_SOURCE -D_SVID_SOURCE
 
+CFLAGS-s_lib_version.c=-D_POSIX_MODE
+
+#DOMULTI=n
+
 LIB_NAME:=libm
 
-srcdir=$(top_srcdir)$(LIB_NAME)
-$(LIB_NAME)_DIR:=$(top_builddir)$(LIB_NAME)
+ifeq ($(HAS_FPU),y)
+-include $(top_srcdir)libm/$(TARGET_ARCH)/Makefile.arch
+endif
 
 FL_MSRC:=float_wrappers.c
 
@@ -29,7 +51,7 @@ CSRC:=        e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \
        w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \
        w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
        w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \
-       w_sqrt.c fpmacros.c nan.c s_ceilf.c s_floorf.c
+       w_sqrt.c fpmacros.c nan.c
 FL_MOBJ:=acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \
        ceilf.o copysignf.o cosf.o coshf.o erfcf.o erff.o exp2f.o expf.o \
        expm1f.o fabsf.o fdimf.o floorf.o fmaf.o fmaxf.o fminf.o fmodf.o \
@@ -52,33 +74,64 @@ CSRC:=      w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \
 FL_MOBJ:=sqrtf.o
 endif
 
-$(LIB_NAME)_SRC:=$(patsubst %.c,$(srcdir)/%.c,$(CSRC))
-
-$(LIB_NAME)_MSRC:=$(srcdir)/$(FL_MSRC)
-$(LIB_NAME)_MOBJ:=$(patsubst %.o,$($(LIB_NAME)_DIR)/%.o,$(FL_MOBJ))
+libm_DIR:=$(top_srcdir)libm
+libm_OUT:=$(top_builddir)libm
 
+# assume that arch specific versions are provided as single sources/objects
 ifeq ($(HAS_FPU),y)
-ifeq ($(DO_C99_MATH),y)
-$(LIB_NAME)_ARCH_SRC:=$(wildcard $(srcdir)/$(TARGET_ARCH)/*.c)
-$(LIB_NAME)_ARCH_OBJ:=$(patsubst $(srcdir)/$(TARGET_ARCH)/%.c,$($(LIB_NAME)_DIR)/$(TARGET_ARCH)/%.o,$($(LIB_NAME)_ARCH_SRC))
+ifneq ($(strip $(libm_ARCH_OBJS)),)
 
 # remove generic sources, if arch specific version is present
-$(LIB_NAME)_NO_SRC:=$(patsubst $(srcdir)/$(TARGET_ARCH)/%.c,$(srcdir)/%.c,$($(LIB_NAME)_ARCH_SRC))
-$(LIB_NAME)_SRC:=$(filter-out $($(LIB_NAME)_NO_SRC),$($(LIB_NAME)_SRC))
-# add arch specific sources (assumed that these are not multi-sources)
-$(LIB_NAME)_SRC+=$($(LIB_NAME)_ARCH_SRC)
-
-# remove generic objects produced from multi-sources, if arch specific version is present
-$(LIB_NAME)_NO_MOBJ:=$(patsubst $($(LIB_NAME)_DIR)/$(TARGET_ARCH)/%.o,$($(LIB_NAME)_DIR)/%.o,$($(LIB_NAME)_ARCH_OBJ))
-$(LIB_NAME)_MOBJ:=$(filter-out $($(LIB_NAME)_NO_MOBJ),$($(LIB_NAME)_MOBJ))
+ifneq ($(strip $(libm_ARCH_SRC)),)
+CSRC:=$(filter-out $(notdir $(libm_ARCH_SRC)),$(CSRC))
+endif
+
+# remove generic objects built from multi-sources, if arch specific version is present
+FL_MOBJ:=$(filter-out $(notdir $(libm_ARCH_OBJS)),$(FL_MOBJ))
+
+# we also try to remove % if s_% is in arch specific subdir
+FL_MOBJ:=$(filter-out $(patsubst s_%.o,%.o,$(notdir $(libm_ARCH_OBJS))),$(FL_MOBJ))
+endif
 endif
+
+ifneq ($(DOMULTI),n)
+ifeq ($(DO_C99_MATH),y)
+LIBM_NO_MULTI:=s_lib_version.c
+CSRC:=$(filter-out $(LIBM_NO_MULTI),$(CSRC))
 endif
+endif
+
+libm_SRC:=$(patsubst %.c,$(libm_DIR)/%.c,$(CSRC))
+libm_OBJ:=$(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC))
 
-$(LIB_NAME)_arch_clean:
-       $(RM) $($(LIB_NAME)_DIR)/$(TARGET_ARCH)/*.{o,os}
+libm_MSRC:=$(libm_DIR)/$(FL_MSRC)
+libm_MOBJ:=$(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ))
+
+libm_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ))))
+
+libm_OBJS:=$(libm_OBJ) $(libm_MOBJ)
+ifneq ($(DOMULTI),n)
+ifeq ($(DO_C99_MATH),y)
+libm_OBJS+=$(patsubst %.c,$(libm_OUT)/%.o,$(LIBM_NO_MULTI))
+endif
+endif
+
+$(libm_MOBJ): $(libm_MSRC)
+       $(compile.m)
+
+$(libm_MOBJ:.o=.os): $(libm_MSRC)
+       $(compile.m)
+
+libm-a-$(UCLIBC_HAS_FLOATS)+=$(libm_OBJS)
+libm-so-$(UCLIBC_HAS_FLOATS)+=$(libm_OBJS:.o=.os)
+
+CFLAGS-multi-$(UCLIBC_HAS_FLOATS)+=$(libm_DEF)
+libm-multi-$(UCLIBC_HAS_FLOATS)+=$(libm_SRC) $(libm_MSRC)
+ifeq ($(DO_C99_MATH),y)
+libm-nomulti-$(UCLIBC_HAS_FLOATS)+=$(patsubst %.c,$(libm_OUT)/%.o,$(LIBM_NO_MULTI))
+endif
 
-libso-$(UCLIBC_HAS_FLOATS)+=$(top_builddir)lib/$(LIB_NAME).so
-liba-$(UCLIBC_HAS_FLOATS)+=$(top_builddir)lib/$(LIB_NAME).a
-libclean-y+=$(LIB_NAME)_clean $(LIB_NAME)_arch_clean
+objclean-y+=libm_clean
 
-include $(top_srcdir)Makefile.libs
+lib-a-$(UCLIBC_HAS_FLOATS)+=$(top_builddir)lib/libm.a
+lib-so-$(UCLIBC_HAS_FLOATS)+=$(top_builddir)lib/libm.so