@@ -33,7 +33,7 @@ module fpm_backend
33
33
use fpm_targets, only: build_target_t, build_target_ptr, &
34
34
FPM_TARGET_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
35
35
36
- use fpm_strings, only: string_cat
36
+ use fpm_strings, only: string_t
37
37
38
38
implicit none
39
39
@@ -247,7 +247,8 @@ subroutine build_target(model,target)
247
247
// " " // target % link_flags// " -o " // target % output_file)
248
248
249
249
case (FPM_TARGET_ARCHIVE)
250
- call run(" ar -rs " // target % output_file // " " // string_cat(target % link_objects," " ))
250
+ call write_response_file(target % output_file// " .resp" ,target % link_objects)
251
+ call run(" ar -rs " // target % output_file // " @" // target % output_file// " .resp" )
251
252
252
253
end select
253
254
@@ -259,4 +260,19 @@ subroutine build_target(model,target)
259
260
260
261
end subroutine build_target
261
262
263
+ ! > Response files allow to read command line options from files.
264
+ ! > Whitespace is used to separate the arguments, we will use newlines
265
+ ! > as separator to create readable response files which can be inspected
266
+ ! > in case of errors.
267
+ subroutine write_response_file (name , argv )
268
+ character (len=* ), intent (in ) :: name
269
+ type (string_t), intent (in ) :: argv(:)
270
+ integer :: iarg, io
271
+ open (file= name, newunit= io)
272
+ do iarg = 1 , size (argv)
273
+ write (io, ' (a)' ) argv(iarg)% s
274
+ end do
275
+ close (io)
276
+ end subroutine write_response_file
277
+
262
278
end module fpm_backend
0 commit comments