summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/libflame/Makefile_5.2.0_darwin.patch
blob: 44646cbc5559f01d6b79f4092c8fc2d806d4bae9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
From 6dd3c19978a0b805b0e294271ce8f5ef2f421425 Mon Sep 17 00:00:00 2001
From: "Field G. Van Zee" <field@cs.utexas.edu>
Date: Wed, 25 Sep 2019 12:46:23 -0500
Subject: [PATCH] Use OSX-specific SOFLAGS when building shared lib.

Details:
- Use linker flags and shared library suffix specific to OSX/Darwin when
  the user appears to be building in OSX/Darwin. The OS is queried using
  'uname -s'. Thanks to Adam J. Stewart for reporting this issue in #23.
- Substitute os_name from configure into config.mk (and echo in
  post-configure.sh).
- Substitute CC_VENDOR from configure into config.mk (and echo in
  post-configure.sh). This variable isn't needed yet, but may be in the
  future.
- Autoconf update to configure.
- Whitespace changes.
---
 Makefile                               | 22 +++++++++++++++++++++-
 build/ac-macros/fla_observe_os_name.m4 | 11 +++++++++++
 build/ac-macros/fla_require_cc.m4      |  8 ++++++--
 build/config.mk.in                     |  5 +++++
 build/post-configure.sh.in             |  5 +++++
 configure                              | 15 +++++++++++++++
 configure.ac                           |  3 +++
 7 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 build/ac-macros/fla_observe_os_name.m4

diff --git a/Makefile b/Makefile
index 6bd8bdce..f9681439 100644
--- a/Makefile
+++ b/Makefile
@@ -92,7 +92,12 @@ endif
 
 # --- Shared library extension ---
 
-SHLIB_EXT            := so
+# The shared (dynamic) library file suffix is different for Linux and OS X.
+ifeq ($(OS_NAME),Darwin)
+SHLIB_EXT          := dylib
+else
+SHLIB_EXT          := so
+endif
 
 # --- Library names ---
 
@@ -107,8 +112,15 @@ LIBFLAME_SO          := $(LIBFLAME).$(SHLIB_EXT)
 LIBFLAME_A_PATH      := $(BASE_LIB_PATH)/$(LIBFLAME_A)
 LIBFLAME_SO_PATH     := $(BASE_LIB_PATH)/$(LIBFLAME_SO)
 
+ifeq ($(OS_NAME),Darwin)
+# OS X shared library extensions.
+LIBFLAME_SO_MAJ_EXT  := $(SO_MAJOR).$(SHLIB_EXT)
+LIBFLAME_SO_MMB_EXT  := $(SO_MMB).$(SHLIB_EXT)
+else
+# Linux shared library extensions.
 LIBFLAME_SO_MAJ_EXT  := $(SHLIB_EXT).$(SO_MAJOR)
 LIBFLAME_SO_MMB_EXT  := $(SHLIB_EXT).$(SO_MMB)
+endif
 
 LIBFLAME_SONAME      := $(LIBFLAME).$(LIBFLAME_SO_MAJ_EXT)
 LIBFLAME_SO_MAJ_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_SONAME)
@@ -124,8 +136,15 @@ LIBFLAME_SO_OUTPUT_NAME := $(LIBFLAME_SO_PATH)
 
 # Specify the shared library's 'soname' field.
 # NOTE: The flag for creating shared objects is different for Linux and OS X.
+ifeq ($(OS_NAME),Darwin)
+# OS X shared library link flags.
+SOFLAGS    := -dynamiclib
+SOFLAGS    += -Wl,-install_name,$(LIBFLAME_SONAME)
+else
 SOFLAGS    := -shared
+# Linux shared library link flags.
 SOFLAGS    += -Wl,-soname,$(LIBFLAME_SONAME)
+endif
 
 
 
