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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
|
#
# Makefile
#
# Field G. Van Zee
#
# Top-level makefile for libflame linear algebra library.
#
#
#
# --- Makefile PHONY target definitions ----------------------------------------
#
.PHONY: all \
libs libflame \
check-env check-env-config check-env-fragments \
flat-headers \
test \
install-headers install-libs install-lib-symlinks \
clean cleanmk cleanh cleanlib cleanleaves distclean \
install \
uninstall-libs uninstall-lib-symlinks uninstall-headers
# Accept an abbreivated request for verbosity (e.g. 'make V=1 ...')
ifeq ($(V),1)
ENABLE_VERBOSE := yes
endif
ifeq ($(V),0)
ENABLE_VERBOSE := no
endif
#
# --- Include architecture-specific variable definitions ----------------------
#
# Avoid catting the config.sys_type file unless it exists. This makes the
# output of things like 'make distclean' (when the directory is already
# clean) less confusing.
ifneq ($(wildcard config.sys_type),)
# The host string will uniquely identify the current host (as much
# as is reasonable) for purposes of separating the configure products and
# object files of one architecture from another.
HOST := $(shell cat config.sys_type)
else
HOST := unknown-generic
endif
# --- Important directories for source code and build products ---
SRC_DIR := src
CONFIG_DIR := config
OBJ_DIR := obj
LIB_DIR := lib
INC_DIR := include
# Use the system type to name the config, object, and library directories.
# These directories are special in that they will contain products specific
# to this particular architecture.
BASE_CONFIG_PATH := ./$(CONFIG_DIR)/$(HOST)
BASE_OBJ_PATH := ./$(OBJ_DIR)/$(HOST)/$(SRC_DIR)
BASE_LIB_PATH := ./$(LIB_DIR)/$(HOST)
BASE_INC_PATH := ./$(INC_DIR)/$(HOST)
# Pathname to the makefile fragment containing lots of various definitions,
# most of which were substituted via configure.
CONFIG_MK_FILE := $(BASE_CONFIG_PATH)/config.mk
# Include the definitions in the config makefile fragment.
-include $(CONFIG_MK_FILE)
# Detect whether we actually got the config makefile fragment. If we didn't,
# then it is likely that the user has not yet generated it (via configure).
ifeq ($(strip $(CONFIG_MK_INCLUDED)),yes)
CONFIG_MK_PRESENT := yes
IS_CONFIGURED := yes
else
CONFIG_MK_PRESENT := no
IS_CONFIGURED := no
endif
#
# --- Library name and local paths ---------------------------------------------
#
# --- Shared library extension ---
SHLIB_EXT := so
# --- Library names ---
LIBFLAME := libflame
LIBFLAME_A := $(LIBFLAME).a
LIBFLAME_SO := $(LIBFLAME).$(SHLIB_EXT)
# --- Library filepaths ---
# Append the base library path to the library names.
LIBFLAME_A_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_A)
LIBFLAME_SO_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_SO)
LIBFLAME_SO_MAJ_EXT := $(SHLIB_EXT).$(SO_MAJOR)
LIBFLAME_SO_MMB_EXT := $(SHLIB_EXT).$(SO_MMB)
LIBFLAME_SONAME := $(LIBFLAME).$(LIBFLAME_SO_MAJ_EXT)
LIBFLAME_SO_MAJ_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_SONAME)
# Construct the output path when building a shared library.
LIBFLAME_SO_OUTPUT_NAME := $(LIBFLAME_SO_PATH)
#
# --- Shared library flags ----------------------------------------------------
#
# Specify the shared library's 'soname' field.
# NOTE: The flag for creating shared objects is different for Linux and OS X.
SOFLAGS := -shared
SOFLAGS += -Wl,-soname,$(LIBFLAME_SONAME)
#
# --- Main target variable definitions ----------------------------------------
#
MK_BASE_FLAMEC_SRC :=
MK_BASE_FLAMEC_OBJS :=
MK_BLAS_FLAMEC_SRC :=
MK_BLAS_FLAMEC_OBJS :=
MK_LAPACK_FLAMEC_SRC :=
MK_LAPACK_FLAMEC_OBJS :=
MK_MAP_LAPACK2FLAMEC_SRC :=
MK_MAP_LAPACK2FLAMEC_OBJS :=
MK_MAP_LAPACK2FLAMEC_F2C_SRC :=
MK_MAP_LAPACK2FLAMEC_F2C_OBJS :=
MK_MAP_LAPACK2FLAMEC_F2C_FLAMEC_SRC :=
MK_MAP_LAPACK2FLAMEC_F2C_FLAMEC_OBJS :=
MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_SRC :=
MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_OBJS :=
MK_FLABLAS_F2C_SRC :=
MK_FLABLAS_F2C_OBJS :=
# --- Define install target names for static libraries ---
LIBFLAME_A_INST := $(INSTALL_LIBDIR)/$(LIBFLAME_A)
# --- Define install target names for dynamic libraries ---
LIBFLAME_SO_INST := $(INSTALL_LIBDIR)/$(LIBFLAME_SO)
LIBFLAME_SO_MAJ_INST := $(INSTALL_LIBDIR)/$(LIBFLAME_SONAME)
LIBFLAME_SO_MMB_INST := $(INSTALL_LIBDIR)/$(LIBFLAME).$(LIBFLAME_SO_MMB_EXT)
# --- Determine which libraries to build ---
MK_LIBS :=
MK_LIBS_INST :=
MK_LIBS_SYML :=
ifeq ($(FLA_ENABLE_STATIC_BUILD),yes)
MK_LIBS += $(LIBFLAME_A_PATH)
MK_LIBS_INST += $(LIBFLAME_A_INST)
MK_LIBS_SYML +=
endif
ifeq ($(FLA_ENABLE_DYNAMIC_BUILD),yes)
MK_LIBS += $(LIBFLAME_SO_PATH) \
$(LIBFLAME_SO_MAJ_PATH)
MK_LIBS_INST += $(LIBFLAME_SO_MMB_INST)
MK_LIBS_SYML += $(LIBFLAME_SO_INST) \
$(LIBFLAME_SO_MAJ_INST)
endif
# Strip leading, internal, and trailing whitespace.
MK_LIBS_INST := $(strip $(MK_LIBS_INST))
MK_LIBS_SYML := $(strip $(MK_LIBS_SYML))
# Set the path to the subdirectory of the include installation directory.
MK_INCL_DIR_INST := $(INSTALL_INCDIR)
#
# --- Test definitions --------------------------------------------------------
#
#
# --- Include sub-tree makefile fragments --------------------------------------
#
# Makefile fragment name.
FRAGMENT_MK := .fragment.mk
# Initialize our list of directory paths to makefile fragments with the empty list.
FRAGMENT_DIR_PATHS :=
# The only fragment subdirectory that we build from the top-level directory is the
# source directory.
SRC_PATH := $(DIST_PATH)/$(SRC_DIR)
SRC_FRAG_PATH := ./$(OBJ_DIR)/$(HOST)/$(SRC_DIR)
# These variables are used by the include statements as they recursively include
# one another. We initialize them to the distribution path and the base object
# path.
PARENT_SRC_PATH := $(DIST_PATH)
PARENT_PATH := ./$(OBJ_DIR)/$(HOST)
# Recursively include all the makefile fragments.
#-include $(addsuffix /$(FRAGMENT_MK), $(FRAGMENT_SUB_DIRS))
-include $(addsuffix /$(FRAGMENT_MK), $(SRC_FRAG_PATH))
# Create a list of the makefile fragments.
MAKEFILE_FRAGMENTS := $(addsuffix /$(FRAGMENT_MK), $(FRAGMENT_DIR_PATHS))
# Detect whether we actually got any makefile fragments. If we didn't, then it
# is likely that the user has not yet generated them (via configure).
ifeq ($(strip $(MAKEFILE_FRAGMENTS)),)
MAKEFILE_FRAGMENTS_PRESENT := no
else
MAKEFILE_FRAGMENTS_PRESENT := yes
endif
#
# --- Compiler include path definitions ----------------------------------------
#
# A script (originating from BLIS) that creates a monolithic header file from
# many header files that are recursively #included from one another.
BUILD_PATH := $(DIST_PATH)/build
FLATTEN_H := $(PYTHON) $(BUILD_PATH)/flatten-headers.py
# The path to the main header files.
FLAF2C_H_SRC_PATH := $(DIST_PATH)/src/base/flamec/include/FLA_f2c.h
FLAME_H_SRC_PATH := $(DIST_PATH)/src/base/flamec/include/FLAME.h
BLIS1_H_SRC_PATH := $(DIST_PATH)/src/base/flamec/blis/include/blis1.h
# Construct the path to what will be the intermediate flattened/monolithic
# header files.
FLAME_H := FLAME.h
FLAME_H_FLAT := $(BASE_INC_PATH)/$(FLAME_H)
BLIS1_H := blis1.h
BLIS1_H_FLAT := $(BASE_INC_PATH)/$(BLIS1_H)
FLAF2C_H := FLA_f2c.h
FLAF2C_H_FLAT := $(BASE_INC_PATH)/$(FLAF2C_H)
# Expand the fragment paths that contain .h files to attain the set of header
# files present in all fragment paths.
MK_HEADER_FILES := $(foreach frag_path, $(FRAGMENT_DIR_PATHS), $(wildcard $(frag_path)/*.h))
MK_HEADER_FILES += $(BASE_CONFIG_PATH)/FLA_config.h
# Strip the leading, internal, and trailing whitespace from our list of header
# files. This makes the "make install-headers" much more readable.
MK_HEADER_FILES := $(strip $(MK_HEADER_FILES))
# Expand the fragment paths that contain .h files, and take the first expansion.
# Then, strip the header filename to leave the path to each header location.
# Notice this process even weeds out duplicates! Add the config directory manually
# since it contains FLA_config.h.
MK_HEADER_DIR_PATHS := $(dir $(foreach frag_path, $(FRAGMENT_DIR_PATHS), \
$(firstword $(wildcard $(frag_path)/*.h))))
MK_HEADER_DIR_PATHS += $(BASE_CONFIG_PATH)
# Define a list of headers to flatten. We have to flatten blis1.h and FLA_f2c.h
# because a few files #include only those files, but they aren't needed after
# libflame is compiled.
HEADERS_TO_FLATTEN := $(FLAME_H_FLAT) $(BLIS1_H_FLAT) $(FLAF2C_H_FLAT)
# Define a list of headers to install and their installation path. The default
# is to only install FLAME.h.
HEADERS_TO_INSTALL := $(FLAME_H_FLAT)
HEADERS_INST := $(addprefix $(MK_INCL_DIR_INST)/, $(notdir $(HEADERS_TO_INSTALL)))
# Add -I to each header path so we can specify our include search paths to the
# C and Fortran compilers. NOTE: This is primarily for access to the monolithic
# (flattened) FLAME.h file, athough a few other files are placed there too (see
# above).
#INCLUDE_PATHS := $(strip $(patsubst %, -I%, $(MK_HEADER_DIR_PATHS)))
INCLUDE_PATHS := $(strip $(patsubst %, -I%, $(BASE_INC_PATH)))
# When lapack2flame is enabled, we need to add a -I option for the directory
# in which the lapack2flame headers reside.
ifeq ($(FLA_ENABLE_LAPACK2FLAME),yes)
L2F_FRAG_DIR_PATHS := $(filter $(DIST_PATH)/src/map/lapack2flamec%,$(FRAGMENT_DIR_PATHS))
L2F_HEADER_DIR_PATHS := $(dir $(foreach frag_path, $(L2F_FRAG_DIR_PATHS), \
$(firstword $(wildcard $(frag_path)/*.h))))
INCLUDE_PATHS += $(strip $(patsubst %, -I%, $(L2F_HEADER_DIR_PATHS)))
endif
# Add the include flags determined above to various compiler flags variables.
CFLAGS := $(CFLAGS) $(INCLUDE_PATHS)
CFLAGS_NOOPT := $(CFLAGS_NOOPT) $(INCLUDE_PATHS)
CPPFLAGS := $(CPPFLAGS) $(INCLUDE_PATHS)
FFLAGS := $(FFLAGS) $(INCLUDE_PATHS)
#
# --- Library object definitions -----------------------------------------------
#
# Convert source file paths to object file paths by replaying the base source
# directory with the base object directory, and also replacing the source file
# suffix (ie: '.c' or '.f') with '.o'.
MK_FLABLAS_F2C_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_FLABLAS_F2C_SRC)))
MK_BASE_FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_BASE_FLAMEC_SRC)))
MK_BLAS_FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_BLAS_FLAMEC_SRC)))
MK_LAPACK_FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_LAPACK_FLAMEC_SRC)))
MK_MAP_LAPACK2FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_MAP_LAPACK2FLAMEC_SRC)))
MK_MAP_LAPACK2FLAMEC_F2C_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_MAP_LAPACK2FLAMEC_F2C_SRC)))
MK_MAP_LAPACK2FLAMEC_F2C_FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_MAP_LAPACK2FLAMEC_F2C_FLAMEC_SRC)))
MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \
$(filter %.c, $(MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_SRC)))
# Combine the base, blas, and lapack libraries.
MK_ALL_FLAMEC_OBJS := $(MK_BASE_FLAMEC_OBJS) \
$(MK_BLAS_FLAMEC_OBJS) \
$(MK_LAPACK_FLAMEC_OBJS)
# Prepend the flablas source code files, if requested
# LAPACK
ifeq ($(FLA_ENABLE_LAPACK2FLAME),yes)
MK_ALL_FLAMEC_OBJS := $(MK_MAP_LAPACK2FLAMEC_OBJS) \
$(MK_MAP_LAPACK2FLAMEC_F2C_OBJS) \
$(MK_MAP_LAPACK2FLAMEC_F2C_FLAMEC_OBJS) \
$(MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_OBJS) \
$(MK_ALL_FLAMEC_OBJS)
endif
# BLAS
ifeq ($(FLA_ENABLE_BUILTIN_BLAS),yes)
ifeq ($(FLA_ENABLE_LAPACK2FLAME),no)
MK_FLABLAS_F2C_OBJS := $(MK_MAP_LAPACK2FLAMEC_F2C_INSTALL_OBJS) \
$(MK_FLABLAS_F2C_OBJS)
endif
MK_ALL_FLAMEC_OBJS := $(MK_FLABLAS_F2C_OBJS) \
$(MK_ALL_FLAMEC_OBJS)
endif
### Kyungjoo 2015.10.21
#AR_CHUNK_SIZE=4096
AR_CHUNK_SIZE=1024
#
# --- Targets/rules ------------------------------------------------------------
#
# --- Primary targets ---
all: libs
libs: libflame
install: libs install-libs install-lib-symlinks install-headers
uninstall: uninstall-libs uninstall-lib-symlinks uninstall-headers
clean: cleanh cleanlib
# --- Environment check rules ---
check-env: check-env-config check-env-fragments
check-env-config:
ifeq ($(CONFIG_MK_PRESENT),no)
$(error Cannot proceed: config.mk not detected! Run configure first)
endif
check-env-fragments: check-env-config
ifeq ($(MAKEFILE_FRAGMENTS_PRESENT),no)
$(error Cannot proceed: makefile fragments not detected! Run configure first)
endif
# --- Cosolidated header creation ---
flat-headers: check-env $(FLAME_H_FLAT) $(BLIS1_H_FLAT) $(FLAF2C_H_FLAT)
# Consolidated FLAME.h header creation
$(FLAME_H_FLAT): $(MK_HEADER_FILES)
ifeq ($(ENABLE_VERBOSE),yes)
$(FLATTEN_H) -c -v1 $(FLAME_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
else
@echo -n "Generating monolithic $(@)"
@$(FLATTEN_H) -c -v1 $(FLAME_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
@echo "Generated monolithic $@"
endif
# Consolidated blis1.h header creation
$(BLIS1_H_FLAT): $(MK_HEADER_FILES) $(FLAME_H_FLAT)
ifeq ($(ENABLE_VERBOSE),yes)
$(FLATTEN_H) -c -v1 $(BLIS1_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
else
@echo -n "Generating monolithic $(@)"
@$(FLATTEN_H) -c -v1 $(BLIS1_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
@echo "Generated monolithic $@"
endif
# Consolidated FLA_f2c.h header creation
# NOTE: This file doesn't actually need any inlining, but we do need to
# "install" it to $(BASE_INC_PATH), so we opt to go through the same
# motions as for FLAME.h and FLA_f2c.h.
$(FLAF2C_H_FLAT): $(MK_HEADER_FILES) $(FLAME_H_FLAT) $(BLIS1_H_FLAT)
ifeq ($(ENABLE_VERBOSE),yes)
$(FLATTEN_H) -c -v1 $(FLAF2C_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
else
@echo -n "Generating monolithic $(@)"
@$(FLATTEN_H) -c -v1 $(FLAF2C_H_SRC_PATH) $@ $(BASE_INC_PATH) "$(MK_HEADER_DIR_PATHS)"
@echo "Generated monolithic $@"
endif
# --- Special source code / object code rules ---
FLA_SLAMCH=base/flamec/util/lapack/mch/fla_slamch
$(BASE_OBJ_PATH)/$(FLA_SLAMCH).o: $(SRC_PATH)/$(FLA_SLAMCH).c $(CONFIG_MK_FILE) $(HEADERS_TO_FLATTEN)
ifeq ($(ENABLE_VERBOSE),yes)
$(CC) $(CFLAGS_NOOPT) -c $< -o $@
else
@echo "Compiling $<"
@$(CC) $(CFLAGS_NOOPT) -c $< -o $@
endif
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
@echo $@ >> $(AR_OBJ_LIST_FILE)
endif
FLA_DLAMCH=base/flamec/util/lapack/mch/fla_dlamch
$(BASE_OBJ_PATH)/$(FLA_DLAMCH).o: $(SRC_PATH)/$(FLA_DLAMCH).c $(CONFIG_MK_FILE) $(HEADERS_TO_FLATTEN)
ifeq ($(ENABLE_VERBOSE),yes)
$(CC) $(CFLAGS_NOOPT) -c $< -o $@
else
@echo "Compiling $<"
@$(CC) $(CFLAGS_NOOPT) -c $< -o $@
endif
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
@echo $@ >> $(AR_OBJ_LIST_FILE)
endif
# --- General source code / object code rules ---
# Default compilation rules
$(BASE_OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(CONFIG_MK_FILE) $(HEADERS_TO_FLATTEN)
ifeq ($(ENABLE_VERBOSE),yes)
$(CC) $(CFLAGS) -c $< -o $@
else
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
endif
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
@echo $@ >> $(AR_OBJ_LIST_FILE)
endif
# --- All-purpose library rule (static and shared) ---
libflame: check-env $(MK_LIBS)
# --- Static library archiver rules ---
$(LIBFLAME_A_PATH): $(MK_ALL_FLAMEC_OBJS)
ifeq ($(ENABLE_VERBOSE),yes)
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
### Kyungjoo 2015.10.21
$(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $@
### Previous hack (works on linux, not on osx; osx's ar does not support @file)
# echo $(ARFLAGS) $@ > $(AR_ARG_LIST_FILE)
# $(CAT) $(AR_OBJ_LIST_FILE) >> $(AR_ARG_LIST_FILE)
# $(AR) @$(AR_ARG_LIST_FILE)
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
# the list of prerequisites.
$(AR) $(ARFLAGS) $@ $^
endif
$(RANLIB) $@
# $(MKDIR) include_local
# cp -f $(MK_HEADER_FILES) include_local
else
@echo "Archiving $@"
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
### Kyungjoo 2015.10.21
@$(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $@
### Previous hack (works on linux, not on osx; osx's ar does not support @file)
# @echo $(ARFLAGS) $@ > $(AR_ARG_LIST_FILE)
# @$(CAT) $(AR_OBJ_LIST_FILE) >> $(AR_ARG_LIST_FILE)
# @$(AR) @$(AR_ARG_LIST_FILE)
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
# the list of prerequisites.
@$(AR) $(ARFLAGS) $@ $^
endif
@$(RANLIB) $@
# @$(MKDIR) include_local
# @cp -f $(MK_HEADER_FILES) include_local
endif
# --- Shared library linker rules ---
$(LIBFLAME_SO_PATH): $(MK_ALL_FLAMEC_OBJS)
ifeq ($(ENABLE_VERBOSE),yes)
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
$(LINKER) $(SOFLAGS) $(LDFLAGS) -o $@ @$(AR_OBJ_LIST_FILE)
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
# the list of prerequisites.
$(LINKER) $(SOFLAGS) $(LDFLAGS) -o $@ $^
endif
else
@echo "Dynamically linking $@"
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
@$(LINKER) $(SOFLAGS) $(LDFLAGS) -o $@ @$(AR_OBJ_LIST_FILE)
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
# the list of prerequisites.
@$(LINKER) $(SOFLAGS) $(LDFLAGS) -o $@ $^
endif
endif
# Local symlink for shared library.
# NOTE: We use a '.loc' suffix to avoid filename collisions in case this
# rule is executed concurrently with the install-lib-symlinks rule, which
# also creates symlinks in the current directory (before installing them).
$(LIBFLAME_SO_MAJ_PATH): $(LIBFLAME_SO_PATH)
ifeq ($(ENABLE_VERBOSE),yes)
$(SYMLINK) $(<F) $(@F).loc
$(MV) $(@F).loc $(BASE_LIB_PATH)/$(@F)
else # ifeq ($(ENABLE_VERBOSE),no)
@echo "Creating symlink $@"
@$(SYMLINK) $(<F) $(@F).loc
@$(MV) $(@F).loc $(BASE_LIB_PATH)/$(@F)
endif
# Original implementation of the rule above.
# FGVZ: This rule has been observed to not work on at least one system, where
# it appears the ".in" file is not fully written out, or written out at all,
# prior to the shared library link command being executed.
#$(MK_ALL_FLAMEC_DLL): $(MK_ALL_FLAMEC_OBJS)
#ifeq ($(ENABLE_VERBOSE),yes)
#ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
# $(file > $@.in,$^)
# $(LINKER) -shared -Wl,-soname,libflame.so $(LDFLAGS) -o $@ @$@.in
# $(RM) $@.in
#else
# $(LINKER) -shared -Wl,-soname,libflame.so $(LDFLAGS) -o $@ $^
#endif
#else
# @echo "Dynamically linking $@"
#ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
# @$(file > $@.in,$^)
# @$(LINKER) -shared -Wl,-soname,libflame.so $(LDFLAGS) -o $@ @$@.in
# @$(RM) $@.in
#else
# @$(LINKER) -shared -Wl,-soname,libflame.so $(LDFLAGS) -o $@ $^
#endif
#endif
# --- Test suite rules ---
# --- Install rules ---
# --- Install header rules ---
install-headers: check-env $(HEADERS_INST)
$(HEADERS_INST): $(HEADERS_TO_INSTALL) $(CONFIG_MK_FILE)
ifeq ($(ENABLE_VERBOSE),yes)
$(MKDIR) $(MK_INCL_DIR_INST)
$(INSTALL) -m 0644 $(HEADERS_TO_INSTALL) $(MK_INCL_DIR_INST)
else
@$(MKDIR) $(MK_INCL_DIR_INST)
@echo "Installing $(notdir $(HEADERS_TO_INSTALL)) into $(MK_INCL_DIR_INST)/"
@$(INSTALL) -m 0644 $(HEADERS_TO_INSTALL) $(MK_INCL_DIR_INST)
endif
# --- Install library rules ---
install-libs: check-env $(MK_LIBS_INST)
# Install static library.
$(INSTALL_LIBDIR)/%.a: $(BASE_LIB_PATH)/%.a $(CONFIG_MK_FILE)
ifeq ($(ENABLE_VERBOSE),yes)
$(MKDIR) $(@D)
$(INSTALL) -m 0644 $< $@
else
@echo "Installing $(@F) into $(INSTALL_LIBDIR)/"
@$(MKDIR) $(@D)
@$(INSTALL) -m 0644 $< $@
endif
# Install shared library.
$(INSTALL_LIBDIR)/%.$(LIBFLAME_SO_MMB_EXT): $(BASE_LIB_PATH)/%.$(SHLIB_EXT) $(CONFIG_MK_FILE)
ifeq ($(ENABLE_VERBOSE),yes)
$(MKDIR) $(@D)
$(INSTALL) -m 0644 $< $@
else
@echo "Installing $(@F) into $(INSTALL_LIBDIR)/"
@$(MKDIR) $(@D)
@$(INSTALL) -m 0644 $< $@
endif
# --- Install-symlinks rules ---
install-lib-symlinks: check-env $(MK_LIBS_SYML)
$(INSTALL_LIBDIR)/%.$(SHLIB_EXT): $(INSTALL_LIBDIR)/%.$(LIBFLAME_SO_MMB_EXT)
ifeq ($(ENABLE_VERBOSE),yes)
$(SYMLINK) $(<F) $(@F)
$(MV) $(@F) $(INSTALL_LIBDIR)/
else
@echo "Installing symlink $(@F) into $(INSTALL_LIBDIR)/"
@$(SYMLINK) $(<F) $(@F)
@$(MV) $(@F) $(INSTALL_LIBDIR)/
endif
# Install shared library symlink containing only .so major version.
$(INSTALL_LIBDIR)/%.$(LIBFLAME_SO_MAJ_EXT): $(INSTALL_LIBDIR)/%.$(LIBFLAME_SO_MMB_EXT)
ifeq ($(ENABLE_VERBOSE),yes)
$(SYMLINK) $(<F) $(@F)
$(MV) $(@F) $(INSTALL_LIBDIR)/
else
@echo "Installing symlink $(@F) into $(INSTALL_LIBDIR)/"
@$(SYMLINK) $(<F) $(@F)
@$(MV) $(@F) $(INSTALL_LIBDIR)/
endif
# --- Clean rules ---
cleanmk:
ifeq ($(IS_CONFIGURED),yes)
ifeq ($(ENABLE_VERBOSE),yes)
- $(FIND) $(SRC_FRAG_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
else
@echo "Removing makefile fragments from $(SRC_FRAG_PATH)"
@$(FIND) $(SRC_FRAG_PATH) -name "$(FRAGMENT_MK)" | $(XARGS) $(RM_F)
endif
endif
cleanh:
ifeq ($(IS_CONFIGURED),yes)
ifeq ($(ENABLE_VERBOSE),yes)
- $(RM_F) $(HEADERS_TO_FLATTEN)
else
@echo "Removing flattened header files from $(BASE_INC_PATH)"
@$(RM_F) $(HEADERS_TO_FLATTEN)
endif
endif
cleanlib:
ifeq ($(IS_CONFIGURED),yes)
ifeq ($(ENABLE_VERBOSE),yes)
- $(FIND) $(BASE_OBJ_PATH) -name "*.o" | $(XARGS) $(RM_F)
- $(RM_F) $(LIBBLIS_A_PATH)
- $(RM_F) $(LIBBLIS_SO_PATH)
else
@echo "Removing object files from $(BASE_OBJ_PATH)"
@$(FIND) $(BASE_OBJ_PATH) -name "*.o" | $(XARGS) $(RM_F)
@echo "Removing libraries from $(BASE_LIB_PATH)"
@$(RM_F) $(LIBBLIS_A_PATH)
@$(RM_F) $(LIBBLIS_SO_PATH)
endif
endif
distclean: cleanmk cleanh cleanlib
ifeq ($(IS_CONFIGURED),yes)
ifeq ($(ENABLE_VERBOSE),yes)
- $(RM_F) $(AR_OBJ_LIST_FILE)
- $(RM_RF) $(CONFIG_DIR)
- $(RM_RF) $(OBJ_DIR)
- $(RM_RF) $(LIB_DIR)
- $(RM_RF) $(INC_DIR)
- $(RM_RF) config.log
- $(RM_RF) aclocal.m4
- $(RM_RF) autom4te.cache
- $(RM_RF) config.status
- $(RM_RF) config.sys_type
- $(RM_RF) config.dist_path
else
@echo "Removing $(AR_OBJ_LIST_FILE)"
@$(RM_F) $(AR_OBJ_LIST_FILE)
@echo "Removing $(CONFIG_DIR)"
@$(RM_RF) $(CONFIG_DIR)
@echo "Removing $(OBJ_DIR)"
@$(RM_RF) $(OBJ_DIR)
@echo "Removing $(LIB_DIR)"
@$(RM_RF) $(LIB_DIR)
@echo "Removing $(INC_DIR)"
@$(RM_RF) $(INC_DIR)
@echo "Removing intermediate configure files"
@$(RM_RF) config.log
@$(RM_RF) aclocal.m4
@$(RM_RF) autom4te.cache
@$(RM_RF) config.status
@$(RM_RF) config.sys_type
@$(RM_RF) config.dist_path
endif
endif
cleanleaves:
ifeq ($(IS_CONFIGURED),yes)
ifeq ($(ENABLE_VERBOSE),yes)
- $(FIND) $(BASE_OBJ_PATH) -name "*.[osx]" | $(XARGS) $(RM_F)
else
@echo "Removing leaf-level build objects from source tree"
@$(FIND) $(BASE_OBJ_PATH) -name "*.[osx]" | $(XARGS) $(RM_F)
endif
endif
# --- Uninstall rules ---
# NOTE: We can't write these uninstall rules directly in terms of targets
# $(MK_LIBS_INST) and $(MK_INCL_DIR_INST)
# because those targets are already defined in terms of rules that *build*
# those products.
uninstall-libs: check-env
ifeq ($(ENABLE_VERBOSE),yes)
- $(RM_F) $(MK_LIBS_INST)
else
@echo "Uninstalling libraries $(notdir $(MK_LIBS_INST)) from $(dir $(firstword $(MK_LIBS_INST)))."
@- $(RM_F) $(MK_LIBS_INST)
endif
uninstall-lib-symlinks: check-env
ifeq ($(ENABLE_VERBOSE),yes)
- $(RM_F) $(MK_LIBS_SYML)
else
@echo "Uninstalling symlinks $(notdir $(MK_LIBS_SYML)) from $(dir $(firstword $(MK_LIBS_SYML)))."
@- $(RM_F) $(MK_LIBS_SYML)
endif
uninstall-headers: check-env
ifeq ($(ENABLE_VERBOSE),yes)
- $(RM_F) $(HEADERS_INST)
else
@echo "Uninstalling headers '$(notdir $(HEADERS_TO_INSTALL))' from $(MK_INCL_DIR_INST)."
# @- $(RM_F) $(addprefix $(MK_INCL_DIR_INST)/, $(notdir $(HEADERS_TO_INSTALL)))
@- $(RM_F) $(HEADERS_INST)
endif
|