usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / usbmodeswitch / jim / autosetup / cc-lib.tcl
blobe8e5e8608f246bda8aa08502fca477ac68728763
1 # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2 # All rights reserved
4 # @synopsis:
6 # Provides a library of common tests on top of the 'cc' module.
8 use cc
10 module-options {}
12 # @cc-check-lfs
14 # The equivalent of the AC_SYS_LARGEFILE macro
16 # defines 'HAVE_LFS' if LFS is available,
17 # and defines '_FILE_OFFSET_BITS=64' if necessary
19 # Returns 1 if 'LFS' is available or 0 otherwise
21 proc cc-check-lfs {} {
22 cc-check-includes sys/types.h
23 msg-checking "Checking if -D_FILE_OFFSET_BITS=64 is needed..."
24 set lfs 1
25 if {[msg-quiet cc-with {-includes sys/types.h} {cc-check-sizeof off_t}] == 8} {
26 msg-result no
27 } elseif {[msg-quiet cc-with {-includes sys/types.h -cflags -D_FILE_OFFSET_BITS=64} {cc-check-sizeof off_t}] == 8} {
28 define _FILE_OFFSET_BITS 64
29 msg-result yes
30 } else {
31 set lfs 0
32 msg-result none
34 define-feature lfs $lfs
35 return $lfs
38 # @cc-check-endian
40 # The equivalent of the AC_C_BIGENDIAN macro
42 # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
43 # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
45 # Returns 1 if determined, or 0 if not.
47 proc cc-check-endian {} {
48 cc-check-includes sys/types.h sys/param.h
49 set rc 0
50 msg-checking "Checking endian..."
51 cc-with {-includes {sys/types.h sys/param.h}} {
52 if {[cctest -code {
53 #if !defined(BIG_ENDIAN) || !defined(BYTE_ORDER)
54 #error unknown
55 #elif BYTE_ORDER != BIG_ENDIAN
56 #error little
57 #endif
58 }]} {
59 define-feature big-endian
60 msg-result "big"
61 set rc 1
62 } elseif {[cctest -code {
63 #if !defined(LITTLE_ENDIAN) || !defined(BYTE_ORDER)
64 #error unknown
65 #elif BYTE_ORDER != LITTLE_ENDIAN
66 #error big
67 #endif
68 }]} {
69 define-feature little-endian
70 msg-result "little"
71 set rc 1
72 } else {
73 msg-result "unknown"
76 return $rc