Make.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # -*- mode: makefile-gmake -*-
  2. OS := $(shell uname)
  3. # Do not forget to bump SOMINOR when changing VERSION,
  4. # and SOMAJOR when breaking ABI in a backward-incompatible way
  5. VERSION = 0.5-dev
  6. SOMAJOR = 2
  7. SOMINOR = 1
  8. DESTDIR =
  9. prefix = /usr/local
  10. bindir = $(prefix)/bin
  11. libdir = $(prefix)/lib
  12. includedir = $(prefix)/include
  13. ifeq ($(OS), FreeBSD)
  14. pkgconfigdir = $(prefix)/libdata/pkgconfig
  15. else
  16. pkgconfigdir = $(libdir)/pkgconfig
  17. endif
  18. USEGCC = 1
  19. USECLANG = 0
  20. ifeq ($(OS), Darwin)
  21. USEGCC = 0
  22. USECLANG = 1
  23. endif
  24. ifeq ($(OS), FreeBSD)
  25. USEGCC = 0
  26. USECLANG = 1
  27. endif
  28. AR = ar
  29. ifeq ($(USECLANG),1)
  30. USEGCC = 0
  31. CC = clang
  32. CFLAGS_add += -fno-builtin
  33. endif
  34. ifeq ($(USEGCC),1)
  35. CC = gcc
  36. CFLAGS_add += -fno-gnu89-inline
  37. endif
  38. ARCH ?= $(shell $(CC) -dumpmachine | sed "s/\([^-]*\).*$$/\1/")
  39. ARCH_ORIGIN := $(origin ARCH)
  40. ifeq ($(ARCH),mingw32)
  41. $(error "the mingw32 compiler you are using fails the openblas testsuite. please see the Julia README.windows.md document for a replacement")
  42. endif
  43. CFLAGS_add += -std=c99 -Wall -I$(OPENLIBM_HOME) -I$(OPENLIBM_HOME)/include -I$(OPENLIBM_HOME)/ld80 -I$(OPENLIBM_HOME)/$(ARCH) -I$(OPENLIBM_HOME)/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration
  44. default: all
  45. # *int / *intf need to be built with -O0
  46. src/%int.c.o: src/%int.c
  47. $(CC) $(CPPFLAGS) -O0 $(CFLAGS_add) -c $< -o $@
  48. src/%intf.c.o: src/%intf.c
  49. $(CC) $(CPPFLAGS) -O0 $(CFLAGS_add) -c $< -o $@
  50. %.c.o: %.c
  51. $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@
  52. %.S.o: %.S
  53. $(CC) $(CPPFLAGS) $(SFLAGS) $(SFLAGS_add) $(filter -m% -B% -I% -D%,$(CFLAGS_add)) -c $< -o $@
  54. # OS-specific stuff
  55. REAL_ARCH := $(ARCH)
  56. ifeq ($(findstring arm,$(ARCH)),arm)
  57. override ARCH := arm
  58. endif
  59. ifeq ($(findstring powerpc,$(ARCH)),powerpc)
  60. override ARCH := powerpc
  61. endif
  62. ifeq ($(findstring ppc,$(ARCH)),ppc)
  63. override ARCH := powerpc
  64. endif
  65. ifeq ($(ARCH),i386)
  66. override ARCH := i387
  67. endif
  68. ifeq ($(ARCH),i486)
  69. override ARCH := i387
  70. endif
  71. ifeq ($(ARCH),i586)
  72. override ARCH := i387
  73. endif
  74. ifeq ($(ARCH),i686)
  75. override ARCH := i387
  76. endif
  77. ifeq ($(ARCH),x86_64)
  78. override ARCH := amd64
  79. endif
  80. ifneq (,$(findstring MINGW,$(OS)))
  81. override OS=WINNT
  82. endif
  83. #keep these if statements separate
  84. ifeq ($(OS), WINNT)
  85. SHLIB_EXT = dll
  86. SONAME_FLAG = -soname
  87. override CFLAGS_add += -nodefaultlibs
  88. shlibdir = $(bindir)
  89. else
  90. ifeq ($(OS), Darwin)
  91. SHLIB_EXT = dylib
  92. SONAME_FLAG = -install_name
  93. else
  94. SHLIB_EXT = so
  95. SONAME_FLAG = -soname
  96. endif
  97. override CFLAGS_add += -fPIC
  98. shlibdir = $(libdir)
  99. endif
  100. # The target specific FLAGS_add
  101. ifeq ($(ARCH_ORIGIN),file)
  102. CFLAGS_add_TARGET_$(ARCH) :=
  103. SFLAGS_add_TARGET_$(ARCH) :=
  104. LDFLAGS_add_TARGET_$(ARCH) :=
  105. else
  106. ifeq ($(ARCH),i387)
  107. CFLAGS_add_TARGET_$(ARCH) := -m32 -march=$(REAL_ARCH)
  108. SFLAGS_add_TARGET_$(ARCH) := -m32 -march=$(REAL_ARCH)
  109. LDFLAGS_add_TARGET_$(ARCH) := -m32 -march=$(REAL_ARCH)
  110. endif
  111. CFLAGS_add_TARGET_x86_64 := -m64
  112. SFLAGS_add_TARGET_x86_64 := -m64
  113. LDFLAGS_add_TARGET_x86_64 := -m64
  114. # Arm
  115. ifeq ($(ARCH),arm)
  116. ifneq ($(REAL_ARCH),arm)
  117. CFLAGS_add_TARGET_$(ARCH) := -march=$(REAL_ARCH)
  118. SFLAGS_add_TARGET_$(ARCH) := -march=$(REAL_ARCH)
  119. LDFLAGS_add_TARGET_$(ARCH) := -march=$(REAL_ARCH)
  120. else
  121. $(error No known generic arm cflags. Please specify arch type)
  122. endif
  123. endif
  124. endif
  125. # Actually finish setting the FLAGS_add
  126. CFLAGS_add += $(CFLAGS_add_TARGET_$(ARCH))
  127. LDFLAGS_add += $(LDFLAGS_add_TARGET_$(ARCH))
  128. SFLAGS_add += $(SFLAGS_add_TARGET_$(ARCH))