Menu

[865f8f]: / README  Maximize  Restore  History

Download this file

249 lines (208 with data), 6.9 kB

  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

cstem - C/C++ system probe, test and automation toolkit


Description
===========

cstem is a portable toolkit for probing and testing C/C++ system. It consist of 4 scripts: cprobe, cltest, cppdef, mkdep.
cstem scripts can be used standalone or as part of software build systems.
All scripts are portable and have no dependencies.



Overview
========

### cprobe

cprobe is a portable script that reliably probes a compiler to get the following properties:

* compiler command (if not specified on command line)
* compiler type
* compiler version
* C/C++ language standard
* target OS
* target OS version,
* target architecture
* target bitness
* target endianess
* target data model
* POSIX support version
* SUS support version
* if compiler is cross-compiler
* if compiler is C++ compiler

Example:
~~~bash
$ cprobe
type:               gcc
version:            4.9.2
command:            gcc
C standard:         c89
C++ standard:       cxx98
target os:          gnulinux
target os version:  -
target arch:        x86_64
bitness:            64
endianness:         little
data model:         lp64
cross compiler:     false
C++ compiler:       true
posix version:      posix1-2008
sus version:        susv4

$ cprobe clang
type:               clang
version:            3.5.0
command:            clang
C standard:         c99
C++ standard:       cxx98
target os:          gnulinux
target os version:  -
target arch:        x86_64
bitness:            64
endianness:         little
data model:         lp64
cross compiler:     false
C++ compiler:       true
posix version:      posix1-2008
sus version:        susv4

$ cprobe x86_64-w64-mingw32-gcc
type:               gcc
version:            4.9.1
command:            /usr/bin/x86_64-w64-mingw32-gcc
C standard:         c89
C++ standard:       cxx98
target os:          windows
target os version:  -
target arch:        x86_64
bitness:            64
endianness:         little
data model:         llp64
cross compiler:     true
C++ compiler:       true
posix version:      -
sus version:        -

$ cprobe g++ -lang=c++11 -msse4 -O3 -g2 -I. -Wall
type:               gcc
version:            4.9.2
command:            g++
C standard:         c89
C++ standard:       cxx98
target os:          gnulinux
target os version:  -
target arch:        x86_64
bitness:            64
endianness:         little
data model:         lp64
cross compiler:     true
C++ compiler:       true
posix version:      posix1-2008
sus version:        susv4

$ cprobe -f4
gcc:gnulinux:x86_64:gcc

$ cprobe -f5
gcc:4.9.2:c89:cxx98:gnulinux::x86_64:64::lp64:false:true:posix1-2008:susv4:gcc

$ cprobe gcc -f1
CC_CMD="gcc"
CC_TYPE="gcc"
CC_VERSION="4.9.2"
CC_STD="c89"
CC_CXX_STD="cxx98"
CC_OS="gnulinux"
CC_OS_VERSION=""
CC_ARCH="x86_64"
CC_BITNESS="64"
CC_ENDIANNESS="little"
CC_DATA_MODEL="lp64"
CC_FLAG_CROSS="false"
CC_FLAG_CXX="true"
CC_POSIX="posix1-2008"
CC_SUS="susv4"
~~~

--------------------------------------------------------------------------------

### cltest

cltest can test compiler, compiler flags, system libraries and other C/C++ system properties. If you need to check system for any C/C++ dependencies, cltest tool is what you need.

Example:
~~~bash
$ cltest
checking compiler gcc ... OK
checking linker gcc ... OK

$ cltest clang
checking compiler clang ... OK
checking linker clang ... OK

$ cltest -I. -DVERSION=1.0 -UDEBUG -L. -O3 -g0
checking compiler flags  -I. -DVERSION=1.0 -UDEBUG -O3 -g0 ... OK
checking linker flags  -L. -O3 -g0 ... OK

$ ./cltest -lxml2 -lm stdio.h stdlib.h stdarg.h
checking header stdio.h ... OK
checking header stdlib.h ... OK
checking header stdarg.h ... OK
checking libraries  -lxml2 -lm ... OK

$ cltest clang "#ifdef __clang_major__" -def="__unix__ __linux__"
checking define #ifdef __clang_major__ ... OK
checking define __unix__ ... OK
checking define __linux__ ... OK

$ cltest "fprintf()" "atoi()" =__SIZEOF_INT__ stdio.h errno.h -var="errno sys_errlist"
checking variable errno ... OK
checking variable sys_errlist ... OK
checking rval __SIZEOF_INT__ ... OK
checking function fprintf ... OK
checking function atoi ... OK

$ cltest "xmlXPathInit() xmlListWalk() xmlAddChild()" -lxml2
checking function xmlXPathInit ... OK
checking function xmlListWalk ... OK
checking function xmlAddChild ... OK

$ cltest g++ -lQtGui
checking libraries  -lQtGui ... OK
~~~


**cltest** can test the following properties:

* compiler/linker. check if compiler/linker works
* compiler/linker flags. check if given flags are correct for the specified or autoselected compiler
* libraries. check if given libraries are available on a system
* headers. check if given headers are available on a system
* defines. test specified defines and complex macro commands
* types. check if specified types are available
* enum constants
* extern variables
* functions
* symbols
* rvalues
* one line source strings
* custom source files. Check given source files

--------------------------------------------------------------------------------

### cppdef

cppdef is a simple tool to read CPP defines. It is very useful in 'configure' scripts to check specific compiler or system library properties. Example:

~~~bash
$ cppdef __GNUC__
4
$ cppdef -cc=clang __clang_major__
3
$ ./cppdef LIBXML_VERSION_STRING -I/usr/include/libxml2 libxml/xmlversion.h
20901
~~~

--------------------------------------------------------------------------------

### mkdep

Tool to generate dependencies of C/C++ source files for Makefile. mkdep is portable and compiler-independent.

Example for simple source file 'file1.c':
~~~bash
$ mkdep gcc -o obj/file1.o -c file1.c -I. -g0 -O3 >file.d
$ cat file1.d
obj/file1.o: file1.c /usr/include/stdc-predef.h /usr/include/stdio.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h \
 /usr/include/x86_64-linux-gnu/bits/types.h \
 /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
 /usr/include/_G_config.h /usr/include/wchar.h \
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include/stdarg.h \
 /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
 /usr/include/x86_64-linux-gnu/bits/sys_errlist.h
/usr/include/stdc-predef.h:
/usr/include/stdio.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/libio.h:
/usr/include/_G_config.h:
/usr/include/wchar.h:
/usr/lib/gcc/x86_64-linux-gnu/4.9/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
~~~

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.