]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/Makefile
LINALG 1.2.0 iteration 1.
[dense-linear-algebra-libraries/linalg.git] / blis / Makefile
1 #!/bin/bash
2 #
3 #  BLIS    
4 #  An object-based framework for developing high-performance BLAS-like
5 #  libraries.
6 #
7 #  Copyright (C) 2014, The University of Texas at Austin
8 #
9 #  Redistribution and use in source and binary forms, with or without
10 #  modification, are permitted provided that the following conditions are
11 #  met:
12 #   - Redistributions of source code must retain the above copyright
13 #     notice, this list of conditions and the following disclaimer.
14 #   - Redistributions in binary form must reproduce the above copyright
15 #     notice, this list of conditions and the following disclaimer in the
16 #     documentation and/or other materials provided with the distribution.
17 #   - Neither the name of The University of Texas at Austin nor the names
18 #     of its contributors may be used to endorse or promote products
19 #     derived from this software without specific prior written permission.
20 #
21 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 #  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 #  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 #  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 #  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 #  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 #  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 #  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 #  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #
33 #
35 #
36 # Makefile
37 #
38 # Field G. Van Zee
39
40 # Top-level makefile for libflame linear algebra library.
41 #
42 #
44 #
45 # --- Makefile PHONY target definitions ----------------------------------------
46 #
48 .PHONY: all libs test install uninstall clean \
49         check-env check-env-mk check-env-fragments check-env-make-defs \
50         testsuite testsuite-run testsuite-bin \
51         install-libs install-headers install-lib-symlinks \
52         showconfig \
53         cleanlib distclean cleanmk cleanleaves \
54         changelog \
55         uninstall-libs uninstall-headers uninstall-lib-symlinks \
56         uninstall-old
60 #
61 # --- Makefile initialization --------------------------------------------------
62 #
64 # The base name of the BLIS library that we will build.
65 BLIS_LIB_BASE_NAME := libblis
67 # Define the name of the configuration file.
68 CONFIG_MK_FILE     := config.mk
70 # Define the name of the file containing build and architecture-specific
71 # makefile definitions.
72 MAKE_DEFS_FILE     := make_defs.mk
74 # All makefile fragments in the tree will have this name.
75 FRAGMENT_MK        := .fragment.mk
77 # Locations of important files.
78 BUILD_DIR          := build
79 CONFIG_DIR         := config
80 FRAME_DIR          := frame
81 OBJ_DIR            := obj
82 LIB_DIR            := lib
83 TESTSUITE_DIR      := testsuite
85 # The names of the testsuite binary executable and related default names
86 # of its input/configuration files.
87 TESTSUITE_NAME     := test_$(BLIS_LIB_BASE_NAME)
88 TESTSUITE_CONF_GEN := input.general
89 TESTSUITE_CONF_OPS := input.operations
90 TESTSUITE_OUT_FILE := output.testsuite
92 # The name of the file where the version string is stored.
93 VERSION_FILE       := version
95 # The name of the "special" directories, which contain source code that
96 # use non-standard compiler flags.
97 NOOPT_DIR          := noopt
98 KERNELS_DIR        := kernels
100 # Text strings that alert the user to the fact that special source code is
101 # being compiled.
102 NOOPT_TEXT         := "(NOTE: using flags for no optimization)"
103 KERNELS_TEXT       := "(NOTE: using flags for kernels)"
105 # CHANGELOG file.
106 CHANGELOG          := CHANGELOG
108 COMPILER_OUTPUT_FLAG := -o
113 # --- Include makefile configuration file --------------------------------------
116 # Include the configuration file.
117 -include $(CONFIG_MK_FILE)
119 # Detect whether we actually got the configuration file. If we didn't, then
120 # it is likely that the user has not yet generated it (via configure).
121 ifeq ($(strip $(CONFIG_MK_INCLUDED)),yes)
122 CONFIG_MK_PRESENT := yes
123 else
124 CONFIG_MK_PRESENT := no
125 endif
127 # Now we have access to CONFIG_NAME, which tells us which sub-directory of the
128 # config directory to use as our configuration. Also using CONFIG_NAME, we
129 # construct the path to the general framework source tree.
130 CONFIG_PATH       := $(DIST_PATH)/$(CONFIG_DIR)/$(CONFIG_NAME)
131 FRAME_PATH        := $(DIST_PATH)/$(FRAME_DIR)
133 # Construct base paths for the object file tree.
134 BASE_OBJ_PATH           := ./$(OBJ_DIR)/$(CONFIG_NAME)
135 BASE_OBJ_CONFIG_PATH    := $(BASE_OBJ_PATH)/$(CONFIG_DIR)
136 BASE_OBJ_FRAME_PATH     := $(BASE_OBJ_PATH)/$(FRAME_DIR)
138 # Construct base path for the library.
139 BASE_LIB_PATH           := ./$(LIB_DIR)/$(CONFIG_NAME)
144 # --- Include makefile definitions file ----------------------------------------
147 # Construct the path to the makefile definitions file residing inside of
148 # the configuration sub-directory.
149 MAKE_DEFS_MK_PATH := $(CONFIG_PATH)/$(MAKE_DEFS_FILE)
151 # Include the makefile definitions file.
152 -include $(MAKE_DEFS_MK_PATH)
154 # Detect whether we actually got the make definitios file. If we didn't, then
155 # it is likely that the configuration is invalid (or incomplete).
156 ifeq ($(strip $(MAKE_DEFS_MK_INCLUDED)),yes)
157 MAKE_DEFS_MK_PRESENT := yes
158 else
159 MAKE_DEFS_MK_PRESENT := no
160 endif
165 # --- Main target variable definitions -----------------------------------------
169 # Construct the architecture-version string, which will be used to name the
170 # library upon installation.
171 VERSION                := $(shell cat $(DIST_PATH)/$(VERSION_FILE))
172 VERS_CONF              := $(VERSION)-$(CONFIG_NAME)
174 # --- Library names ---
176 # Note: These names will be modified later to include the configuration and
177 # version strings.
178 BLIS_LIB_NAME      := $(BLIS_LIB_BASE_NAME).a
179 BLIS_DLL_NAME      := $(BLIS_LIB_BASE_NAME).so
181 # --- BLIS framework source and object variable names ---
183 # These are the makefile variables that source code files will be accumulated
184 # into by the makefile fragments. Notice that we include separate variables
185 # for regular and "special" source.
186 MK_FRAME_SRC           :=
187 MK_FRAME_NOOPT_SRC     :=
188 MK_FRAME_KERNELS_SRC   :=
189 MK_CONFIG_SRC          :=
190 MK_CONFIG_NOOPT_SRC    :=
191 MK_CONFIG_KERNELS_SRC  :=
193 # These hold object filenames corresponding to above.
194 MK_FRAME_OBJS          :=
195 MK_FRAME_NOOPT_OBJS    :=
196 MK_FRAME_KERNELS_OBJS  :=
197 MK_CONFIG_OBJS         :=
198 MK_CONFIG_NOOPT_OBJS   :=
199 MK_CONFIG_KERNELS_OBJS :=
201 # Append the base library path to the library names.
202 MK_ALL_BLIS_LIB        := $(BASE_LIB_PATH)/$(BLIS_LIB_NAME)
203 MK_ALL_BLIS_DLL        := $(BASE_LIB_PATH)/$(BLIS_DLL_NAME)
205 # --- Define install target names for static libraries ---
207 MK_BLIS_LIB                  := $(MK_ALL_BLIS_LIB)
208 MK_BLIS_LIB_INST             := $(patsubst $(BASE_LIB_PATH)/%.a, \
209                                            $(INSTALL_PREFIX)/lib/%.a, \
210                                            $(MK_BLIS_LIB))
211 MK_BLIS_LIB_INST_W_VERS_CONF := $(patsubst $(BASE_LIB_PATH)/%.a, \
212                                            $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).a, \
213                                            $(MK_BLIS_LIB))
215 # --- Define install target names for shared libraries ---
217 MK_BLIS_DLL                  := $(MK_ALL_BLIS_DLL)
218 MK_BLIS_DLL_INST             := $(patsubst $(BASE_LIB_PATH)/%.so, \
219                                            $(INSTALL_PREFIX)/lib/%.so, \
220                                            $(MK_BLIS_DLL))
221 MK_BLIS_DLL_INST_W_VERS_CONF := $(patsubst $(BASE_LIB_PATH)/%.so, \
222                                            $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).so, \
223                                            $(MK_BLIS_DLL))
225 # --- Determine which libraries to build ---
227 MK_LIBS                           :=
228 MK_LIBS_INST                      :=
229 MK_LIBS_INST_W_VERS_CONF          :=
231 ifeq ($(BLIS_ENABLE_STATIC_BUILD),yes)
232 MK_LIBS                           += $(MK_BLIS_LIB)
233 MK_LIBS_INST                      += $(MK_BLIS_LIB_INST)
234 MK_LIBS_INST_W_VERS_CONF          += $(MK_BLIS_LIB_INST_W_VERS_CONF)
235 endif
237 ifeq ($(BLIS_ENABLE_DYNAMIC_BUILD),yes)
238 MK_LIBS                           += $(MK_BLIS_DLL)
239 MK_LIBS_INST                      += $(MK_BLIS_DLL_INST)
240 MK_LIBS_INST_W_VERS_CONF          += $(MK_BLIS_DLL_INST_W_VERS_CONF)
241 endif
243 # Strip leading, internal, and trailing whitespace.
244 MK_LIBS_INST                      := $(strip $(MK_LIBS_INST))
245 MK_LIBS_INST_W_VERS_CONF          := $(strip $(MK_LIBS_INST_W_VERS_CONF))
247 # Set the include directory names
248 MK_INCL_DIR_INST                  := $(INSTALL_PREFIX)/include/blis
253 # --- Include makefile fragments -----------------------------------------------
256 # Initialize our list of directory paths to makefile fragments with the empty
257 # list. This variable will accumulate all of the directory paths in which
258 # makefile fragments reside.
259 FRAGMENT_DIR_PATHS :=
261 # This variable is used by the include statements as they recursively include
262 # one another. For the framework source tree ('frame' directory), we initialize
263 # it to the top-level directory since that is its parent.
264 PARENT_PATH        := $(DIST_PATH)
266 # Recursively include all the makefile fragments in the framework itself.
267 -include $(addsuffix /$(FRAGMENT_MK), $(FRAME_PATH))
269 # Now set PARENT_PATH to $(DIST_PATH)/config in preparation to include the
270 # fragments in the configuration sub-directory.
271 PARENT_PATH        := $(DIST_PATH)/$(CONFIG_DIR)
273 # Recursively include all the makefile fragments in the configuration
274 # sub-directory.
275 -include $(addsuffix /$(FRAGMENT_MK), $(CONFIG_PATH))
277 # Create a list of the makefile fragments.
278 MAKEFILE_FRAGMENTS := $(addsuffix /$(FRAGMENT_MK), $(FRAGMENT_DIR_PATHS))
280 # Detect whether we actually got any makefile fragments. If we didn't, then it
281 # is likely that the user has not yet generated them (via configure).
282 ifeq ($(strip $(MAKEFILE_FRAGMENTS)),)
283 MAKEFILE_FRAGMENTS_PRESENT := no
284 else
285 MAKEFILE_FRAGMENTS_PRESENT := yes
286 endif
291 # --- Compiler include path definitions ----------------------------------------
294 # Expand the fragment paths that contain .h files to attain the set of header
295 # files present in all fragment paths.
296 MK_HEADER_FILES := $(foreach frag_path, $(FRAGMENT_DIR_PATHS), \
297                                         $(wildcard $(frag_path)/*.h))
299 # Strip the leading, internal, and trailing whitespace from our list of header
300 # files. This makes the "make install-headers" much more readable.
301 MK_HEADER_FILES := $(strip $(MK_HEADER_FILES))
303 # Expand the fragment paths that contain .h files, and take the first
304 # expansion. Then, strip the header filename to leave the path to each header
305 # location. Notice this process even weeds out duplicates! Add the config
306 # directory manually since it contains FLA_config.h.
307 MK_HEADER_DIR_PATHS := $(dir $(foreach frag_path, $(FRAGMENT_DIR_PATHS), \
308                                        $(firstword $(wildcard $(frag_path)/*.h))))
310 # Add -I to each header path so we can specify our include search paths to the
311 # C compiler.
312 INCLUDE_PATHS   := $(strip $(patsubst %, -I%, $(MK_HEADER_DIR_PATHS)))
313 CFLAGS          := $(CFLAGS) $(INCLUDE_PATHS)
314 CFLAGS_NOOPT    := $(CFLAGS_NOOPT) $(INCLUDE_PATHS)
315 CFLAGS_KERNELS  := $(CFLAGS_KERNELS) $(INCLUDE_PATHS)
320 # --- Special preprocessor macro definitions -----------------------------------
323 # Define a C preprocessor macro to communicate the current version so that it
324 # can be embedded into the library and queried later.
325 VERS_DEF       := -DBLIS_VERSION_STRING=\"$(VERSION)\"
326 CFLAGS         := $(CFLAGS) $(VERS_DEF)
327 CFLAGS_NOOPT   := $(CFLAGS_NOOPT) $(VERS_DEF)
328 CFLAGS_KERNELS := $(CFLAGS_KERNELS) $(VERS_DEF)
333 # --- Library object definitions -----------------------------------------------
336 # Convert source file paths to object file paths by replacing the base source
337 # directories with the base object directories, and also replacing the source
338 # file suffix (eg: '.c') with '.o'.
339 MK_BLIS_FRAME_OBJS         := $(patsubst $(FRAME_PATH)/%.c, $(BASE_OBJ_FRAME_PATH)/%.o, \
340                                           $(filter %.c, $(MK_FRAME_SRC)))
341 MK_BLIS_FRAME_NOOPT_OBJS   := $(patsubst $(FRAME_PATH)/%.c, $(BASE_OBJ_FRAME_PATH)/%.o, \
342                                           $(filter %.c, $(MK_FRAME_NOOPT_SRC)))
343 MK_BLIS_FRAME_KERNELS_OBJS := $(patsubst $(FRAME_PATH)/%.c, $(BASE_OBJ_FRAME_PATH)/%.o, \
344                                           $(filter %.c, $(MK_FRAME_KERNELS_SRC)))
346 MK_BLIS_CONFIG_OBJS          := $(patsubst $(CONFIG_PATH)/%.S, $(BASE_OBJ_CONFIG_PATH)/%.o, \
347                                           $(filter %.S, $(MK_CONFIG_SRC)))
348 MK_BLIS_CONFIG_OBJS          += $(patsubst $(CONFIG_PATH)/%.c, $(BASE_OBJ_CONFIG_PATH)/%.o, \
349                                           $(filter %.c, $(MK_CONFIG_SRC)))
351 MK_BLIS_CONFIG_NOOPT_OBJS    := $(patsubst $(CONFIG_PATH)/%.S, $(BASE_OBJ_CONFIG_PATH)/%.o, \
352                                           $(filter %.S, $(MK_CONFIG_NOOPT_SRC)))
353 MK_BLIS_CONFIG_NOOPT_OBJS    += $(patsubst $(CONFIG_PATH)/%.c, $(BASE_OBJ_CONFIG_PATH)/%.o, \
354                                           $(filter %.c, $(MK_CONFIG_NOOPT_SRC)))
356 MK_BLIS_CONFIG_KERNELS_OBJS  := $(patsubst $(CONFIG_PATH)/%.S, $(BASE_OBJ_CONFIG_PATH)/%.o, \
357                                           $(filter %.S, $(MK_CONFIG_KERNELS_SRC)))
358 MK_BLIS_CONFIG_KERNELS_OBJS  += $(patsubst $(CONFIG_PATH)/%.c, $(BASE_OBJ_CONFIG_PATH)/%.o, \
359                                           $(filter %.c, $(MK_CONFIG_KERNELS_SRC)))
361 # Combine all of the object files into some readily-accessible variables.
362 MK_ALL_BLIS_OPT_OBJS      := $(MK_BLIS_CONFIG_OBJS) \
363                              $(MK_BLIS_FRAME_OBJS)
365 MK_ALL_BLIS_NOOPT_OBJS    := $(MK_BLIS_CONFIG_NOOPT_OBJS) \
366                              $(MK_BLIS_FRAME_NOOPT_OBJS)
368 MK_ALL_BLIS_KERNELS_OBJS  := $(MK_BLIS_CONFIG_KERNELS_OBJS) \
369                              $(MK_BLIS_FRAME_KERNELS_OBJS)
371 MK_ALL_BLIS_OBJS          := $(MK_ALL_BLIS_OPT_OBJS) \
372                              $(MK_ALL_BLIS_NOOPT_OBJS) \
373                              $(MK_ALL_BLIS_KERNELS_OBJS)
378 # --- Test suite definitions ---------------------------------------------------
381 # The location of the test suite's general and operations-specific
382 # input/configuration files.
383 TESTSUITE_CONF_GEN_PATH := $(DIST_PATH)/$(TESTSUITE_DIR)/$(TESTSUITE_CONF_GEN)
384 TESTSUITE_CONF_OPS_PATH := $(DIST_PATH)/$(TESTSUITE_DIR)/$(TESTSUITE_CONF_OPS)
386 # The locations of the test suite source directory and the local object
387 # directory.
388 TESTSUITE_SRC_PATH      := $(DIST_PATH)/$(TESTSUITE_DIR)/src
389 BASE_OBJ_TESTSUITE_PATH := $(BASE_OBJ_PATH)/$(TESTSUITE_DIR)
391 # Convert source file paths to object file paths by replacing the base source
392 # directories with the base object directories, and also replacing the source
393 # file suffix (eg: '.c') with '.o'.
394 MK_TESTSUITE_OBJS       := $(patsubst $(TESTSUITE_SRC_PATH)/%.c, \
395                                       $(BASE_OBJ_TESTSUITE_PATH)/%.o, \
396                                       $(wildcard $(TESTSUITE_SRC_PATH)/*.c))
398 # The test suite binary executable filename.
399 ifeq ($(CONFIG_NAME),pnacl)
400 # Linked executable
401 MK_TESTSUITE_BIN_UNSTABLE := $(BASE_OBJ_TESTSUITE_PATH)/test_libblis.unstable.pexe
402 # Finalized executable
403 MK_TESTSUITE_BIN_PNACL    := $(BASE_OBJ_TESTSUITE_PATH)/test_libblis.pexe
404 # Translated executable (for x86-64)
405 TESTSUITE_BIN             := test_libblis.x86-64.nexe
406 else
407 ifeq ($(CONFIG_NAME),emscripten)
408 # JS script name.
409 TESTSUITE_BIN             := test_libblis.js
410 else
411 # Binary executable name.
412 TESTSUITE_BIN             := test_libblis.x
413 endif # emscripten
414 endif # pnacl
419 # --- Uninstall definitions ----------------------------------------------------
422 # This shell command grabs all files named "libblis-*.a" or "libblis-*.so" in
423 # the installation directory and then filters out the name of the library
424 # archive for the current version/configuration. We consider this remaining set
425 # of libraries to be "old" and eligible for removal upon running of the
426 # uninstall-old target.
427 UNINSTALL_LIBS   := $(shell $(FIND) $(INSTALL_PREFIX)/lib/ -name "$(BLIS_LIB_BASE_NAME)-*.[a|so]" 2> /dev/null | $(GREP) -v "$(BLIS_LIB_BASE_NAME)-$(VERS_CONF).[a|so]" | $(GREP) -v $(BLIS_LIB_NAME))
432 # --- Targets/rules ------------------------------------------------------------
435 # --- Primary targets ---
437 all: libs
439 libs: blis-lib
441 test: testsuite
443 install: libs install-libs install-headers install-lib-symlinks
445 uninstall: uninstall-libs uninstall-lib-symlinks uninstall-headers
447 clean: cleanlib cleantest
450 # --- General source code / object code rules ---
452 # Define two functions, each of which takes one argument (an object file
453 # path). The functions determine which CFLAGS and text string are needed to
454 # compile the object file. Note that we match with a preceding forward slash,
455 # so the directory name must begin with the special directory name, but it
456 # can have trailing characters (e.g. 'kernels_x86').
457 get_cflags_for_obj = $(if $(findstring /$(NOOPT_DIR),$1),$(CFLAGS_NOOPT),\
458                      $(if $(findstring /$(KERNELS_DIR),$1),$(CFLAGS_KERNELS),\
459                      $(CFLAGS)))
461 get_ctext_for_obj = $(if $(findstring /$(NOOPT_DIR),$1),$(NOOPT_TEXT),\
462                     $(if $(findstring /$(KERNELS_DIR),$1),$(KERNELS_TEXT),))
464 $(BASE_OBJ_FRAME_PATH)/%.o: $(FRAME_PATH)/%.c $(MK_HEADER_FILES) $(MAKE_DEFS_MK_PATH)
465 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
466         $(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
467 else
468         @echo "Compiling $<" $(call get_ctext_for_obj,$@)
469         @$(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
470 endif
472 $(BASE_OBJ_CONFIG_PATH)/%.o: $(CONFIG_PATH)/%.c $(MK_HEADER_FILES) $(MAKE_DEFS_MK_PATH)
473 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
474         $(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
475 else
476         @echo "Compiling $<" $(call get_ctext_for_obj,$@)
477         @$(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
478 endif
480 $(BASE_OBJ_CONFIG_PATH)/%.o: $(CONFIG_PATH)/%.S $(MK_HEADER_FILES) $(MAKE_DEFS_MK_PATH)
481 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
482         $(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
483 else
484         @echo "Compiling $<" $(call get_ctext_for_obj,$@)
485         @$(CC) $(call get_cflags_for_obj,$@) -c $< $(COMPILER_OUTPUT_FLAG) $@
486 endif
489 # --- Environment check rules ---
491 check-env: check-env-make-defs check-env-fragments check-env-mk
493 check-env-mk:
494 ifeq ($(CONFIG_MK_PRESENT),no)
495         $(error Cannot proceed: config.mk not detected! Run configure first)
496 endif
498 check-env-fragments: check-env-mk
499 ifeq ($(MAKEFILE_FRAGMENTS_PRESENT),no)
500         $(error Cannot proceed: makefile fragments not detected! Run configure first)
501 endif
503 check-env-make-defs: check-env-fragments
504 ifeq ($(MAKE_DEFS_MK_PRESENT),no)
505         $(error Cannot proceed: make_defs.mk not detected! Invalid configuration)
506 endif
509 # --- All-purpose library rule (static and shared) ---
511 blis-lib: check-env $(MK_LIBS)
514 # --- Static library archiver rules ---
516 $(MK_ALL_BLIS_LIB): $(MK_ALL_BLIS_OBJS)
517 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
518         $(AR) $(ARFLAGS) $@ $?
519         $(RANLIB) $@
520 else
521         @echo "Archiving $@"
522         @$(AR) $(ARFLAGS) $@ $?
523         @$(RANLIB) $@
524 endif
527 # --- Dynamic library linker rules ---
529 $(MK_ALL_BLIS_DLL): $(MK_ALL_BLIS_OBJS)
530 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
531         $(LINKER) $(SOFLAGS) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@ $?
532 else 
533         @echo "Dynamically linking $@"
534         @$(LINKER) $(SOFLAGS) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@ $?
535 endif
538 # --- Test suite rules ---
540 testsuite: testsuite-run
542 testsuite-bin: check-env $(TESTSUITE_BIN)
544 $(BASE_OBJ_TESTSUITE_PATH)/%.o: $(TESTSUITE_SRC_PATH)/%.c
545 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
546         $(CC) $(CFLAGS) -c $< $(COMPILER_OUTPUT_FLAG) $@
547 else
548         @echo "Compiling $<"
549         @$(CC) $(CFLAGS) -c $< $(COMPILER_OUTPUT_FLAG) $@
550 endif
552 ifeq ($(CONFIG_NAME),pnacl)
554 # Link executable (produces unstable LLVM bitcode)
555 $(MK_TESTSUITE_BIN_UNSTABLE): $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB)
556 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
557         $(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@
558 else
559         @echo "Linking $@ against '$(MK_BLIS_LIB) $(LDFLAGS)'"
560         @$(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@
561 endif
563 # Finalize PNaCl executable (i.e. convert from LLVM bitcode to PNaCl bitcode)
564 $(MK_TESTSUITE_BIN_PNACL): $(MK_TESTSUITE_BIN_UNSTABLE)
565 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
566         $(FINALIZER) $(FINFLAGS) $(COMPILER_OUTPUT_FLAG) $@ $<
567 else
568         @echo "Finalizing $@"
569         @$(FINALIZER) $(FINFLAGS) $(COMPILER_OUTPUT_FLAG) $@ $<
570 endif
572 # Translate PNaCl executable to x86-64 NaCl executable
573 $(TESTSUITE_BIN): $(MK_TESTSUITE_BIN_PNACL)
574 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
575         $(TRANSLATOR) $(TRNSFLAGS) $(TRNSAMD64FLAGS) $< $(COMPILER_OUTPUT_FLAG) $@
576 else
577         @echo "Translating $< -> $@"
578         @$(TRANSLATOR) $(TRNSFLAGS) $(TRNSAMD64FLAGS) $< $(COMPILER_OUTPUT_FLAG) $@
579 endif
581 else # Non-PNaCl case
583 ifeq ($(CONFIG_NAME),emscripten)
584 # Generate JavaScript and embed testsuite resources normally
585 $(TESTSUITE_BIN): $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(TESTSUITE_CONF_GEN_PATH) $(TESTSUITE_CONF_OPS_PATH)
586 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
587         $(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@ \
588                 --embed-file $(TESTSUITE_CONF_GEN_PATH)@input.general \
589                 --embed-file $(TESTSUITE_CONF_OPS_PATH)@input.operations
590 else
591         @echo "Linking $@ against '$(MK_BLIS_LIB) $(LDFLAGS)'"
592         @$(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@ \
593                 --embed-file $(TESTSUITE_CONF_GEN_PATH)@input.general \
594                 --embed-file $(TESTSUITE_CONF_OPS_PATH)@input.operations
595 endif
596 else
597 # Link executable normally
598 $(TESTSUITE_BIN): $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB)
599 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
600         $(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@
601 else
602         @echo "Linking $@ against '$(MK_BLIS_LIB) $(LDFLAGS)'"
603         @$(LINKER) $(MK_TESTSUITE_OBJS) $(MK_BLIS_LIB) $(LDFLAGS) $(COMPILER_OUTPUT_FLAG) $@
604 endif
605 endif
607 endif
609 testsuite-run: testsuite-bin
610 ifeq ($(CONFIG_NAME),pnacl)
611 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
612         $(NACL_SDK_ROOT)/tools/sel_ldr_x86_64 -a -c -q \
613             -B $(NACL_SDK_ROOT)/tools/irt_core_x86_64.nexe -- \
614             $(TESTSUITE_BIN) -g $(TESTSUITE_CONF_GEN_PATH) \
615                              $(COMPILER_OUTPUT_FLAG) $(TESTSUITE_CONF_OPS_PATH) \
616                          > $(TESTSUITE_OUT_FILE)
617 else
618         @echo "Running $(TESTSUITE_BIN) with output redirected to '$(TESTSUITE_OUT_FILE)'"
619         @$(NACL_SDK_ROOT)/tools/sel_ldr_x86_64 -a -c -q \
620             -B $(NACL_SDK_ROOT)/tools/irt_core_x86_64.nexe -- \
621             $(TESTSUITE_BIN) -g $(TESTSUITE_CONF_GEN_PATH) \
622                              $(COMPILER_OUTPUT_FLAG) $(TESTSUITE_CONF_OPS_PATH) \
623                          > $(TESTSUITE_OUT_FILE)
624 endif
625 else
626 ifeq ($(CONFIG_NAME),emscripten)
627 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
628         $(JSINT) $(TESTSUITE_BIN)
629 else
630         @echo "Running $(TESTSUITE_BIN)"
631         @$(JSINT) $(TESTSUITE_BIN)
632 endif
633 else
634 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
635         ./$(TESTSUITE_BIN) -g $(TESTSUITE_CONF_GEN_PATH) \
636                            $(COMPILER_OUTPUT_FLAG) $(TESTSUITE_CONF_OPS_PATH) \
637                         > $(TESTSUITE_OUT_FILE)
638 else
639         @echo "Running $(TESTSUITE_BIN) with output redirected to '$(TESTSUITE_OUT_FILE)'"
640         @./$(TESTSUITE_BIN) -g $(TESTSUITE_CONF_GEN_PATH) \
641                             $(COMPILER_OUTPUT_FLAG)  $(TESTSUITE_CONF_OPS_PATH) \
642                          > $(TESTSUITE_OUT_FILE)
643 endif
644 endif # emscripten
645 endif # pnacl
647 # --- Install rules ---
648 #ifeq ($(CONFIG_NAME),c66x) $(filter $(var),X `')
650 install-libs: check-env $(MK_LIBS_INST_W_VERS_CONF) 
651 ifeq ($(CONFIG_NAME), $(filter c66x am57x shannon,$(CONFIG_NAME)))
652         @echo "Installing as DSP Binary"
653         @cp $(MK_BLIS_LIB_INST_W_VERS_CONF) $(patsubst %.a, %.ae66, $(MK_BLIS_LIB_INST_W_VERS_CONF))
654         @$(SYMLINK) $(notdir $(patsubst %.a, %.ae66, $(MK_BLIS_LIB_INST_W_VERS_CONF))) $(INSTALL_PREFIX)/lib/$(BLIS_LIB_BASE_NAME).ae66 
655 endif
657 install-headers: check-env $(MK_INCL_DIR_INST)
659 $(MK_INCL_DIR_INST): $(MK_HEADER_FILES) $(CONFIG_MK_FILE)
660 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
661         $(MKDIR) $(@)
662         $(INSTALL) -m 0644 $(MK_HEADER_FILES) $(@)
663 else
664         @$(MKDIR) $(@)
665         @echo "Installing C header files into $(@)/"
666         @$(INSTALL) -m 0644 $(MK_HEADER_FILES) $(@)
667 endif
669 $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).a: $(BASE_LIB_PATH)/%.a $(CONFIG_MK_FILE)
670 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
671         $(MKDIR) $(@D)
672         $(INSTALL) -m 0644 $< $@
673 else
674         @echo "Installing $(@F) into $(INSTALL_PREFIX)/lib/"
675         @$(MKDIR) $(@D)
676         @$(INSTALL) -m 0644 $< $@
677 endif
679 $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).so: $(BASE_LIB_PATH)/%.so $(CONFIG_MK_FILE)
680 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
681         $(MKDIR) $(@D)
682         $(INSTALL) -m 0644 $< $@
683 else
684         @echo "Installing $(@F) into $(INSTALL_PREFIX)/lib/"
685         @$(MKDIR) $(@D)
686         @$(INSTALL) -m 0644 $< $@
687 endif
689 #install-lib-dsp: $(MK_BLIS_LIB_INST_W_VERS_CONF)
690 #ifeq ($(CONFIG_NAME),c66x)
691         #cp $(MK_BLIS_LIB_INST_W_VERS_CONF) $(patsubst %.a, %.ae66, $(MK_BLIS_LIB_INST_W_VERS_CONF))
692 #endif
698 # --- Install-symlinks rules ---
700 install-lib-symlinks: check-env $(MK_LIBS_INST)
702 $(INSTALL_PREFIX)/lib/%.a: $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).a
703 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
704         $(SYMLINK) $(<F) $(@F)
705         $(MV) $(@F) $(INSTALL_PREFIX)/lib/
706 else
707         @echo "Installing symlink $(@F) into $(INSTALL_PREFIX)/lib/"
708         @$(SYMLINK) $(<F) $(@F)
709         @$(MV) $(@F) $(INSTALL_PREFIX)/lib/
710 endif
712 $(INSTALL_PREFIX)/lib/%.so: $(INSTALL_PREFIX)/lib/%-$(VERS_CONF).so
713 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
714         $(SYMLINK) $(<F) $(@F)
715         $(MV) $(@F) $(INSTALL_PREFIX)/lib/
716 else
717         @echo "Installing symlink $(@F) into $(INSTALL_PREFIX)/lib/"
718         @$(SYMLINK) $(<F) $(@F)
719         @$(MV) $(@F) $(INSTALL_PREFIX)/lib/
720 endif
723 # --- Query current configuration ---
725 showconfig: check-env
726         @echo "Current configuration is '$(CONFIG_NAME)', located in '$(CONFIG_PATH)'"
729 # --- Clean rules ---
731 cleanlib: check-env
732 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
733         - $(FIND) $(BASE_OBJ_CONFIG_PATH) -name "*.o" | $(XARGS) $(RM_F)
734         - $(FIND) $(BASE_OBJ_FRAME_PATH) -name "*.o" | $(XARGS) $(RM_F)
735         - $(FIND) $(BASE_LIB_PATH) -name "*.a" | $(XARGS) $(RM_F)
736         - $(FIND) $(BASE_LIB_PATH) -name "*.so" | $(XARGS) $(RM_F)
737 else
738         @echo "Removing .o files from $(BASE_OBJ_CONFIG_PATH)."
739         @- $(FIND) $(BASE_OBJ_CONFIG_PATH) -name "*.o" | $(XARGS) $(RM_F)
740         @echo "Removing .o files from $(BASE_OBJ_FRAME_PATH)."
741         @- $(FIND) $(BASE_OBJ_FRAME_PATH) -name "*.o" | $(XARGS) $(RM_F)
742         @echo "Removing .a files from $(BASE_LIB_PATH)."
743         @- $(FIND) $(BASE_LIB_PATH) -name "*.a" | $(XARGS) $(RM_F)
744         @echo "Removing .so files from $(BASE_LIB_PATH)."
745         @- $(FIND) $(BASE_LIB_PATH) -name "*.so" | $(XARGS) $(RM_F)
746 endif
748 cleantest: check-env
749 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
750         - $(FIND) $(BASE_OBJ_TESTSUITE_PATH) -name "*.o" -name "*.pexe" | $(XARGS) $(RM_F)
751         - $(RM_RF) $(TESTSUITE_BIN)
752 else
753         @echo "Removing object files from $(BASE_OBJ_TESTSUITE_PATH)."
754         @- $(FIND) $(BASE_OBJ_TESTSUITE_PATH) -name "*.o" -name "*.pexe" | $(XARGS) $(RM_F)
755         @echo "Removing $(TESTSUITE_BIN) binary."
756         @- $(RM_RF) $(TESTSUITE_BIN)
757 endif
759 cleanmk: check-env
760 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
761         - $(FIND) $(CONFIG_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
762         - $(FIND) $(FRAME_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
763 else
764         @echo "Removing makefile fragments from $(CONFIG_PATH)."
765         @- $(FIND) $(CONFIG_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
766         @echo "Removing makefile fragments from $(FRAME_PATH)."
767         @- $(FIND) $(FRAME_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
768 endif
770 distclean: check-env cleanmk cleanlib cleantest
771 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
772         - $(RM_F) $(CONFIG_MK_FILE)
773         - $(RM_RF) $(TESTSUITE_OUT_FILE)
774         - $(RM_RF) $(OBJ_DIR)
775         - $(RM_RF) $(LIB_DIR)
776 else
777         @echo "Removing $(CONFIG_MK_FILE)."
778         @- $(RM_F) $(CONFIG_MK_FILE)
779         @echo "Removing $(TESTSUITE_OUT_FILE)."
780         @- $(RM_F) $(TESTSUITE_OUT_FILE)
781         @echo "Removing $(OBJ_DIR)."
782         @- $(RM_RF) $(OBJ_DIR)
783         @echo "Removing $(LIB_DIR)."
784         @- $(RM_RF) $(LIB_DIR)
785 endif
788 # --- CHANGELOG rules ---
790 changelog: check-env
791         @echo "Updating '$(DIST_PATH)/$(CHANGELOG)' via '$(GIT_LOG)'."
792         @$(GIT_LOG) > $(DIST_PATH)/$(CHANGELOG) 
795 # --- Uninstall rules ---
797 uninstall-old: $(UNINSTALL_LIBS)
799 uninstall-libs: check-env
800 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
801         - $(RM_F) $(MK_LIBS_INST_W_VERS_CONF)
802 else
803         @echo "Removing $(MK_LIBS_INST_W_VERS_CONF)."
804         @- $(RM_F) $(MK_LIBS_INST_W_VERS_CONF)
805 ifeq ($(CONFIG_NAME),c66x)
806         @echo "Removing$(patsubst %.a, %.ae66, $(MK_BLIS_LIB_INST_W_VERS_CONF))"
807         @- $(RM_F) $(patsubst %.a, %.ae66, $(MK_BLIS_LIB_INST_W_VERS_CONF))
808 endif
809 endif
811 uninstall-lib-symlinks: check-env
812 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
813         - $(RM_F) $(MK_LIBS_INST)
814 else
815         @echo "Removing $(MK_LIBS_INST)."
816         @- $(RM_F) $(MK_LIBS_INST)
817 endif
819 uninstall-headers: check-env
820 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
821         - $(RM_RF) $(MK_INCL_DIR_INST)
822 else
823         @echo "Removing $(MK_INCL_DIR_INST)/."
824         @- $(RM_RF) $(MK_INCL_DIR_INST)
825 endif
827 $(UNINSTALL_LIBS): check-env
828 ifeq ($(BLIS_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
829         - $(RM_F) $@
830 else
831         @echo "Removing $(@F) from $(@D)/."
832         @- $(RM_F) $@
833 endif