-
Notifications
You must be signed in to change notification settings - Fork 4
/
configure.ac
334 lines (289 loc) · 10.1 KB
/
configure.ac
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.10])
AC_INIT([pic32prog], [2.1.0], [[email protected]])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([subdir-objects no-dependencies])
#LT_INIT
AC_CONFIG_MACRO_DIR([m4])
AM_SILENT_RULES([yes])
# Checks for programs.
AC_PROG_CC
PKG_PROG_PKG_CONFIG
AC_CANONICAL_HOST
WANT_HID=0
WANT_USB=0
WANT_SER=0
ADAPTER_SRC=""
ADAPTER_OBJ=""
HID_SRC=""
HID_OBJ=""
SER_SRC=""
SER_OBJ=""
# First round decides if we want USB or not.
AC_ARG_ENABLE([an1388], AS_HELP_STRING([--disable-an1388], [Disable AN1388 HID adapter]))
AS_IF([test "x$enable_an1388" != "xno"], [
WANT_HID=1
WANT_USB=1
])
AC_ARG_ENABLE([hidboot], AS_HELP_STRING([--disable-hidboot], [Disable HidBoot adapter]))
AS_IF([test "x$enable_hidboot" != "xno"], [
WANT_USB=1
WANT_HID=1
])
AC_ARG_ENABLE([mpsse], AS_HELP_STRING([--disable-mpsse], [Disable MPSSE adapter]))
AS_IF([test "x$enable_mpsse" != "xno"], [
WANT_USB=1
])
AC_ARG_ENABLE([pickit2], AS_HELP_STRING([--disable-pickit2], [Disable PICkit2 adapter]))
AS_IF([test "x$enable_pickit2" != "xno"], [
WANT_USB=1
WANT_HID=1
])
AC_ARG_ENABLE([uhb], AS_HELP_STRING([--disable-uhb], [Disable UHB adapter]))
AS_IF([test "x$enable_uhb" != "xno"], [
WANT_USB=1
WANT_HID=1
])
AS_IF([test "x$enable_an1388_uart" != "xno"], [
WANT_SER=1
SER_SRC='serial.c'
SER_OBJ='serial.$(OBJEXT)'
AC_DEFINE([ENABLE_SERIAL],[1],[Serial devices enabled])
])
AS_IF([test "x$enable_bitbang" != "xno"], [
WANT_SER=1
SER_SRC='serial.c'
SER_OBJ='serial.$(OBJEXT)'
AC_DEFINE([ENABLE_SERIAL],[1],[Serial devices enabled])
])
AS_IF([test "x$enable_stk500v2" != "xno"], [
WANT_SER=1
SER_SRC='serial.c'
SER_OBJ='serial.$(OBJEXT)'
AC_DEFINE([ENABLE_SERIAL],[1],[Serial devices enabled])
])
case $host_os in
darwin* )
AM_CONDITIONAL([OSX], true)
AM_CONDITIONAL([LINUX], false)
AM_CONDITIONAL([WINDOWS], false)
AM_CONDITIONAL([BSD], false)
AS_IF([test "x$WANT_USB" = "x1"], [
LIBUSB_PREFIX=`pkg-config --libs-only-L libusb-1.0 | cut -c3-`
AC_SUBST([LIBUSB_PREFIX])
PKG_CHECK_MODULES(LIBUSB, libusb-1.0,[
LIBUSB_LIBS="-framework IOKit -framework CoreFoundation -framework Security ${LIBUSB_PREFIX}/libusb-1.0.a -lobjc"
],[WANT_USB=-1; WANT_HID=0])
])
AS_IF([test "x$WANT_HID" = "x1"], [
HID_SRC="hid/mac/hid.c"
HID_OBJ='hid/mac/hid.$(OBJEXT)'
])
;;
linux* )
AM_CONDITIONAL([OSX], false)
AM_CONDITIONAL([LINUX], true)
AM_CONDITIONAL([WINDOWS], false)
AM_CONDITIONAL([BSD], false)
AX_PTHREAD
AS_IF([test "x$WANT_USB" = "x1"], [
PKG_CHECK_MODULES(LIBUSB, libusb-1.0,[
LIBUSB_STATIC='-Wl,-Bstatic -Wl,-lusb-1.0 -Wl,-Bdynamic'
],[WANT_USB=-1; WANT_HID=0; LIBUSB_STATIC=''])
PKG_CHECK_MODULES(UDEV, libudev,,[WANT_USB=-1; WANT_HID=0; LIBUSB_STATIC=''])
])
AS_IF([test "x$WANT_HID" = "x1"], [
AM_ICONV
AS_IF([test "x$am_cv_func_iconv" = "xyes"], [
HID_SRC="hid/linux/hid.c"
HID_OBJ='hid/linux/hid.$(OBJEXT)'
LIBUSB_LIBS="${LIBUSB_LIBS} $LIBICONV"
],[
WANT_HID=-1
])
])
;;
*bsd* )
LDFLAGS="${LDFLAGS} -L/usr/local/lib"
CFLAGS="${CFLAGS} -I/usr/local/include"
AM_CONDITIONAL([OSX], false)
AM_CONDITIONAL([LINUX], true)
AM_CONDITIONAL([WINDOWS], false)
AM_CONDITIONAL([BSD], true)
AX_PTHREAD
AS_IF([test "x$WANT_USB" = "x1"], [
PKG_CHECK_MODULES(LIBUSB, libusb-1.0,[
],[WANT_USB=-1; WANT_HID=0; LIBUSB_STATIC=''])
])
AS_IF([test "x$WANT_HID" = "x1"], [
AM_ICONV
AS_IF([test "x$am_cv_func_iconv" = "xyes"], [
HID_SRC="hid/bsd/hid.c"
HID_OBJ='hid/bsd/hid.$(OBJEXT)'
LIBUSB_LIBS="${LIBUSB_LIBS} $LIBICONV"
],[
WANT_HID=-1
])
])
;;
*mingw* )
AM_CONDITIONAL([OSX], false)
AM_CONDITIONAL([LINUX], false)
AM_CONDITIONAL([WINDOWS], true)
AM_CONDITIONAL([BSD], false)
AS_IF([test "x$WANT_HID" = "x1"], [
HID_SRC="hid/linux/hid.c"
HID_OBJ='hid/linux/hid.$(OBJEXT)'
])
AS_IF([test "x$WANT_USB" = "x1"], [
LIBUSB_LIBS="-Llibusb-win32/MinGW64/static -lusb-1.0 -lsetupapi"
LIBUSB_CFLAGS="-Ilibusb-win32/include/libusb-1.0"
])
AS_IF([test "x$WANT_HID" = "x1"], [
HID_SRC="hid/windows/hid.c"
HID_OBJ='hid/windows/hid.$(OBJEXT)'
])
;;
esac
# Second round decides what we can actually use.
AS_IF([test "x$enable_an1388" != "xno"], [
AS_IF([test "x$WANT_USB$WANT_HID" = "x11"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-an1388.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-an1388.\$(OBJEXT)"
AC_DEFINE([ENABLE_AN1388],[1],[AN1388 HID Adapter is enabled])
WITH_AN1388=1
],)
])
AS_IF([test "x$enable_an1388_uart" != "xno"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-an1388-uart.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-an1388-uart.\$(OBJEXT)"
AC_DEFINE([ENABLE_AN1388_UART],[1],[AN1388 UART Adapter is enabled])
WITH_AN1388_UART=1
])
AS_IF([test "x$enable_bitbang" != "xno"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-bitbang.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-bitbang.\$(OBJEXT)"
AC_DEFINE([ENABLE_BITBANG],[1],[BitBang Adapter is enabled])
WITH_BITBANG=1
])
AS_IF([test "x$enable_hidboot" != "xno"], [
AS_IF([test "x$WANT_USB$WANT_HID" = "x11"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-hidboot.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-hidboot.\$(OBJEXT)"
AC_DEFINE([ENABLE_HIDBOOT],[1],[HidBoot Adapter is enabled])
WITH_HIDBOOT=1
],)
])
AS_IF([test "x$enable_mpsse" != "xno"], [
AS_IF([test "x$WANT_USB" = "x1"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-mpsse.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-mpsse.\$(OBJEXT)"
AC_DEFINE([ENABLE_MPSSE],[1],[MPSSE Adapter is enabled])
WITH_MPSSE=1
],)
])
AS_IF([test "x$enable_pickit2" != "xno"], [
AS_IF([test "x$WANT_USB$WANT_HID" = "x11"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-pickit2.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-pickit2.\$(OBJEXT)"
AC_DEFINE([ENABLE_PICKIT2],[1],[PICKIT2 Adapter is enabled])
WITH_PICKIT2=1
],)
])
AS_IF([test "x$enable_stk500v2" != "xno"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-stk500v2.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-stk500v2.\$(OBJEXT)"
AC_DEFINE([ENABLE_STK500V2],[1],[STK500v2 Adapter is enabled])
WITH_STK500V2=1
])
AS_IF([test "x$enable_uhb" != "xno"], [
AS_IF([test "x$WANT_USB$WANT_HID" = "x11"], [
ADAPTER_SRC="${ADAPTER_SRC} adapters/adapter-uhb.c"
ADAPTER_OBJ="${ADAPTER_OBJ} adapters/adapter-uhb.\$(OBJEXT)"
AC_DEFINE([ENABLE_UHB],[1],[UHB Adapter is enabled])
WITH_UHB=1
],)
])
AC_MSG_CHECKING([build number])
GITCOUNT=0
if [[ -d .git ]]; then
GITCOUNT=`git tag -l --sort -version:refname | head -n 1` 2>&5
else
if [[ -f .version ]]; then
GITCOUNT=`cat .version`
fi
fi
AC_MSG_RESULT([$GITCOUNT])
AC_SUBST([GITCOUNT])
AC_SUBST([SER_SRC])
AC_SUBST([SER_OBJ])
AC_SUBST([HID_SRC])
AC_SUBST([HID_OBJ])
AC_SUBST([ADAPTER_SRC])
AC_SUBST([ADAPTER_OBJ])
AC_SUBST([LIBUSB_LIBS])
AC_SUBST([LIBUSB_CFLAGS])
AC_SUBST([LIBUSB_STATIC])
AC_SUBST([UDEV_LIBS])
AC_SUBST([UDEV_CFLAGS])
CFLAGS="$CFLAGS -Iinclude $LIBUSB_CFLAGS $UDEV_CFLAGS $PTHREAD_CFLAGS"
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h locale.h malloc.h stdlib.h string.h sys/ioctl.h sys/time.h termios.h unistd.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([atexit clock_gettime gettimeofday memset select setlocale strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol strtoul])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
echo
echo " Configuration Summary"
echo " ---------------------"
echo
printf " AN1388 (HID) ............. "
AS_IF([test "x$WITH_AN1388" = "x1"], [echo Enabled], [echo Disabled])
printf " AN1388 (UART) ............ "
AS_IF([test "x$WITH_AN1388_UART" = "x1"], [echo Enabled], [echo Disabled])
printf " BitBang .................. "
AS_IF([test "x$WITH_BITBANG" = "x1"], [echo Enabled], [echo Disabled])
printf " HIDBoot .................. "
AS_IF([test "x$WITH_HIDBOOT" = "x1"], [echo Enabled], [echo Disabled])
printf " MPSSE .................... "
AS_IF([test "x$WITH_MPSSE" = "x1"], [echo Enabled], [echo Disabled])
printf " PICkit2/3 ................ "
AS_IF([test "x$WITH_PICKIT2" = "x1"], [echo Enabled], [echo Disabled])
printf " STK500v2 ................. "
AS_IF([test "x$WITH_STK500V2" = "x1"], [echo Enabled], [echo Disabled])
printf " UHB ...................... "
AS_IF([test "x$WITH_UHB" = "x1"], [echo Enabled], [echo Disabled])
echo
printf " USB Support .............. "
AS_IF([test "x$WANT_USB" = "x1"], [echo Enabled], [echo Disabled])
printf " HID Support .............. "
AS_IF([test "x$WANT_HID" = "x1"], [echo Enabled], [echo Disabled])
printf " Serial Support ........... "
AS_IF([test "x$WANT_SER" = "x1"], [echo Enabled], [echo Disabled])
echo
echo " Compiling For ............ $host_os"
echo
AS_IF([test "x$WANT_USB" = "x-1"], [
echo "Warning:"
echo " USB support could not be enabled. You may need to install libusb-1.0"
echo
],);
AS_IF([test "x$WANT_HID" = "x-1"], [
echo "Warning:"
echo " HID support could not be enabled. You may need to install libiconv"
echo
],);