forked from libxsmm/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.inc
2551 lines (2404 loc) · 83 KB
/
Makefile.inc
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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###############################################################################
# Copyright (c) Intel Corporation - All rights reserved. #
# This file is part of the LIBXSMM library. #
# #
# For information on the license, see the LICENSE file. #
# Further information: https://github.com/libxsmm/libxsmm/ #
# SPDX-License-Identifier: BSD-3-Clause #
###############################################################################
# Hans Pabst (Intel Corp.)
###############################################################################
MAKE_VERSION_MAJOR := $(shell echo "$(MAKE_VERSION)" | cut -d. -f1)
MAKE_VERSION_MINOR := $(shell echo "$(MAKE_VERSION)" | cut -d. -f2)
MAKE_VERSION_PATCH := $(shell echo "$(MAKE_VERSION)" | cut -d. -f3)
ifeq (,$(MAKE_VERSION_MAJOR))
MAKE_VERSION_MAJOR := 0
endif
ifeq (,$(MAKE_VERSION_MINOR))
MAKE_VERSION_MINOR := 0
endif
ifeq (,$(MAKE_VERSION_PATCH))
MAKE_VERSION_PATCH := 0
endif
# calculate version number given by up to three components
version = $(shell echo "$$(( \
$(if $1,$(word 1,$1)*10000,0) + \
$(if $2,$2*100,$(if $(word 2,$1),$(word 2,$1)*100,0)) + \
$(if $3,$3,$(if $(word 3,$1),$(word 3,$1),0))))")
MAKE_VERSION_INT := $(call version,$(MAKE_VERSION_MAJOR),$(MAKE_VERSION_MINOR),$(MAKE_VERSION_PATCH))
# Automatically disable parallel builds
# depending on the version of GNU Make.
# MAKE_PARALLEL=0: disable explicitly
# MAKE_PARALLEL=1: enable explicitly
ifeq (0,$(MAKE_PARALLEL))
.NOTPARALLEL:
else ifeq (,$(strip $(MAKE_PARALLEL)))
# Force parallel build for old GNU Make
#ifneq (0,$(shell echo "$$((38200>$(MAKE_VERSION_INT)))"))
#.NOTPARALLEL:
#else
ifneq (0,$(shell echo "$$((40201<$(MAKE_VERSION_INT)))"))
MAKEFLAGS += -O
endif
else ifneq (0,$(shell echo "$$((40201<$(MAKE_VERSION_INT)))"))
MAKEFLAGS += -O
endif
#MAKEINC := $(abspath $(dir $(filter %Makefile.inc,$(MAKEFILE_LIST))))
MAKEINC := $(patsubst %/,%,$(dir $(filter %Makefile.inc,$(MAKEFILE_LIST))))
COMMAND := $(shell which command 2>/dev/null)
ifneq (,$(COMMAND))
which = $(shell $(COMMAND) -v $1)
else
which = $(shell which $(firstword $1) 2>/dev/null)
endif
# ensure a number or instead return zero (by default) or 2nd argument (if given)
qnum = $(shell echo "$1" | grep "^-*[0-9][0-9]*$$" 2>/dev/null || echo "$(if $2,$2,0)")
ifeq (,$(HOSTNAME))
HOSTNAME := $(shell hostname 2>/dev/null)
endif
ifeq (Windows_NT,$(OS))
MNAME ?= $(if $(filter AMD64,$(PROCESSOR_ARCHITECTURE)),x86_64,$(PROCESSOR_ARCHITECTURE))
UNAME ?= Windows_NT
# Cygwin/MinGW based
DLIBEXT ?= dll
SLIBEXT ?= lib
else
MNAME ?= $(shell uname -m 2>/dev/null)
UNAME ?= $(shell uname 2>/dev/null)
ifneq (Darwin,$(UNAME))
ENVBIN ?= $(call which,env)
endif
endif
# Command line utilities
#PKGCFG ?= $(call which,pkg-config)
ifneq (,$(call which,stdbuf))
FLUSH ?= stdbuf -o0 -e0
endif
MKDIR ?= $(call which,mkdir)
CP ?= $(call which,cp)
MV ?= $(call which,mv)
MAKE ?= make
SED := $(call which,gsed)
# GNU sed is desired (macOS)
ifeq (,$(SED))
SED := $(call which,sed)
endif
# Python interpreter per PYTHON=/path/to/python
PYTHON3 := $(call which,python3)
# Python3 by default
ifneq (,$(PYTHON3))
PYTHON := $(PYTHON3)
else ifneq (,$(call which,python))
ifneq (Windows_NT,$(UNAME))
PYTHON3 := $(shell ln -s $(call which,python) $(MAKEINC)/python3 2>/dev/null)
PYTHON := $(MAKEINC)/python3
else
PYTHON := python
endif
endif
ifneq (Darwin,$(UNAME))
ifneq (,$(strip $(CP)))
ifneq (FreeBSD,$(UNAME))
CP += -u
endif
endif
DLIBEXT ?= so
SLIBEXT ?= a
else
DLIBEXT ?= dylib
SLIBEXT ?= a
endif
# Regular expression to match "main" (good-enough pattern)
CMAIN := main[[:space:]]*(.*)
FMAIN := ^[[:space:]]*PROGRAM[[:space:]][[:space:]]*\w\w*\([[:space:]][[:space:]]*\!.*\)*$$
# Regular expression to mazch variable name (Make-key)
VNAME := ^ *[^0-9[:punct:]][A-Z0-9_][A-Z0-9_]*
# Debugging and symbols (e.g., when profiling)
SYM ?= 0
DBG ?= 0
# Instrumentation level (trace)
ifeq (,$(strip $(INSTRUMENT)))
INSTRUMENT := 0
endif
TRACE ?= 0
ifeq (0,$(DBG))
ifneq (0,$(INSTRUMENT))
SYM := $(INSTRUMENT)
endif
ifneq (,$(filter 0 1,$(SYM)))
DFLAGS += -DNDEBUG
endif
else # debugging enabled
ifneq (0,$(shell echo "$$((1<$(DBG)||0>$(DBG)))"))
DFLAGS += -D_DEBUG
endif
SYM := $(DBG)
endif
# Optimization level
ifeq (0,$(DBG))
OPT ?= 2
else
OPT ?= 0
endif
# Optimization flag derived from OPT flag
OPT := $(patsubst O%,%,$(OPT))
OPTFLAGS ?= -O$(OPT)
OPTFLAG1 ?= -O$(shell echo "$$((1<$(OPT)?1:$(OPT)))")
# Kind of Clang/GCC based analysis (thread, address, ...)
SANITIZE ?= $(NULL)
# VMAX=0 (default): Prefer default vector size
# VMAX=1: Prefer widest vector size (VLEN=MAX)
VMAX ?= 0
# Avoid more sophisticated flags of the GCC tool chain,
# and improve compatibility with compilers supposed to be
# compatible with the GCC tool chain
COMPATIBLE ?= 0
# Control visibility of symbols
# 0: hidden unless explicitly marked visible
# 1: default visibility
VISIBILITY ?= 0
# Number of repeated calls (tests),
# or used to scale the problem size
TESTSIZE ?= 1
# Delay for user-interaction (sleep)
WAIT ?= 12
# Prefer static or shared library/dependencies
STATIC ?= 1
# PIC: PIC or pic
PIC ?= pic
# Add object files to archive (not "?=")
#MAKE_AR ?= rm -f $(basename $@).$(SLIBEXT); $(AR) -rs
MAKE_AR ?= $(AR) -rs
PLATFORM ?= 0
ifneq (0,$(call qnum,$(PLATFORM))) # NaN
DFLAGS += -DLIBXSMM_PLATFORM_FORCE
endif
DEPDIR ?= $(ROOTDIR)
LIBNAME ?= $(DEPDIR)/lib/libxsmm
# Additional library search paths
LIBFIND ?= /usr/local/lib
# Utilities
MKTEMP := $(DEPDIR)/.mktmp.sh
FLOCK := $(DEPDIR)/.flock.sh
# Special characters
CHAR_OPEN := (
CHAR_CLOSE := )
CHAR_HASH := \#
# make -d triggers Shell's verbose output
ifeq (d,$(filter d,$(MAKEFLAGS)))
SHELL := $(SHELL) -xv
endif
ifneq (,$(UMASK))
UMASK_CURRENT := $(shell umask)
ifneq (0,$(shell echo "$$(($(UMASK)<$(UMASK_CURRENT)))"))
$(info WARNING: umask $(UMASK_CURRENT) does not match requirement ($(UMASK)))
endif
SHELL := $(shell printf "$(CHAR_HASH)!$(SHELL)\numask $(UMASK)\n$(SHELL) \"\$$$\@\"\n" \
>$(DEPDIR)/.shell.sh; chmod +x $(DEPDIR)/.shell.sh 2>/dev/null; echo "$(DEPDIR)/.shell.sh")
endif
# THREADS refers to foundational TRT (and not necessarily Posix Threads)
THREADS ?= 1
# Threading runtime
ifeq (0,$(THREADS))
override OMP := 0
endif
OMP ?= 0
# Code conformance (beyond -Wall)
PEDANTIC ?= 0
# Static code analysis (linking is not intended)
ANALYZE ?= 0
# Warning about unused functions
UNUSED ?= 0
# Embed InterProcedural Optimization information into libraries
IPO ?= 0
FAT ?= 0
# ILP64=0 (LP64 with 32-bit integers), and ILP64=0 (64-bit integers)
ILP64 ?= 0
# TBB Malloc enabled (1) or disabled (0)
# availability depends on TBBROOT
TBB_MALLOC ?= 0
# TBB runtime compatible with oldest supported GCC
TBB_OLDRTL ?= 0
# Enable absolute library paths
ABSLIBS ?= 1
# Embedd soname into shared library
SONAMELNK ?= 2
# utilities to handle paths with spaces
SPACES ?= 0
REVERSION0 := [0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*
REVERSION1 := s/..* \($(REVERSION0)\)[ \S]*.*/\1/
REVERSION2 := s/..* \([0-9]\{5\}[0-9]*\)[ \S]*.*/\1/
ifneq (0,$(SPACES))
unquote = $(shell echo "$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}" | $(SED) -e 's/^[" ][" ]*//' -e 's/[" ][" ]*$$//')
quote = $(strip $(if $(filter 0 1,$(words $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})), \
$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}, \
"$(call unquote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})"))
qapath = $(call quote,$(shell export "VAR=$(call unquote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})" && if [ "$${VAR}" ]; then \
if [ ! -d "$${VAR}" ]; then cd "$$(dirname "$${VAR}" 2>/dev/null)" 2>/dev/null && echo "$$(pwd -P)/$$(basename "$${VAR}" 2>/dev/null)"; \
else cd "$${VAR}" 2>/dev/null && pwd -P; fi; fi))
qndir = $(call quote,$(shell export "VAR=$(call unquote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})" && \
if [ ! -d "$${VAR}" ]; then basename "$${VAR}" 2>/dev/null; fi))
qdir = $(call quote,$(shell dirname "$(call unquote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})x" 2>/dev/null | $(SED) "s/\/\(\"*\)$$/\1/"))
else
quote = $(strip $(subst "",$(NULL),$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))
qapath = $(abspath $(call quote, $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))
qndir = $(notdir $(call quote, $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))
qdir = $(shell echo "$(dir $(call quote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))" | $(SED) "s/\/\(\"*\)$$/\1/")
endif
qsuffix = $(suffix $(strip $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))
qbname = $(basename $(call quote,$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}))
qxdir = $(shell if [ -d "$1" ]; then echo "$1" | $(SED) "s/\/\(\"*\)$$/\1/"; else echo "$(call qdir,$1)"; fi)
qname = $(basename $(call quote,$(shell echo "$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}" | $(SED) "s/\.$(REVERSION0)//")))
# absolute directory paths
ABSDIR := $(call qapath,$(ROOTDIR))
HOMEDIR := $(call qapath,$(HOME))
HEREDIR := $(call qapath,.)
# pick the last of wildcard's sorted results
wildcard1 = $(strip $(lastword $(sort $(wildcard $1))))
# tail of list
tailwords = $(wordlist 2, $(words \
$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12}), \
$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12})
# Pickup OpenMP library name if passed as OMP=libname|name
ifeq (NaN,$(call qnum,$(OMP),NaN))
OMPRT := $(patsubst lib%,%,$(OMP))
endif
OMPRT ?= $(NULL)
uniqadd = $(if $($2),$(filter-out $($2),$($1)) $(if $3,$3,$($2)),$(filter-out $2,$($1)) $(if $3,$3,$2))
uniqmov = $(if $(filter $($2),$($1)),$(call uniqadd,$1,$2,$3),$($1))
ctest = $(if $1,$(if $(shell INFILE=$$($(MKTEMP) /tmp/.libxsmm_XXXXXX.c) && \
echo "int main(void) { return 0; }" >$${INFILE} && if [ "$3" ]; \
then $(firstword $1) $2 -c $${INFILE} -o $${INFILE}.o >/dev/null && if [ "$(strip $3)" ]; then \
$(firstword $1) $3 $${INFILE}.o -o $${INFILE}.x >/dev/null; fi; \
else $(firstword $1) $2 $${INFILE} -o $${INFILE}.x >/dev/null; fi 2>&1 || echo "FAILED"; \
rm -f /tmp/$$(basename $${INFILE} .c).* .libxsmm_??????.c.* 2>/dev/null),$(NULL),$(strip $2 $3)))
# INFILE cannot use leading dot when used with certain F-compiler
ftest = $(if $1,$(if $(shell INFILE=$$($(MKTEMP) /tmp/_libxsmm_XXXXXX.f) && \
printf " PROGRAM test\n END PROGRAM\n" >$${INFILE} && if [ "$3" ]; \
then $(firstword $1) $2 -c $${INFILE} -o $${INFILE}.o >/dev/null && if [ "$(strip $3)" ]; then \
$(firstword $1) $3 $${INFILE}.o -o $${INFILE}.x >/dev/null; fi; \
else $(firstword $1) $2 $${INFILE} -o $${INFILE}.x >/dev/null; fi 2>&1 || echo "FAILED"; \
rm -f /tmp/$$(basename $${INFILE} .f).* _libxsmm_??????.f.* 2>/dev/null),$(NULL),$(strip $2 $3)))
ldclib = $(if $1,$(call ctest,$1 $2,-l$(strip $3)))
ldflib = $(if $1,$(call ftest,$1 $2,-l$(strip $3)))
# extract from source file (1st arg) the value of the preprocessor definition (2nd arg)
preppat = $(if $1$2,s/[[:space:]]*$(CHAR_HASH)[[:space:]]*define[[:space:]][[:space:]]*$(if $(wildcard $1),$2,$1)[[:space:]][[:space:]]*\(..*\)[[:space:]]*/\1/p)
prepget = $(shell $(CC) $(DFLAGS) $(IFLAGS) $(CFLAGS) $(CTARGET) $(if $(wildcard $1),-c $1,- </dev/null) -dM -E 2>/dev/null \
| $(SED) -n "$(call preppat,$1,$2);$(call preppat,$1,$3);$(call preppat,$1,$4)")
# Automatically pickup the environment (make -e is not required),
# or pickup the Intel Compiler (if available).
GNU ?= 0
ifeq (0,$(GNU))
ifeq (,$(shell echo "$${CXX}"))
ifneq (,$(filter icpc icpc1,$(call qndir,$(call which,icpc))$(INTEL)))
CXX := icpc
else ifneq (,$(filter icpx icpx2,$(call qndir,$(call which,icpx))$(INTEL)))
CXX := icpx
endif
endif
ifeq (,$(shell echo "$${CC}"))
ifneq (,$(filter icc icc1,$(call qndir,$(call which,icc))$(INTEL)))
CC := icc
else ifneq (,$(filter icx icx2,$(call qndir,$(call which,icx))$(INTEL)))
CC := icx
endif
endif
else ifneq (,$(filter-out default undefined,$(origin CC) $(origin CXX) $(origin FC)))
$(info WARNING: GNU=$(GNU) was given but CC, CXX, or FC was specified!)
endif
# adopt extra flags from C if not set individually
ECXXFLAGS ?= $(ECFLAGS)
COMPILER_VERSION_FLAG ?= $(ECXXFLAGS) $(EFLAGS) --version 2>/dev/null
CC_VERSION_FLAG ?= $(COMPILER_VERSION_FLAG)
FC_VERSION_FLAG ?= $(COMPILER_VERSION_FLAG)
CXX_VERSION_FLAG ?= $(CC_VERSION_FLAG)
# check if the Intel Development Tools are available
# 1: classic, 2: next-gen (opt-in)
INTEL ?= $(if $(filter 2,$(words $(filter icpc% icpx% icc% icx% Intel%, \
$(shell $(CXX) $(CXX_VERSION_FLAG) | head -n1 | cut -d' ' -f1) \
$(shell $(CC) $(CC_VERSION_FLAG) | head -n1 | cut -d' ' -f1)) )),1,0)
ifneq (0,$(INTEL))
ifeq (,$(shell echo "$${FC}"))
ifeq (ifx$(INTEL),$(call qndir,$(call which,ifx))$(filter-out 1,$(INTEL)))
FC := ifx
else ifneq (,$(call qndir,$(call which,ifort)))
FC := ifort
endif
endif
else
ifeq (,$(call which,$(CXX)))
CXX := g++
else ifneq (0,$(shell $(CXX) $(CXX_VERSION_FLAG) >/dev/null; echo "$$?"))
CXX := g++
else ifneq (gcc,$(call qndir,$(call which,$(CC))))
ifeq (g++,$(call qndir,$(call which,$(CXX))))
CC := gcc
endif
endif
ifeq (,$(call which,$(CC)))
CC := gcc
else ifneq (0,$(shell $(CC) $(CC_VERSION_FLAG) >/dev/null; echo "$$?"))
CC := gcc
endif
ifeq (Cray,$(shell $(CC) --version 2>&1 | head -n1 | cut -d' ' -f1))
COMPILER_VERSION_FLAG ?= --version 2>&1
else ifeq (Cray,$(shell $(CC) -V 2>&1 | head -n1 | cut -d' ' -f1))
COMPILER_VERSION_FLAG ?= -V 2>&1
endif
endif
ifneq (,$(filter-out __INTEL_LLVM_COMPILER,$(shell echo "__INTEL_LLVM_COMPILER" \
| $(CC) $(call ctest,$(CC),$(ECFLAGS) $(EFLAGS)) -E -P - 2>/dev/null \
| $(SED) "/^[[:space:]]*$$/d" 2>/dev/null)))
ICX := 1
endif
ifneq (,$(filter-out __INTEL_LLVM_COMPILER,$(shell echo "__INTEL_LLVM_COMPILER" \
| $(FC) $(call ftest,$(FC),$(EFCFLAGS) $(EFLAGS)) -E -P /dev/stdin 2>/dev/null \
| $(SED) "/^[[:space:]]*$$/d" 2>/dev/null; rm -f stdin.f)))
ICX := $(if $(filter 1,$(ICX)),2,1)
FIXFC ?= 0
endif
ICX ?= 0
# linker setup
LD := $(CC)
XLD := $(CXX)
LNKSOFT ?= 1
ifeq (0,$(STATIC))
ifeq (Windows_NT,$(UNAME))
LNKSOFT := 0
else ifeq (Darwin,$(UNAME))
LNKSOFT := 0
endif
endif
# BLAS is not used by default
ifneq (0,$(LNKSOFT))
BLAS ?= 0
else
BLAS ?= 2
endif
# Explicitly disable BLAS by user's intervention
# Makefile defines what happens (perhaps nothing)
NOBLAS ?= 0
DNOBLAS := -D__BLAS=0
ifneq (,$(filter environment% override command%,$(origin BLAS)))
ifeq (0,$(BLAS))
NOBLAS := 1
endif
endif
ifneq (0,$(NOBLAS))
BLAS_FLAGS += $(DNOBLAS)
endif
CXX_VERSION := $(shell $(CXX) $(CXX_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION1)p")
ifeq (,$(CXX_VERSION))
CXX_VERSION := $(shell $(CXX) $(CXX_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION2)p")
endif
CXX_VERSION_MAJOR := $(shell echo "$(CXX_VERSION)" | cut -d. -f1)
CXX_VERSION_MINOR := $(shell echo "$(CXX_VERSION)" | cut -d. -f2)
CXX_VERSION_PATCH := $(shell echo "$(CXX_VERSION)" | cut -d. -f3)
ifeq (3,$(words $(CXX_VERSION_MAJOR) $(CXX_VERSION_MINOR) $(CXX_VERSION_PATCH)))
CXX_VERSION_NUM := $(call version,$(CXX_VERSION_MAJOR),$(CXX_VERSION_MINOR),$(CXX_VERSION_PATCH))
else ifeq (2,$(words $(CXX_VERSION_MAJOR) $(CXX_VERSION_MINOR)))
CXX_VERSION_NUM := $(call version,$(CXX_VERSION_MAJOR),$(CXX_VERSION_MINOR))
CXX_VERSION_PATCH := 0
else
CXX_VERSION := $(NULL)
CXX_VERSION_NUM := 0
endif
CC_VERSION := $(shell $(CC) $(CC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION1)p")
ifeq (,$(CC_VERSION))
CC_VERSION := $(shell $(CC) $(CC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION2)p")
endif
CC_VERSION_MAJOR := $(shell echo "$(CC_VERSION)" | cut -d. -f1)
CC_VERSION_MINOR := $(shell echo "$(CC_VERSION)" | cut -d. -f2)
CC_VERSION_PATCH := $(shell echo "$(CC_VERSION)" | cut -d. -f3)
ifeq (3,$(words $(CC_VERSION_MAJOR) $(CC_VERSION_MINOR) $(CC_VERSION_PATCH)))
CC_VERSION_NUM := $(call version,$(CC_VERSION_MAJOR),$(CC_VERSION_MINOR),$(CC_VERSION_PATCH))
else ifeq (2,$(words $(CC_VERSION_MAJOR) $(CC_VERSION_MINOR)))
CC_VERSION_NUM := $(call version,$(CC_VERSION_MAJOR),$(CC_VERSION_MINOR))
CC_VERSION_PATCH := 0
else
CC_VERSION := $(NULL)
CC_VERSION_NUM := 0
endif
# disable Fortran per user-request
ifeq (0,$(FORTRAN))
override FC := $(NULL)
endif
# fixup FC-default given by MAKE
ifneq (,$(strip $(FC)))
ifeq (,$(call which,$(FC)))
FIXFC ?= 1
else ifneq (0,$(shell $(FC) $(FC_VERSION_FLAG) >/dev/null; echo "$$?"))
FIXFC ?= 1
else ifneq (gfortran,$(call qndir,$(call which,$(FC))))
ifeq (g++,$(call qndir,$(call which,$(CXX))))
FIXFC ?= 1
endif
endif
endif
FIXFC ?= 0
ifneq (0,$(FIXFC))
ifneq (,$(call qndir,$(call which,gfortran)))
MKL_FCRTL := gf
GFC := gfortran
FC := $(GFC)
else
FC := $(NULL)
endif
endif
ifneq (,$(strip $(FC)))
FC_VERSION := $(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION1)p")
ifeq (,$(FC_VERSION))
FC_VERSION := $(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION2)p")
endif
FC_VERSION_MAJOR := $(shell echo "$(FC_VERSION)" | cut -d. -f1)
FC_VERSION_MINOR := $(shell echo "$(FC_VERSION)" | cut -d. -f2)
FC_VERSION_PATCH := $(shell echo "$(FC_VERSION)" | cut -d. -f3)
ifeq (3,$(words $(FC_VERSION_MAJOR) $(FC_VERSION_MINOR) $(FC_VERSION_PATCH)))
FC_VERSION_NUM := $(call version,$(FC_VERSION_MAJOR),$(FC_VERSION_MINOR),$(FC_VERSION_PATCH))
else ifeq (2,$(words $(FC_VERSION_MAJOR) $(FC_VERSION_MINOR)))
FC_VERSION_NUM := $(call version,$(FC_VERSION_MAJOR),$(FC_VERSION_MINOR))
FC_VERSION_PATCH := 0
else
FC_VERSION := $(NULL)
FC_VERSION_NUM := 0
endif
ifeq (GNU,$(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | cut -d" " -f1))
ifneq (0,$(shell echo "$$((40500>$(FC_VERSION_NUM)))"))
ifneq (gfortran,$(call qndir,$(FC)))
FC := gfortran
FC_VERSION := $(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION1)p")
ifeq (,$(FC_VERSION))
FC_VERSION := $(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION2)p")
endif
FC_VERSION_MAJOR := $(shell echo "$(FC_VERSION)" | cut -d. -f1)
FC_VERSION_MINOR := $(shell echo "$(FC_VERSION)" | cut -d. -f2)
FC_VERSION_PATCH := $(shell echo "$(FC_VERSION)" | cut -d. -f3)
ifeq (3,$(words $(FC_VERSION_MAJOR) $(FC_VERSION_MINOR) $(FC_VERSION_PATCH)))
FC_VERSION_NUM := $(call version,$(FC_VERSION_MAJOR),$(FC_VERSION_MINOR),$(FC_VERSION_PATCH))
else ifeq (2,$(words $(FC_VERSION_MAJOR) $(FC_VERSION_MINOR)))
FC_VERSION_NUM := $(call version,$(FC_VERSION_MAJOR),$(FC_VERSION_MINOR))
FC_VERSION_PATCH := 0
else
FC_VERSION_NUM := 0
endif
ifneq (0,$(shell echo "$$((40500>$(FC_VERSION_NUM)))"))
override FC := $(NULL)
endif
else
override FC := $(NULL)
endif
else ifneq (0,$(shell echo "$$((40600>$(FC_VERSION_NUM)))"))
FORTRAN ?= 1
endif
else ifneq (0,$(INTEL))
ifneq (0,$(shell echo "$$((130000>$(FC_VERSION_NUM)&&0<$(FC_VERSION_NUM)))"))
override FC := $(NULL)
endif
endif
endif
FORTRAN ?= 2
ifeq (,$(strip $(FC)))
ifeq (0,$(FORTRAN))
FC_VERSION_NUM := 0
FC_VERSION := $(NULL)
else # keep FC_VERSION for message about outdated compiler
FORTRAN := 0
endif
endif
# compiler names
ifeq (0,$(PLATFORM))
CXX_NAME := $(call qbname,$(shell $(CXX) $(CXX_VERSION_FLAG) | head -n1 \
| $(SED) -e "s/^\([^0-9][^0-9]*\) ..*/\1/" -e "s/[[:space:]][[:space:]]*[Vv]ersion//" \
-e "s/[[:space:]][[:space:]]*$(CHAR_OPEN)..*//" -e "s/[[:space:]][[:space:]]*[[:punct:]]//" \
-e "s/[[:space:]][[:space:]]*$(REVERSION0)//" \
| rev | cut -d" " -f1 | rev))
endif
ifeq (,$(strip $(CXX_NAME)))
CXX_NAME := $(call qname,$(call qndir,$(CXX)))
endif
ifeq (0,$(PLATFORM))
CC_NAME := $(call qbname,$(shell $(CC) $(CC_VERSION_FLAG) | head -n1 \
| $(SED) -e "s/^\([^0-9][^0-9]*\) ..*/\1/" -e "s/[[:space:]][[:space:]]*[Vv]ersion//" \
-e "s/[[:space:]][[:space:]]*$(CHAR_OPEN)..*//" -e "s/[[:space:]][[:space:]]*[[:punct:]]//" \
-e "s/[[:space:]][[:space:]]*$(REVERSION0)//" \
| rev | cut -d" " -f1 | rev))
endif
ifeq (,$(strip $(CC_NAME)))
CC_NAME := $(call qname,$(call qndir,$(CC)))
endif
ifneq (,$(strip $(FC)))
FC_NAME := $(firstword $(call qndir,$(FC)))
endif
ifeq (,$(strip $(FC_NAME)))
FC_NAME := $(call qname,$(call qndir,$(FC)))
endif
ifneq (0,$(FORTRAN))
ifeq (,$(strip $(GFC)))
ifneq (,$(strip $(FC)))
ifeq (GCC,$(shell $(FC) $(FC_VERSION_FLAG) | head -n1 | $(SED) "s/.* (\(..*\)) .*/\1/"))
GFC := $(FC)
else ifeq (0,$(shell $(FC) $(FC_VERSION_FLAG) | grep -q "Free Software Foundation"; echo "$$?"))
GFC := $(FC)
else ifneq (pgfortran,$(FC_NAME))
ifneq (,$(findstring gfortran,$(FC_NAME)))
GFC := $(FC)
endif
endif
ifeq ($(strip $(FC)),$(strip $(GFC)))
FC_NAME := gfortran
endif
else
FORTRAN ?= 0
endif
endif
else
FC := $(NULL)
endif
ifeq (,$(strip $(FC)))
DFLAGS += -DLIBXSMM_NOFORTRAN
endif
# native GCC?
XSMM_GCC ?= 0
ifeq (0,$(shell $(CC) $(CC_VERSION_FLAG) | grep -q "Free Software Foundation"; echo "$$?"))
XSMM_GCC := 1
else ifeq (GCC,$(shell $(CC) $(CC_VERSION_FLAG) | head -n1 | $(SED) "s/.* (\(..*\)) .*/\1/"))
XSMM_GCC := 1
else ifneq (pgcc,$(CC_NAME))
ifneq (,$(findstring pgcc,$(CC_NAME)))
XSMM_GCC := 1
endif
endif
ifeq (1,$(XSMM_GCC))
ifeq (0,$(shell $(CXX) $(CXX_VERSION_FLAG) | grep -q "Free Software Foundation"; echo "$$?"))
XSMM_GCC := 2
else ifeq (GCC,$(shell $(CXX) $(CXX_VERSION_FLAG) | head -n1 | $(SED) "s/.* (\(..*\)) .*/\1/"))
XSMM_GCC := 2
else ifneq (,$(findstring g++,$(CXX_NAME)))
XSMM_GCC := 2
endif
ifeq (2,$(XSMM_GCC))
ifneq (,$(strip $(GFC)))
MKL_FCRTL := gf
XSMM_GCC := 3
endif
endif
endif
# Fortran runtime library
MKL_FCRTL ?= intel
# adopt fully equipped archiver
CCAR := $(call which,$(CC)-ar)
ifneq (,$(findstring -ar?,$(CCAR)?))
ifeq (default,$(origin AR))
AR := $(CCAR)
else
AR ?= $(CCAR)
endif
endif
ifneq (0,$(ANALYZE))
ifeq (1,$(ANALYZE))
ANALYZE_FLAG := $(call ctest,$(CC),--analyze)
ifeq (,$(ANALYZE_FLAG))
ECFLAGS += $(call ctest,$(CC),-fanalyzer)
else
EFLAGS += $(ANALYZE_FLAG)
FORCE_CXX := 1
endif
else
FORCE_CXX := 1
PEDANTIC := 3
endif
endif
ifneq (,$(filter-out 0,$(FORCE_CXX)))
override EFLAGS := $(EFLAGS) $(call ctest,$(CXX),-xc++)
override CC := $(CXX)
endif
WCHECK ?= 0
WERROR_CFLAG := $(call ctest,$(CC),-Werror)
WERROR_FCFLAG := $(call ftest,$(FC),-Werror)
ifneq (0,$(WCHECK))
WCHECK_CFLAG := $(call ctest,$(CC),-Wcheck)
ifneq (,$(WCHECK_CFLAG))
WCHECK_CFLAG := $(WCHECK_CFLAG) $(WERROR_CFLAG)
ifneq (0,$(INTEL))
ifeq (1,$(WCHECK))
WCHECK_CFLAG := -diag-disable 2259 $(WCHECK_CFLAG)
endif
endif
else
WCHECK_CFLAG := $(WERROR_CFLAG)
endif
endif
ifeq (0,$(ICX))
ifneq (0,$(INTEL))
NOLIMITS_CFLAG := $(call ctest,$(CC),-qoverride-limits $(WERROR_CFLAG))
ifeq (,$(strip $(GFC)))
ifneq (,$(strip $(FC)))
NOLIMITS_FCFLAG := $(call ftest,$(FC),-qoverride-limits $(WERROR_FCFLAG))
endif
endif
endif
endif
ifeq (Windows_NT,$(UNAME))
ifeq (MINGW64,$(MSYSTEM))
MINGW := 64
else ifeq (MINGW32,$(MSYSTEM))
MINGW := 32
else ifneq (,$(call prepget,__MINGW64__))
MINGW := 64
else ifneq (,$(call prepget,__MINGW32__))
MINGW := 32
endif
endif
MINGW ?= 0
# Library extension
ifneq (0,$(STATIC))
LIBEXT ?= $(SLIBEXT)
#ABSLIBS := 0
else
LIBEXT ?= $(DLIBEXT)
endif
# Import-library
ifeq (0,$(MINGW))
ILIBEXT ?= $(DLIBEXT)
else # MinGW
ILIBEXT ?= a
endif
# Separate control on how to link against the BLAS library
BLAS_STATIC ?= $(STATIC)
# PGI: ignore env. variable (same name)
override PGI := 0
ifeq (0,$(XSMM_GCC)) # not GCC
ifeq (0,$(INTEL)) # not Intel
ifneq (,$(call prepget,__clang__))
CLANG := 1
else
override PGI := $(shell $(CC) $(CC_VERSION_FLAG) | if grep -q "PGI"; then echo "1"; else echo "0"; fi)
endif
endif
endif
CLANG ?= 0
# Make GCC version number available even when not using GCC
ifneq (0,$(XSMM_GCC))
GCC_VERSION := $(CXX_VERSION)
GCC_VERSION_MAJOR := $(CXX_VERSION_MAJOR)
GCC_VERSION_MINOR := $(CXX_VERSION_MINOR)
GCC_VERSION_PATCH := $(CXX_VERSION_PATCH)
else ifeq (0,$(CLANG))
GCCBIN := $(call qndir,$(call which,gcc))
ifneq (,$(strip $(GCCBIN)))
GCC_VERSION := $(shell $(GCCBIN) $(CXX_VERSION_FLAG) | head -n1 | $(SED) -n "$(REVERSION1)p")
GCC_VERSION_MAJOR := $(shell echo "$(GCC_VERSION)" | cut -d. -f1)
GCC_VERSION_MINOR := $(shell echo "$(GCC_VERSION)" | cut -d. -f2)
GCC_VERSION_PATCH := $(shell echo "$(GCC_VERSION)" | cut -d. -f3)
endif
endif
ifeq (3,$(words $(GCC_VERSION_MAJOR) $(GCC_VERSION_MINOR) $(GCC_VERSION_PATCH)))
GCC_VERSION_NUM := $(call version,$(GCC_VERSION_MAJOR),$(GCC_VERSION_MINOR),$(GCC_VERSION_PATCH))
else ifeq (2,$(words $(GCC_VERSION_MAJOR) $(GCC_VERSION_MINOR)))
GCC_VERSION_NUM := $(call version,$(GCC_VERSION_MAJOR),$(GCC_VERSION_MINOR))
GCC_VERSION_PATCH := 0
else
GCC_VERSION := $(NULL)
GCC_VERSION_NUM := 0
endif
# Manually enable maintainer build (aka x86_64v1).
# Previously, it was automatically detected.
# Old logic:
# ifeq (,$(filter Windows_NT Darwin,$(UNAME)))
# ifeq (,$(SPACK_ENV_PATH)) # not under Spack
# ifeq (3,$(XSMM_GCC)) # pure GNU toolchain
# ifneq (0,$(shell echo "$$((100000<=$(GCC_VERSION_NUM)))"))
#
MAINTAINER ?= 0
# Select x86 code path (if not selected otherwise)
CPUFLAGS_X86 := $(strip $(shell if [ -e /proc/cpuinfo ]; then \
grep -m1 flags /proc/cpuinfo | cut -d: -f2-; \
elif [ "Darwin" = "$(UNAME)" ] && [ "x86_64" = "$(MNAME)" ]; then \
sysctl -a \
machdep.cpu.leaf7_features \
machdep.cpu.extfeatures \
machdep.cpu.features \
| cut -d: -f2- | tr -s "\n" " " \
| tr "[:upper:]." "[:lower:]_"; \
fi))
SSE ?= 1
ifeq (0,$(SSE)) # discover AVX
ifeq (1,$(words $(filter avx512f,$(CPUFLAGS_X86))))
ifeq (2,$(words $(filter avx512pf avx512er,$(CPUFLAGS_X86)))) # KNL
AVX ?= 3
MIC ?= 1
else
AVX ?= 2
endif
else ifeq (1,$(words $(filter avx avx1.0,$(CPUFLAGS_X86))))
ifeq (1,$(words $(filter fma,$(CPUFLAGS_X86))))
AVX ?= 2
else
AVX ?= 1
endif
endif
else ifeq (1,$(SSE)) # discover SSE
ifeq (1,$(words $(filter sse4_2 sse4.2,$(CPUFLAGS_X86))))
SSE := 4
else ifneq (0,$(words $(filter sse3 ssse3,$(CPUFLAGS_X86))))
SSE := 3
else ifneq (0,$(words $(filter sse2 ,$(CPUFLAGS_X86))))
SSE := 2
else ifneq (,$(CPUFLAGS_X86))
SSE := 0
endif
endif
AVX ?= 0
MIC ?= 0
# Select aarch64 code path
CPUFLAGS_AARCH64 := $(strip $(shell if [ -e /proc/cpuinfo ]; then \
grep -m1 Features /proc/cpuinfo | cut -d: -f2-; \
elif [ "Darwin" = "$(UNAME)" ] && [ "arm64" = "$(MNAME)" ]; then \
sysctl -a hw.optional.neon | cut -d: -f2-; \
fi))
ASIMD ?= 1
ifeq (1,$(ASIMD)) # discover ASIMD
ifeq (1,$(words $(filter asimd,$(CPUFLAGS_AARCH64))))
ASIMD := 1
else ifneq (0,$(words $(filter 1,$(CPUFLAGS_AARCH64))))
ASIMD := 1
else ifneq (,$(CPUFLAGS_X86))
ASIMD := 0
endif
endif
ifneq (0,$(INTEL))
SUITE := Intel Compiler
MKL_OMPRTL := intel
else ifneq (0,$(XSMM_GCC))
SUITE := GNU Compiler Collection
MKL_OMPRTL := gnu
else ifneq (0,$(PGI))
SUITE := $(if $(filter-out 0,$(PGI)),PGI $(NULL))Compiler
MKL_OMPRTL := pgi
else
ifeq (0,$(CLANG))
COMPATIBLE := 1
endif
ifeq (Cray,$(shell $(CC) $(COMPILER_VERSION_FLAG) | head -n1 | cut -d' ' -f1))
ifneq (0,$(COMPATIBLE))
SUITE := Cray Compiler
LDFLAGS += -hsystem_alloc
# prevent codegen issues
ifeq (0,$(OPT))
override OPT := 1
endif
endif
CRAY ?= 1
endif
endif
SUITE ?= Compiler
MKL_OMPRTL ?= gnu
CRAY ?= 0
PGI ?= 0
ifeq (,$(strip $(GFC)))
ifneq (,$(filter-out 0,$(INTEL) $(ICX)))
ifneq (,$(call ftest,$(LD),$(NULL),-nofor-main))
override LD := $(LD) -nofor-main
endif
endif
endif
ifneq (Windows_NT,$(UNAME))
ifneq (,$(strip $(PIC)))
ifneq (,$(call ctest,$(CC),-f$(PIC)))
PIC := PIC
endif
PICFLAG := -f$(PIC)
endif
endif
# prepend compiler-local library directory
LIBFIND := $(call qapath,$(call qdir,$(call which,$(LD)))/../lib) $(wildcard $(LIBFIND))
ifneq (,$(COMMON))
ifneq (0,$(COMMON))
CFLAGS += $(call ctest,$(CC),-fcommon)
else
CFLAGS += $(call ctest,$(CC),-fno-common)
endif
endif
ifneq (0,$(STATIC))
ifeq (0,$(COMPATIBLE))
ifneq (Darwin,$(UNAME))
ifneq (Windows_NT,$(UNAME))
ifneq (0,$(HARDEN))
ifneq (,$(strip $(HARDEN))) # explicit
DYNAMIC := 1
else ifneq (0,$(SYM))
DYNAMIC := 1
endif
else ifneq (0,$(SYM))
DYNAMIC := 1
endif
endif
endif
endif
else
DYNAMIC := 1
endif
DYNAMIC ?= 0
# enable MKL (if available)
ifeq (,$(strip $(MKLROOT)))
BLAS_INCFILE := $(wildcard /opt/intel/oneapi/mkl/latest/include/mkl.h)
ifeq (,$(BLAS_INCFILE))
BLAS_INCFILE := $(call wildcard1,/opt/intel/compilers_and_libraries_*/$(MKL_PLATFORM)/mkl/include/mkl.h)
endif
ifneq (,$(BLAS_INCFILE))
MKLROOT := $(call qapath,$(call qdir,$(BLAS_INCFILE))/..)
endif
endif
ifeq (,$(strip $(MKLROOT)))
BLAS_INCFILE := $(strip $(wildcard /usr/include/mkl/mkl.h))
ifneq (,$(BLAS_INCFILE))
MKLROOT := $(call qapath,$(call qdir,$(BLAS_INCFILE))/../..)
endif
endif
# Compiler is used for link stage
ifneq (Darwin,$(UNAME))
ifneq (ld,$(call qndir,$(LD)))
XLNKOPT := -Wl,
endif
XLNKVERBOSE := --verbose
linkopt = $(if $1,$(XLNKOPT)$(if $2,$1=$(call quote,$2),$1))
abslibrpath = $(strip $(if $(findstring .$(ILIBEXT),$1)$(if $1,$(wildcard $1/)), \
$(call linkopt,--rpath,$(call qxdir,$(call qapath,$1)))))
XGROUP_BEGIN := $(call linkopt,--start-group)
XGROUP_END := $(call linkopt,--end-group)
WHOLE_BEGIN := $(call linkopt,--whole-archive)
WHOLE_END := $(call linkopt,--no-whole-archive)
XLIB_BEGIN_FORCE := $(call linkopt,--as-needed)
XLIB_END_FORCE := $(call linkopt,--no-as-needed)
else # OSX
ifneq (ld,$(call qndir,$(LD)))
XLNKOPT := -Xlinker
endif
XLNKVERBOSE := -t
linkopt = $(if $1,$(XLNKOPT) $(if $2,$1 $(XLNKOPT) $(call quote,$2),$1))
abslibrpath = $(strip $(if $(findstring .$(ILIBEXT),$1)$(if $1,$(wildcard $1/)), \
$(call linkopt,-rpath,$(call qxdir,$(call qapath,$1)))))
endif
ifneq (0,$(ASNEEDED))
XLIB_BEGIN ?= $(XLIB_BEGIN_FORCE)
XLIB_END ?= $(XLIB_END_FORCE)
endif
absliblpath = $(strip $(if $1,$(if $(findstring .$(ILIBEXT),$1)$(if $1,$(wildcard $1/)), \
-L$(call qxdir,$(call qapath,$1)))))
ifneq (0,$(ABSLIBS))
abslibpath = $(strip $(call abslibrpath,$1) $(call absliblpath,$1))
else
abslibpath_force = $(strip $(call abslibrpath,$1))
endif
abslibpath ?= $(call absliblpath,$1)
abslibpath_force ?= $(NULL)
libpath = $(call qapath,$(if $1,$(shell $(FLUSH) $1 $2 -l$(strip $3) $(call linkopt,$(XLNKVERBOSE)) 2>&1 \
| grep "lib$3" | tr " " "\n" | $(SED) -n "/\//p" | $(SED) "s/[$(CHAR_OPEN)]\(..*\)[$(CHAR_CLOSE)]/\1/" \
| xargs -I {} sh -c "ls -pd {} 2>/dev/null || ls -pd {}.* 2>/dev/null" | grep -v /$$ | tail -n1)))
ifneq (Windows_NT1,$(UNAME)$(STATIC))
abslibfile = $(strip $(if $(findstring .$(ILIBEXT),$1), \
$(if $(patsubst lib%,%,$(call qname,$(call qndir,$1))), \
$(if $(findstring .$(ILIBEXT).,$1),-l:$(call qndir,$1), \
-l$(patsubst lib%,%,$(call qname,$(call qndir,$1))))), \
$(if $(filter $(call qndir,$1),$(call qapath,$1)),$(call qapath,$1),$1)))