aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-07-22 09:20:41 -0600
committerOndřej Čertík <ondrej@certik.us>2020-07-22 09:20:41 -0600
commit46c839b3b05259252287a661b8e7d2a354976a23 (patch)
tree198b0331c8390b7fb408e997473e9dbcb12d40d8
parent93a9735cb8874d248cd3bfab760f5df05cfc97d5 (diff)
downloadfpm-46c839b3b05259252287a661b8e7d2a354976a23.tar.gz
fpm-46c839b3b05259252287a661b8e7d2a354976a23.zip
Use $HOME to determine the OS type
-rw-r--r--fpm/src/fpm.F9026
1 files changed, 17 insertions, 9 deletions
diff --git a/fpm/src/fpm.F90 b/fpm/src/fpm.F90
index 617d5d9..a68a0b9 100644
--- a/fpm/src/fpm.F90
+++ b/fpm/src/fpm.F90
@@ -10,16 +10,24 @@ integer, parameter :: os_windows = 3
contains
integer function get_os() result(r)
-#ifdef _WIN32
- r = os_windows
- return
-#endif
-#ifdef __APPLE__
- r = os_macos
- return
-#endif
- ! Assuming Linux here, as gfortran does not specify any macro for Linux
+character(len=100) :: val
+integer stat
+call get_environment_variable("HOME", val, status=stat)
+if (stat == 1) then
+ print *, "$HOME does not exist"
+ error stop
+end if
+if (stat /= 0) then
+ print *, "get_environment_variable() failed"
+ error stop
+end if
+if (val(1:5) == "/home") then
r = os_linux
+else if (val(1:6) == "/Users") then
+ r = os_macos
+else
+ r = os_windows
+end if
end function
subroutine print_help()