11# -*- mode: makefile-gmake -*-
22
3+ # Default build rule for any Makefile in this project: all
4+ default : all
5+
36OS := $(shell uname )
47# Do not forget to bump SOMINOR when changing VERSION,
58# and SOMAJOR when breaking ABI in a backward-incompatible way
@@ -13,9 +16,9 @@ libdir = $(prefix)/lib
1316includedir = $(prefix )/include
1417
1518ifeq ($(OS ), FreeBSD )
16- pkgconfigdir = $(prefix )/libdata /pkgconfig
19+ pkgconfigdir = $(prefix )/libdata /pkgconfig
1720else
18- pkgconfigdir = $(libdir )/pkgconfig
21+ pkgconfigdir = $(libdir )/pkgconfig
1922endif
2023
2124USEGCC = 1
@@ -45,56 +48,27 @@ CFLAGS_add += -fno-gnu89-inline -fno-builtin
4548endif
4649
4750ARCH ?= $(shell $(CC ) -dumpmachine | sed "s/\([^-]*\).*$$/\1/" )
48- ARCH_ORIGIN := $(origin ARCH )
4951
5052ifeq ($(ARCH ), mingw32 )
5153$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the Julia README.windows.md document for a replacement" )
5254endif
5355
54- 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
55-
56- default : all
57-
58- # *int / *intf need to be built with -O0
59- src /%int . c . o : src /%int . c
60- $(CC ) $(CPPFLAGS ) -O0 $(CFLAGS_add ) -c $< -o $@
61-
62- src /%intf . c . o : src /%intf . c
63- $(CC ) $(CPPFLAGS ) -O0 $(CFLAGS_add ) -c $< -o $@
64-
65- %. c . o : %. c
66- $(CC ) $(CPPFLAGS ) $(CFLAGS ) $(CFLAGS_add ) -c $< -o $@
67-
68- %. S . o : %. S
69- $(CC ) $(CPPFLAGS ) $(SFLAGS ) $(SFLAGS_add ) $(filter -m % -B % -I % -D %, $(CFLAGS_add )) -c $< -o $@
70-
7156# OS-specific stuff
72- REAL_ARCH := $(ARCH )
7357ifeq ($(findstring arm , $(ARCH )), arm )
7458override ARCH := arm
75- endif
76- ifeq ($(ARCH ), aarch64 )
77- override ARCH := arm
59+ MARCH ?= armv7 -a
60+ CFLAGS_add += -mhard -float
7861endif
7962ifeq ($(findstring powerpc , $(ARCH )), powerpc )
8063override ARCH := powerpc
8164endif
8265ifeq ($(findstring ppc , $(ARCH )), ppc )
8366override ARCH := powerpc
8467endif
85- ifeq ($(ARCH ), i386 )
68+ ifneq ($(filter $( ARCH ), i386 i486 i586 i686 i387 i487 i587 i687 ) , )
8669override ARCH := i387
70+ MARCH ?= i686
8771endif
88- ifeq ($(ARCH ), i486 )
89- override ARCH := i387
90- endif
91- ifeq ($(ARCH ), i586 )
92- override ARCH := i387
93- endif
94- ifeq ($(ARCH ), i686 )
95- override ARCH := i387
96- endif
97-
9872ifeq ($(ARCH ), x86_64 )
9973override ARCH := amd64
10074endif
@@ -109,51 +83,68 @@ override OS=WINNT
10983endif
11084
11185# keep these if statements separate
112-
11386ifeq ($(OS ), WINNT )
114- SHLIB_EXT = dll
115- SONAME_FLAG = -soname
116- CFLAGS_add += -nodefaultlibs
117- shlibdir = $(bindir )
87+ SHLIB_EXT = dll
88+ SONAME_FLAG = -soname
89+ CFLAGS_add += -nodefaultlibs
90+ shlibdir = $(bindir )
11891else
119- ifeq ($(OS ), Darwin )
120- SHLIB_EXT = dylib
121- SONAME_FLAG = -install_name
122- else
123- SHLIB_EXT = so
124- SONAME_FLAG = -soname
125- endif
126- CFLAGS_add += -fPIC
127- shlibdir = $(libdir )
128- endif
129-
130- # The target specific FLAGS_add
131- ifeq ($(ARCH_ORIGIN ), file )
132- CFLAGS_add_TARGET_ $(ARCH ) :=
133- SFLAGS_add_TARGET_ $(ARCH ) :=
134- LDFLAGS_add_TARGET_ $(ARCH ) :=
92+ ifeq ($(OS ), Darwin )
93+ SHLIB_EXT = dylib
94+ SONAME_FLAG = -install_name
13595else
96+ SHLIB_EXT = so
97+ SONAME_FLAG = -soname
98+ endif
99+ CFLAGS_add += -fPIC
100+ shlibdir = $(libdir )
101+ endif
102+
103+ # Add `-march` to our CFLAGS if it's defined
104+ ifneq ($(MARCH ), )
105+ CFLAGS_arch += -march = $(MARCH )
106+ endif
107+
136108ifeq ($(ARCH ), i387 )
137- CFLAGS_add_TARGET_ $(ARCH ) := -m32 -march = $(REAL_ARCH )
138- SFLAGS_add_TARGET_ $(ARCH ) := -m32 -march = $(REAL_ARCH )
139- LDFLAGS_add_TARGET_ $(ARCH ) := -m32 -march = $(REAL_ARCH )
140- endif
141- CFLAGS_add_TARGET_x86_64 := -m64
142- SFLAGS_add_TARGET_x86_64 := -m64
143- LDFLAGS_add_TARGET_x86_64 := -m64
144- # Arm
145- ifeq ($(ARCH ), arm )
146- ifneq ($(REAL_ARCH ), arm )
147- CFLAGS_add_TARGET_ $(ARCH ) := -march = $(REAL_ARCH )
148- SFLAGS_add_TARGET_ $(ARCH ) := -march = $(REAL_ARCH )
149- LDFLAGS_add_TARGET_ $(ARCH ) := -march = $(REAL_ARCH )
150- else
151- $(error No known generic arm cflags . Please specify arch type )
109+ CFLAGS_arch += -m32
110+ SFLAGS_arch += -m32
111+ LDFLAGS_arch += -m32
152112endif
113+
114+ ifeq ($(ARCH ), amd64 )
115+ CFLAGS_arch += -m64
116+ SFLAGS_arch += -m64
117+ LDFLAGS_arch += -m64
153118endif
119+
120+ # Add our "arch"-related FLAGS in. We separate arch-related flags out so that
121+ # we can conveniently get at them for targets that don't want the rest of
122+ # *FLAGS_add, such as the testing Makefile targets
123+ CFLAGS_add += $(CFLAGS_arch )
124+ SFLAGS_add += $(SFLAGS_arch )
125+ LDFLAGS_add += $(LDFLAGS_arch )
126+
127+ 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
128+ ifneq ($(filter $(ARCH ), i387 amd64 aarch64 powerpc ), )
129+ CFLAGS_add += -I $(OPENLIBM_HOME )/ld80
154130endif
155131
156- # Actually finish setting the FLAGS_add
157- CFLAGS_add += $(CFLAGS_add_TARGET_ $(ARCH ))
158- LDFLAGS_add += $(LDFLAGS_add_TARGET_ $(ARCH ))
159- SFLAGS_add += $(SFLAGS_add_TARGET_ $(ARCH ))
132+
133+ # *int / *intf need to be built with -O0
134+ src /%int . c . o : src /%int . c
135+ $(CC ) $(CPPFLAGS ) -O0 $(CFLAGS_add ) -c $< -o $@
136+
137+ src /%intf . c . o : src /%intf . c
138+ $(CC ) $(CPPFLAGS ) -O0 $(CFLAGS_add ) -c $< -o $@
139+
140+ %. c . o : %. c
141+ $(CC ) $(CPPFLAGS ) $(CFLAGS ) $(CFLAGS_add ) -c $< -o $@
142+
143+ %. S . o : %. S
144+ $(CC ) $(CPPFLAGS ) $(SFLAGS ) $(SFLAGS_add ) $(filter -m % -B % -I % -D %, $(CFLAGS_add )) -c $< -o $@
145+
146+
147+ # Makefile debugging trick:
148+ # call print-VARIABLE to see the runtime value of any variable
149+ print -%:
150+ @echo '$*=$($*)'
0 commit comments