1# -*- mode: makefile-gmake -*- 2 3# Default build rule for any Makefile in this project: all 4default: all 5 6OS := $(shell uname) 7# Do not forget to bump SOMINOR when changing VERSION, 8# and SOMAJOR when breaking ABI in a backward-incompatible way 9VERSION = 0.6.0 10SOMAJOR = 2 11SOMINOR = 5 12DESTDIR = 13prefix = /usr/local 14bindir = $(prefix)/bin 15libdir = $(prefix)/lib 16includedir = $(prefix)/include 17 18ifeq ($(OS), FreeBSD) 19pkgconfigdir = $(prefix)/libdata/pkgconfig 20else 21pkgconfigdir = $(libdir)/pkgconfig 22endif 23 24USEGCC = 1 25USECLANG = 0 26 27ifneq (,$(findstring $(OS),Darwin FreeBSD OpenBSD)) 28USEGCC = 0 29USECLANG = 1 30endif 31 32AR = $(TOOLPREFIX)ar 33 34ifeq ($(USECLANG),1) 35USEGCC = 0 36CC = clang 37CFLAGS_add += -fno-builtin -fno-strict-aliasing 38endif 39 40ifeq ($(USEGCC),1) 41CC = $(TOOLPREFIX)gcc 42CFLAGS_add += -fno-gnu89-inline -fno-builtin 43endif 44 45ARCH ?= $(shell $(CC) -dumpmachine | sed "s/\([^-]*\).*$$/\1/") 46 47ifeq ($(ARCH),mingw32) 48$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the Julia README.windows.md document for a replacement") 49endif 50 51# OS-specific stuff 52ifeq ($(findstring arm,$(ARCH)),arm) 53override ARCH := arm 54MARCH ?= armv7-a 55CFLAGS_add += -mhard-float 56endif 57ifeq ($(findstring powerpc,$(ARCH)),powerpc) 58override ARCH := powerpc 59endif 60ifeq ($(findstring ppc,$(ARCH)),ppc) 61override ARCH := powerpc 62endif 63ifeq ($(findstring s390,$(ARCH)),s390) 64override ARCH := s390 65endif 66ifneq ($(filter $(ARCH),i386 i486 i586 i686 i387 i487 i587 i687),) 67override ARCH := i387 68MARCH ?= i686 69endif 70ifeq ($(ARCH),x86_64) 71override ARCH := amd64 72endif 73ifeq ($(findstring mips,$(ARCH)),mips) 74override ARCH := mips 75endif 76 77# If CFLAGS does not contain a -O optimization flag, default to -O3 78ifeq ($(findstring -O,$(CFLAGS)),) 79CFLAGS_add += -O3 80endif 81 82ifneq (,$(findstring MINGW,$(OS))) 83override OS=WINNT 84endif 85 86#keep these if statements separate 87ifeq ($(OS), WINNT) 88SHLIB_EXT = dll 89SONAME_FLAG = -soname 90CFLAGS_add += -nodefaultlibs 91shlibdir = $(bindir) 92else 93ifeq ($(OS), Darwin) 94SHLIB_EXT = dylib 95SONAME_FLAG = -install_name 96else 97SHLIB_EXT = so 98SONAME_FLAG = -soname 99endif 100CFLAGS_add += -fPIC 101shlibdir = $(libdir) 102endif 103 104# Add `-march` to our CFLAGS if it's defined 105ifneq ($(MARCH),) 106CFLAGS_arch += -march=$(MARCH) 107endif 108 109ifeq ($(ARCH),i387) 110CFLAGS_arch += -m32 111SFLAGS_arch += -m32 112LDFLAGS_arch += -m32 113endif 114 115ifeq ($(ARCH),amd64) 116CFLAGS_arch += -m64 117SFLAGS_arch += -m64 118LDFLAGS_arch += -m64 119endif 120 121# Add our "arch"-related FLAGS in. We separate arch-related flags out so that 122# we can conveniently get at them for targets that don't want the rest of 123# *FLAGS_add, such as the testing Makefile targets 124CFLAGS_add += $(CFLAGS_arch) 125SFLAGS_add += $(SFLAGS_arch) 126LDFLAGS_add += $(LDFLAGS_arch) 127 128CFLAGS_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 129ifneq ($(filter $(ARCH),i387 amd64 powerpc),) 130CFLAGS_add += -I$(OPENLIBM_HOME)/ld80 131else 132ifneq ($(filter $(ARCH),aarch64),) 133CFLAGS_add += -I$(OPENLIBM_HOME)/ld128 134endif 135endif 136 137 138%.c.o: %.c 139 $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@ 140 141%.S.o: %.S 142 $(CC) $(CPPFLAGS) $(SFLAGS) $(SFLAGS_add) $(filter -m% -B% -I% -D%,$(CFLAGS_add)) -c $< -o $@ 143 144 145# Makefile debugging trick: 146# call print-VARIABLE to see the runtime value of any variable 147print-%: 148 @echo '$*=$($*)' 149