1
1
! > This module contains procedures that interact with the programming environment.
2
- ! !
2
+ ! !
3
3
! ! * [get_os_type] -- Determine the OS type
4
4
! ! * [get_env] -- return the value of an environment variable
5
5
module fpm_environment
@@ -9,6 +9,7 @@ module fpm_environment
9
9
public :: os_is_unix
10
10
public :: run
11
11
public :: get_env
12
+ public :: get_archiver
12
13
13
14
integer , parameter , public :: OS_UNKNOWN = 0
14
15
integer , parameter , public :: OS_LINUX = 1
@@ -110,7 +111,7 @@ integer function get_os_type() result(r)
110
111
end if
111
112
end function get_os_type
112
113
113
- ! > Compare the output of [[get_os_type]] or the optional
114
+ ! > Compare the output of [[get_os_type]] or the optional
114
115
! ! passed INTEGER value to the value for OS_WINDOWS
115
116
! ! and return .TRUE. if they match and .FALSE. otherwise
116
117
logical function os_is_unix (os ) result(unix)
@@ -150,7 +151,7 @@ end subroutine run
150
151
function get_env (NAME ,DEFAULT ) result(VALUE)
151
152
implicit none
152
153
! > name of environment variable to get the value of
153
- character (len=* ),intent (in ) :: NAME
154
+ character (len=* ),intent (in ) :: NAME
154
155
! > default value to return if the requested value is undefined or blank
155
156
character (len=* ),intent (in ),optional :: DEFAULT
156
157
! > the returned value
@@ -182,4 +183,24 @@ function get_env(NAME,DEFAULT) result(VALUE)
182
183
if (VALUE.eq. ' ' .and. present (DEFAULT))VALUE= DEFAULT
183
184
end function get_env
184
185
186
+ function get_archiver () result(archiver)
187
+ character (:), allocatable :: archiver
188
+
189
+ associate(os_type = > get_os_type())
190
+ if (os_type /= OS_WINDOWS .and. os_type /= OS_UNKNOWN) then
191
+ archiver = " ar -rs "
192
+ else
193
+ block
194
+ integer :: estat
195
+
196
+ call execute_command_line(" ar --version" , exitstat= estat)
197
+ if (estat /= 0 ) then
198
+ archiver = " lib /OUT:"
199
+ else
200
+ archiver = " ar -rs "
201
+ end if
202
+ end block
203
+ end if
204
+ end associate
205
+ end function
185
206
end module fpm_environment
0 commit comments