forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csl.mk
82 lines (73 loc) · 2.93 KB
/
csl.mk
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
ifeq ($(USE_BINARYBUILDER_CSL),0)
# Interrogate the fortran compiler (which is always GCC based) on where it is keeping its libraries
STD_LIB_PATH := $(shell LANG=C $(FC) -print-search-dirs | grep '^programs: =' | sed -e "s/^programs: =https://")
STD_LIB_PATH += :$(shell LANG=C $(FC) -print-search-dirs | grep '^libraries: =' | sed -e "s/^libraries: =https://")
ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # the cygwin-mingw32 compiler lies about it search directory paths
STD_LIB_PATH := $(shell echo '$(STD_LIB_PATH)' | sed -e "s!/lib/!/bin/!g")
endif
# Given a colon-separated list of paths in $(2), find the location of the library given in $(1)
define pathsearch
$(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(2)))))
endef
define copy_csl
install-csl: | $$(build_shlibdir) $$(build_shlibdir)/$(1)
$$(build_shlibdir)/$(1): | $$(build_shlibdir)
-@SRC_LIB=$$(call pathsearch,$(1),$$(STD_LIB_PATH)); \
[ -n "$$$${SRC_LIB}" ] && cp $$$${SRC_LIB} $$(build_shlibdir)
endef
ifeq ($(OS),WINNT)
define gen_libname
$$(if $(2),lib$(1)-$(2).$(SHLIB_EXT),lib$(1).$(SHLIB_EXT))
endef
else ifeq ($(OS),Darwin)
define gen_libname
$$(if $(2),lib$(1).$(2).$(SHLIB_EXT),lib$(1).$(SHLIB_EXT))
endef
else
define gen_libname
$$(if $(2),lib$(1).$(SHLIB_EXT).$(2),lib$(1).$(SHLIB_EXT))
endef
endif
# libgfortran has multiple names; we're just going to copy any version we can find
# Since we're only looking in the location given by `$(FC)` this should only succeed for one.
$(eval $(call copy_csl,$(call gen_libname,gfortran,3)))
$(eval $(call copy_csl,$(call gen_libname,gfortran,4)))
$(eval $(call copy_csl,$(call gen_libname,gfortran,5)))
# These are all libraries that we should always have
$(eval $(call copy_csl,$(call gen_libname,quadmath,0)))
$(eval $(call copy_csl,$(call gen_libname,stdc++,6)))
$(eval $(call copy_csl,$(call gen_libname,ssp,0)))
$(eval $(call copy_csl,$(call gen_libname,atomic,1)))
$(eval $(call copy_csl,$(call gen_libname,gomp,1)))
ifeq ($(OS),WINNT)
# Windwos has special gcc_s names
ifeq ($(ARCH),i686)
$(eval $(call copy_csl,$(call gen_libname,gcc_s_sjlj,1)))
else
$(eval $(call copy_csl,$(call gen_libname,gcc_s_seh,1)))
endif
else
$(eval $(call copy_csl,$(call gen_libname,gcc_s,1)))
endif
# winpthread is only Windows, pthread is only others
ifeq ($(OS),WINNT)
$(eval $(call copy_csl,$(call gen_libname,winpthread,1)))
else
$(eval $(call copy_csl,$(call gen_libname,pthread,0)))
endif
get-csl:
clean-csl:
-rm -f $(build_shlibdir)/libgfortran*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libquadmath*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libstdc++*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libc++*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libgcc_s*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libssp*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libpthread*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libwinpthread*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libatomic*$(SHLIB_EXT)*
-rm -f $(build_shlibdir)/libgomp*$(SHLIB_EXT)*
distclean-csl: clean-csl
else
$(eval $(call bb-install,csl,CSL,true))
endif