diff --git a/build/ac-macros/fla_observe_os_name.m4 b/build/ac-macros/fla_observe_os_name.m4
new file mode 100644
index 00000000..d3dbbf99
--- /dev/null
+++ b/build/ac-macros/fla_observe_os_name.m4
@@ -0,0 +1,11 @@
+AC_DEFUN([FLA_OBSERVE_OS_NAME],
+[
+	os_name=$(uname -s)
+	os_vers=$(uname -r)
+
+	dnl os_name_esc=$(echo "${os_name}" | sed 's/\//\\\//g')
+
+	dnl Substitute the OS name and version into autoconf output files
+	AC_SUBST(os_name)
+	AC_SUBST(os_vers)
+])
diff --git a/build/ac-macros/fla_require_cc.m4 b/build/ac-macros/fla_require_cc.m4
index 7f8131d8..5dd7cd38 100644
--- a/build/ac-macros/fla_require_cc.m4
+++ b/build/ac-macros/fla_require_cc.m4
@@ -6,19 +6,23 @@ AC_DEFUN([FLA_REQUIRE_CC],
 	dnl whether the user provided his own definition of CFLAGS.
 	fla_userdef_cflags=$CFLAGS
 	
-	dnl Find a C compiler. 
+	dnl Find a C compiler.
 	dnl If the CC environment variable is not already set, search for the
 	dnl compiler defined by fla_requested_cc (which may be empty) and then
 	dnl continue searching for the compilers in $fla_c_compiler_list, if
 	dnl necessary. Also, if the C compiler found is not in ANSI mode, then
 	dnl try to add an option to make it so. If the GNU gcc was found, then
-	dnl GCC shell variable is set to `yes'. 
+	dnl GCC shell variable is set to `yes'.
 	AC_PROG_CC([$fla_requested_cc $fla_c_compiler_list])
 
 	if test "$CC" = "" ; then
 		AC_MSG_ERROR([Could not locate any of the following C compilers: $CC $fla_requested_cc $fla_c_compiler_list. Cannot continue without a C compiler.],[1])
 	fi
+
+	dnl Ascertain the compiler "vendor".
+	CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
 	
 	dnl Substitute the user-defined CFLAGS into the autoconf output files.
 	AC_SUBST(fla_userdef_cflags)
+	AC_SUBST(CC_VENDOR)
 ])
diff --git a/build/config.mk.in b/build/config.mk.in
index c4679b51..37cedb96 100644
--- a/build/config.mk.in
+++ b/build/config.mk.in
@@ -28,6 +28,10 @@ SO_MMB    := $(SO_MAJOR).$(SO_MINORB)
 # library name.
 ARCH                           := @fla_host_cpu@
 
+# This variable identifies the operating system / kernel. It is the result of
+# 'uname -s'.
+OS_NAME                        := @os_name@
+
 # We have to set these particular variables because some of the @anchors@
 # that are substituted in via configure may be defined *in terms of* these
 # variables. For example, @libdir@ may be replaced with '${exec_prefix}/lib',
@@ -101,6 +105,7 @@ EMPTY_FILE := /dev/null
 
 # --- Determine the C compiler and related flags ---
 CC           := @CC@
+CC_VENDOR    := @CC_VENDOR@
 CPPROCFLAGS  := -D_POSIX_C_SOURCE=200809L @DEFS@ @fla_blis_flags@
 CMISCFLAGS   := @fla_c_lang_flags@ @fla_c_openmp_flags@ @fla_c_prof_flags@
 CDBGFLAGS    := @fla_c_debug_flags@
diff --git a/build/post-configure.sh.in b/build/post-configure.sh.in
index 26f9110d..61d59bca 100755
--- a/build/post-configure.sh.in
+++ b/build/post-configure.sh.in
@@ -17,6 +17,10 @@ echo ""
 echo "build system type............................... : @build@"
 echo "host system type................................ : @host@"
 
+echo ""
+echo "OS name......................................... : @os_name@"
+echo "OS version...................................... : @os_vers@"
+
 echo ""
 echo "Enable verbose make output...................... : @fla_enable_verbose_make_output@"
 
@@ -25,6 +29,7 @@ echo "Enable maximum argument list hack............... : @fla_enable_max_arg_lis
 
 echo ""
 echo "C compiler...................................... : @CC@"
+echo "C compiler vendor............................... : @CC_VENDOR@"
 echo "Library archiver................................ : @AR@"
 echo "Library archive indexer......................... : @RANLIB@"
 
diff --git a/configure b/configure
index c3d19bbc..1e24f9a5 100755
--- a/configure
+++ b/configure
@@ -698,6 +698,7 @@ INSTALL_SCRIPT
 INSTALL_PROGRAM
 RANLIB
 AR
+CC_VENDOR
 fla_userdef_cflags
 OBJEXT
 EXEEXT
@@ -707,6 +708,8 @@ LDFLAGS
 CFLAGS
 CC
 fla_gnu_make_found
+os_vers
+os_name
 fla_host_cpu
 host_os
 host_vendor
@@ -2738,6 +2741,15 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
 
 
+	os_name=$(uname -s)
+	os_vers=$(uname -r)
+
+
+
+
+
+
+
 
 
 
@@ -3462,6 +3474,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 		as_fn_error 1 "Could not locate any of the following C compilers: $CC $fla_requested_cc $fla_c_compiler_list. Cannot continue without a C compiler." "$LINENO" 5
 	fi
 
+		CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
+
+
 
 
 
diff --git a/configure.ac b/configure.ac
index 790ac90e..d8b0e6b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -227,6 +227,9 @@ dnl AC_PROG_CC and AC_PROG_F77 marcos in the variables fla_c_compiler_list and
 dnl fla_f77_compiler_list, respectively.
 FLA_OBSERVE_HOST_CPU_TYPE
 
+dnl Set the @os_name@ output variable to the output of 'uname -s'.
+FLA_OBSERVE_OS_NAME
+
 dnl Set the default value of the $prefix value, normally set by the --prefix
 dnl option to configure.
 dnl AC_PREFIX_DEFAULT([$HOME/flame])