aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-07-21 15:56:30 -0600
committerOndřej Čertík <ondrej@certik.us>2020-07-21 16:01:01 -0600
commitfc8685d24e1b66bc16fc58833e1d4684b6df2a58 (patch)
treec04ddf80a3e95eab03013191239cdd80fbd2eefc
parent661d30f4cc8b8bf4b702c3a8d71b6add86915e16 (diff)
downloadfpm-fc8685d24e1b66bc16fc58833e1d4684b6df2a58.tar.gz
fpm-fc8685d24e1b66bc16fc58833e1d4684b6df2a58.zip
Compile src/fpm.f90 only if it exists
This now compiles hello_world
-rw-r--r--fpm/src/fpm.f9017
1 files changed, 15 insertions, 2 deletions
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90
index e1e52e9..85597c0 100644
--- a/fpm/src/fpm.f90
+++ b/fpm/src/fpm.f90
@@ -20,11 +20,24 @@ if (stat /= 0) then
end if
end subroutine
+logical function exists(filename) result(r)
+character(len=*), intent(in) :: filename
+inquire(file=filename, exist=r)
+end function
+
subroutine cmd_build()
+logical :: src
print *, "# Building project"
-call run("gfortran -c src/fpm.f90 -o fpm.o")
+src = exists("src/fpm.f90")
+if (src) then
+ call run("gfortran -c src/fpm.f90 -o fpm.o")
+end if
call run("gfortran -c app/main.f90 -o main.o")
-call run("gfortran main.o fpm.o -o fpm")
+if (src) then
+ call run("gfortran main.o fpm.o -o fpm")
+else
+ call run("gfortran main.o -o hello_world")
+end if
end subroutine
end module fpm