OpenLibm/Make.inc

177 lines
4.0 KiB
PHP
Raw Permalink Normal View History

2012-10-29 10:30:54 +01:00
# -*- mode: makefile-gmake -*-
# Default build rule for any Makefile in this project: all
default: all
OS := $(shell uname)
# Do not forget to bump SOMINOR when changing VERSION,
2014-07-29 15:46:20 +02:00
# and SOMAJOR when breaking ABI in a backward-incompatible way
2019-12-10 03:43:44 +01:00
VERSION = 0.7.0
SOMAJOR = 3
SOMINOR = 0
2014-01-04 21:37:17 +01:00
DESTDIR =
prefix ?= /usr/local
bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
includedir ?= $(prefix)/include
2012-07-03 13:19:19 +02:00
ifeq ($(OS), FreeBSD)
pkgconfigdir ?= $(prefix)/libdata/pkgconfig
else
pkgconfigdir ?= $(libdir)/pkgconfig
endif
USEGCC ?= 1
USECLANG ?= 0
2012-07-03 13:19:19 +02:00
ifneq (,$(findstring $(OS),Darwin FreeBSD OpenBSD))
USEGCC ?= 0
USECLANG ?= 1
endif
2019-04-15 00:11:03 +02:00
ifeq ($(ARCH),wasm32)
2020-11-14 05:14:33 +01:00
USECLANG = 1
TOOLPREFIX = llvm-
2019-04-15 00:11:03 +02:00
endif
2020-11-14 05:14:33 +01:00
AR ?= $(TOOLPREFIX)ar
2012-07-03 13:19:19 +02:00
ifeq ($(USECLANG),1)
USEGCC ?= 0
2012-07-03 13:19:19 +02:00
CC = clang
CFLAGS_add += -fno-builtin -fno-strict-aliasing
2012-07-03 13:19:19 +02:00
endif
ifeq ($(USEGCC),1)
CC ?= $(TOOLPREFIX)gcc
2016-02-27 19:32:49 +01:00
CFLAGS_add += -fno-gnu89-inline -fno-builtin
2012-07-03 13:19:19 +02:00
endif
2011-12-31 08:18:43 +01:00
ARCH ?= $(shell $(CC) -dumpmachine | sed "s/\([^-]*\).*$$/\1/")
2013-05-30 03:08:06 +02:00
ifeq ($(ARCH),mingw32)
$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the Julia README.windows.md document for a replacement")
endif
2011-12-31 08:18:43 +01:00
# OS-specific stuff
ifeq ($(ARCH),arm64)
override ARCH := aarch64
endif
ifeq ($(findstring arm,$(ARCH)),arm)
override ARCH := arm
MARCH ?= armv7-a
CFLAGS_add += -mhard-float
2016-04-08 19:37:13 +02:00
endif
ifeq ($(findstring powerpc,$(ARCH)),powerpc)
override ARCH := powerpc
endif
2016-02-26 17:46:17 +01:00
ifeq ($(findstring ppc,$(ARCH)),ppc)
override ARCH := powerpc
endif
2016-09-05 14:14:14 +02:00
ifeq ($(findstring s390,$(ARCH)),s390)
override ARCH := s390
endif
ifneq ($(filter $(ARCH),i386 i486 i586 i686 i387 i487 i587 i687),)
override ARCH := i387
MARCH ?= i686
2012-05-25 22:24:37 +02:00
endif
ifeq ($(ARCH),x86_64)
override ARCH := amd64
endif
ifeq ($(findstring mips,$(ARCH)),mips)
override ARCH := mips
endif
# If CFLAGS does not contain a -O optimization flag, default to -O3
ifeq ($(findstring -O,$(CFLAGS)),)
CFLAGS_add += -O3
endif
2013-05-28 14:59:02 +02:00
ifneq (,$(findstring MINGW,$(OS)))
override OS=WINNT
endif
#keep these if statements separate
ifeq ($(OS), WINNT)
SHLIB_EXT = dll
SONAME_FLAG = -soname
CFLAGS_add += -nodefaultlibs
shlibdir = $(bindir)
else
ifeq ($(OS), Darwin)
SHLIB_EXT = dylib
SONAME_FLAG = -install_name
else
SHLIB_EXT = so
SONAME_FLAG = -soname
endif
ifneq ($(ARCH),sh3eb)
CFLAGS_add += -fPIC
endif
shlibdir = $(libdir)
endif
# Add `-march` to our CFLAGS if it's defined
ifneq ($(MARCH),)
CFLAGS_arch += -march=$(MARCH)
endif
ifeq ($(ARCH),i387)
CFLAGS_arch += -m32
SFLAGS_arch += -m32
LDFLAGS_arch += -m32
endif
ifeq ($(ARCH),amd64)
CFLAGS_arch += -m64
SFLAGS_arch += -m64
LDFLAGS_arch += -m64
endif
2019-04-15 00:11:03 +02:00
ifeq ($(ARCH),wasm32)
CFLAGS_arch += -ffreestanding -nostdlib -nostdinc --target=wasm32-unknown-unknown
endif
ifeq ($(ARCH),sh3eb)
CFLAGS_arch += -ffreestanding -nostdlib -m3 -mb
endif
# Add our "arch"-related FLAGS in. We separate arch-related flags out so that
# we can conveniently get at them for targets that don't want the rest of
# *FLAGS_add, such as the testing Makefile targets
CFLAGS_add += $(CFLAGS_arch)
SFLAGS_add += $(SFLAGS_arch)
LDFLAGS_add += $(LDFLAGS_arch)
CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/$(ARCH) -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
ifneq ($(filter $(ARCH),i387 amd64 powerpc),)
CFLAGS_add += -I$(OPENLIBM_HOME)/ld80
else
ifneq ($(filter $(ARCH),aarch64),)
CFLAGS_add += -I$(OPENLIBM_HOME)/ld128
endif
endif
ifneq ($(filter $(ARCH),i387 amd64),)
# Determines whether `long double` is the same as `double` on this arch.
# linux x86_64, for instance, `long double` is 80 bits wide, whereas on macOS aarch64,
# `long double` is the same as `double`.
LONG_DOUBLE_NOT_DOUBLE := 1
else ifeq ($(ARCH), aarch64)
ifneq ($(OS),Darwin)
LONG_DOUBLE_NOT_DOUBLE := 1
endif
endif
%.c.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@
%.S.o: %.S
$(CC) $(CPPFLAGS) $(SFLAGS) $(SFLAGS_add) $(filter -m% -B% -I% -D%,$(CFLAGS_add)) -c $< -o $@
# Makefile debugging trick:
# call print-VARIABLE to see the runtime value of any variable
print-%:
@echo '$*=$($*)'