forked from r-lib/ps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·170 lines (133 loc) · 4.73 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#! /usr/bin/env sh
# Check that this is not just ./configure. We need to run this
# from R CMD INSTALL, to have the R env vars set.
if [ -z "$R_HOME" ]; then
echo >&2 R_HOME is not set, are you running R CMD INSTALL?
exit 1
fi
# Find the R binary we need to use. This is a bit trickier on
# Windows, because it has two architectures. On windows R_ARCH_BIN
# is set, so this should work everywhere.
RBIN="${R_HOME}/bin${R_ARCH_BIN}/R"
# ------------------------------------------------------------------------
# Detect system
# ------------------------------------------------------------------------
unset POSIX
if [ "$R_OSTYPE" = "unix" ]; then
UNAME=`uname`
else
UNAME=Windows
fi
unset WINDOWS
if [ "$R_OSTYPE" = "windows" ]; then WINDOWS=true; fi
unset LINUX
if [ "$UNAME" = "Linux" ]; then LINUX=true; POSIX=true; fi
unset MACOS
if [ "$UNAME" = "Darwin" ]; then MACOS=true; POSIX=true; fi
unset FREEBSD
## if [ "UNAME" = "FreeBSD" ]; then FREEBSD=true; POSIX=true; fi
unset OPENBSD
## if [ "UNAME" = "OpenBSD" ]; then OPENBSD=true; POSIX=true; fi
unset NETBSD
## if [ "UNAME" = "NetBSD" ]; then NETBSD=true; POSIX=true; fi
unset BSD
if [ -n "$FREEBSD" ] || [ -n "$OPENBSD" ] || [ -n "$NETBSD" ]; then
BSD=true
fi
unset SUNOS
## if [ "UNAME" = "SunOS" ]; then SUNOS=true; POSIX=true; fi
unset AIX
## if [ "UNAME" = "AIX" ]; then AIX=true; POSIX=true; fi
# ------------------------------------------------------------------------
# Set source files, macros, libs, compile flags
# ------------------------------------------------------------------------
MACROS=""
OBJECTS="init.o api-common.o common.o extra.o dummy.o error-codes.o"
if [ -n "$POSIX" ]; then
OBJECTS="${OBJECTS} posix.o api-posix.o";
MACROS="${MACROS} PS__POSIX"
PS__POSIX=1
fi
if [ -n "$BSD" ]; then
MACROS="${MACROS} PS__BSD"
PS__BSD=1
fi
MACROS="$MACROS PS__VERSION"
PS__VERSION=546
if [ -n "$WINDOWS" ]; then
VER=`"$RBIN" --vanilla --slave -f inst/tools/winver.R`
MAJOR=`echo $VER | cut -f1 -d.`
MINOR=`echo $VER | cut -f2 -d.`
WINVER=`"$RBIN" --vanilla --slave -e "cat(sprintf('0x0%s', $MAJOR*100 + $MINOR))"`
MACROS="${MACROS} PS__WINDOWS _WIN32_WINNT _AVAIL_WINVER"
MACROS="${MACROS} _CRT_SECURE_NO_WARNINGS PSAPI_VERSION"
PS__WINDOWS=1
_WIN32_WINNT=$WINVER
_AVAIL_WINVER=$WINVER
_CT_SECURE_NO_WARNINGS=""
PSAPI_VERSION=1
OBJECTS="${OBJECTS} windows.o api-windows.o api-windows-conn.o"
OBJECTS="${OBJECTS} arch/windows/process_info.o"
OBJECTS="${OBJECTS} arch/windows/process_handles.o"
OBJECTS="${OBJECTS} arch/windows/wmi.o"
LIBRARIES="psapi kernel32 advapi32 shell32 netapi32 iphlpapi wtsapi32"
LIBRARIES="${LIBRARIES} ws2_32 PowrProf Pdh"
TARGETS=interrupt
elif [ -n "$MACOS" ]; then
MACROS="${MACROS} PS__MACOS"
PS__MACOS=1
OBJECTS="${OBJECTS} macos.o api-macos.o arch/macos/process_info.o"
elif [ -n "$FREEBSD" ]; then
MACROS="${MACROS} PS__FREEBSD"
PS__FREEBSD=1
OBJECTS="${OBJECTS} bsd.o arch/freebsd/specific.o"
OBJECTS="${OBJECTS} arch/freebsd/sys_socks.o"
OBJECTS="${OBJECTS} arch/freebsd/proc_socks.o"
LIBRARIES="devstat"
elif [ -n "$OPENBSD" ]; then
MACROS="${MACROS} PS__OPENBSD"
PS__OPENBSD=1
OBJECTS="${OBJECTS} bsd.o arch/openbsd/specific.o"
LIBRARIES="kvm"
elif [ -n "$NETBSD" ]; then
MACROS="${MACROS} PS__NETBSD"
PS__NETBSD=1
OBJECTS="${OBJECTS} bsd.o arch/netbsd/specific.o"
OBJECTS="${OBJECTS} arch/netbsd/sys_socks.o"
OBJECTS="${OBJECTS} arch/netbsd/proc_socks.o"
LIBRARIES="kvm"
elif [ -n "$LINUX" ]; then
MACROS="${MACROS} PS__LINUX"
PS__LINUX=1
OBJECTS="${OBJECTS} linux.o api-linux.o"
elif [ -n "$SUNOS" ]; then
MACROS="${MACROS} PS__SUNOS"
PS__SUNOS=1
OBJECTS="${OBJECTS} sunos.o arch/solaris/v10/ifaddrs.o"
OBJECTS="${OBJECTS} arch/solaris/environ.o"
elif [ -n "$AIX" ]; then
MACROS="${MACROS} PS__AIX"
PS__AIX=1
OBJECTS="${OBJECTS} aix.o"
OBJECTS="${OBJECTS} arch/aix/net_connections.o"
OBJECTS="${OBJECTS} arch/aix/common.o"
OBJECTS="${OBJECTS} arch/aix/ifaddrs.o"
fi
# ------------------------------------------------------------------------
# Create Makevars file
# ------------------------------------------------------------------------
"$RBIN" --vanilla --slave -f inst/tools/error-codes.R
# OBJECTS (= source files)
# LIBRARIES -> PKG_LIBS
LIBS=`for l in $LIBRARIES; do echo "-l${l}"; done | tr "\n", " "`
cat src/Makevars.in | \
sed "s|@OBJECTS@|${OBJECTS}|" | \
sed "s/@LIBS@/${LIBS}/" | \
sed "s/@TARGETS@/${TARGETS}/" > src/Makevars
# MACROS will be set as preprocessor macros
echo "/* Macros created by configure */" > src/config.h
for m in $MACROS; do
ind='$'$m
echo \#undef $m
eval echo '\#'define $m $ind
done >> src/config.h