1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
14# Copyright (c) 2019, Joyent, Inc.
15#
16
17LIBMDIR		= $(SRC)/lib/libm
18
19LIBMSRC		= $(LIBMDIR)/common
20
21CPP_CMD		= $(CC) -E -Xs
22
23# With studio CSTD of neither enabled nor disabled is "no_lib", whereby we
24# expect C99-the-language, but don't modify the behaviour of library routines.
25# This is VERY IMPORTANT, as $(CSTD_GNU99), for instance, would link us with
26# values-xpg6, which would introduce an __xpg6 to our object with the C99
27# flags set, causing us to default C99 libm behaviour on, breaking
28# compatibility.
29#
30# We must then, unfortunately, defeat the GNU compiler _defaulting_ to C99, by
31# in that case setting it back to gnu89, which _also_ accepts C99 syntax as
32# far as is important.
33CSTD		=
34CFLAGS		+= -_gcc=-std=gnu89
35CFLAGS64	+= -_gcc=-std=gnu89
36
37M4FLAGS		= -D__STDC__ -DPIC
38
39LDBLDIR_sparc	= Q
40LDBLDIR_i386	= LD
41LDBLDIR		= $(LDBLDIR_$(MACH))
42
43CFLAGS		+= $(C_PICFLAGS)
44CFLAGS64	+= $(C_PICFLAGS)
45sparc_CFLAGS	+= -Wa,-xarch=v8plus
46
47CPPFLAGS	+= -I$(LIBMSRC)/C \
48		-I$(LIBMSRC)/$(LDBLDIR) -I$(LIBMDIR)/$(TARGET_ARCH)/src
49$(RELEASE_BUILD)CPPFLAGS += -DNDEBUG
50
51# GCC needs __C99FEATURES__ such that the implementations of isunordered,
52# isgreaterequal, islessequal, etc, exist.  This is basically equivalent to
53# providing no -xc99 to Studio, in that it gets us the C99 language features,
54# but not values-xpg6, the reason for which is outlined with CSTD.
55CFLAGS		+= -_gcc=-D__C99FEATURES__
56CFLAGS64	+= -_gcc=-D__C99FEATURES__
57
58# libm depends on integer overflow characteristics
59CFLAGS		+= -_gcc=-fno-strict-overflow
60CFLAGS64	+= -_gcc=-fno-strict-overflow
61
62# sparse currently has no _Complex support
63CFLAGS		+= -_smatch=off
64CFLAGS64	+= -_smatch=off
65
66$(DYNLIB)	:= LDLIBS += -lc
67
68
69CLEANFILES	+= pics/*.s pics/*.S
70
71FPDEF_amd64	= -DARCH_amd64
72FPDEF_sparc	= -DCG89 -DARCH_v8plus -DFPADD_TRAPS_INCOMPLETE_ON_NAN
73FPDEF_sparcv9	= -DARCH_v9 -DFPADD_TRAPS_INCOMPLETE_ON_NAN
74FPDEF		= $(FPDEF_$(TARGET_ARCH))
75
76ASFLAGS		+= -D_ASM $(FPDEF)
77ASFLAGS64	+= -D_ASM $(FPDEF)
78
79XARCH_sparc	= v8plus
80XARCH_sparcv9	= v9
81XARCH_i386	= f80387
82XARCH_amd64	= amd64
83XARCH		= $(XARCH_$(TARGET_ARCH))
84
85ASOPT_sparc	= -xarch=$(XARCH) $(AS_PICFLAGS)
86ASOPT_sparcv9	= -xarch=$(XARCH) $(AS_PICFLAGS)
87ASOPT_i386	=
88ASOPT_amd64	= -xarch=$(XARCH) $(AS_PICFLAGS)
89ASOPT		= $(ASOPT_$(TARGET_ARCH))
90
91ASFLAGS		+= $(ASOPT)
92ASFLAGS64	+= $(ASOPT)
93
94CPPFLAGS_sparc = -DFPADD_TRAPS_INCOMPLETE_ON_NAN \
95	-DFDTOS_TRAPS_INCOMPLETE_IN_FNS_MODE
96
97CPPFLAGS	+= $(CPPFLAGS_$(MACH))
98ASFLAGS		+= $(CPPFLAGS)
99ASFLAGS64	+= $(CPPFLAGS)
100