diff options
-rw-r--r-- | fpm/src/fpm.f90 | 17 |
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 |