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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
#include "configure.h"
#include <iostream>
#include <filesystem>
#include <fstream>
#include <getoptpp/getoptpp.hpp>
#include "settings.h"
#include "execute.h"
#include "libcppbuild.h"
#include "tasks.h"
std::filesystem::path configurationFile("configuration.cc");
std::filesystem::path configHeaderFile("config.h");
const std::map<std::string, std::string> default_configuration{};
const std::map<std::string, std::string>& __attribute__((weak)) configuration()
{
return default_configuration;
}
bool hasConfiguration(const std::string& key)
{
const auto& c = configuration();
return c.find(key) != c.end();
}
const std::string& getConfiguration(const std::string& key,
const std::string& defaultValue)
{
const auto& c = configuration();
if(hasConfiguration(key))
{
return c.at(key);
}
return defaultValue;
}
/*
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/drumgizmo]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-largefile omit support for large files
--enable-gui=backend Use specified gui backend. Can be x11, win32, cocoa,
pugl-x11, pugl-win32, pugl-cocoa or auto
[default=auto]
--enable-custom-channel-count=count
Compile with specified number of output channels
[default=16]
--enable-lv2 Compile the LV2 plugin [default=no]
--enable-vst Compile the VST plugin [default=no]
--enable-cli Compile the command line interface [default=yes]
--disable-input-dummy Disable input dummy plugin [default=enabled]
--disable-input-test Disable input test plugin [default=enabled]
--disable-input-jackmidi
Disable input jackmidi plugin [default=enabled]
--disable-input-alsamidi
Disable input alsamidi plugin [default=enabled]
--disable-input-midifile
Disable input midifile plugin [default=enabled]
--disable-input-oss Disable input oss plugin [enabled by default on
FreeBSD, disabled otherwise]
--disable-output-dummy Disable output dummy plugin [default=enabled]
--disable-output-jackaudio
Disable output jack plugin [default=enabled]
--disable-output-alsa Disable output alsa plugin [default=enabled]
--disable-output-wavfile
Disable output wavfile plugin [default=enabled]
--disable-output-oss Disable output oss plugin [enabled by default on
FreeBSD, disabled otherwise]
--enable-sse=level Enable SSE Level 1, 2, 3 or auto [default=auto]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-debug Build with debug support
--with-nls Build with nls support (default nls enabled)
--with-test Build unit tests
--with-lv2dir=DIR Use DIR as the lv2 plugin directory
[default=LIBDIR/lv2]
--with-vst-sources Point this to the vstsdk24 directory
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
OBJC Objective C compiler command
OBJCFLAGS Objective C compiler flags
OBJCXX Objective C++ compiler command
OBJCXXFLAGS Objective C++ compiler flags
CC C compiler command
CFLAGS C compiler flags
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CPP C preprocessor
CXXCPP C++ preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
X11_CFLAGS C compiler flags for X11, overriding pkg-config
X11_LIBS linker flags for X11, overriding pkg-config
XEXT_CFLAGS C compiler flags for XEXT, overriding pkg-config
XEXT_LIBS linker flags for XEXT, overriding pkg-config
LV2_CFLAGS C compiler flags for LV2, overriding pkg-config
LV2_LIBS linker flags for LV2, overriding pkg-config
SMF_CFLAGS C compiler flags for SMF, overriding pkg-config
SMF_LIBS linker flags for SMF, overriding pkg-config
SNDFILE_CFLAGS
C compiler flags for SNDFILE, overriding pkg-config
SNDFILE_LIBS
linker flags for SNDFILE, overriding pkg-config
JACK_CFLAGS C compiler flags for JACK, overriding pkg-config
JACK_LIBS linker flags for JACK, overriding pkg-config
ALSA_CFLAGS C compiler flags for ALSA, overriding pkg-config
ALSA_LIBS linker flags for ALSA, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
*/
int configure(int argc, char* argv[])
{
Settings settings;
settings.builddir = "build";
std::string cmd_str;
for(int i = 0; i < argc; ++i)
{
if(i > 0)
{
cmd_str += " ";
}
cmd_str += argv[i];
}
dg::Options opt;
int key{256};
std::string build_arch;
std::string build_path;
std::string host_arch;
std::string host_path;
opt.add("build-dir", required_argument, 'b',
"Set output directory for build files (default: '" +
settings.builddir + "').",
[&]() {
settings.builddir = optarg;
return 0;
});
opt.add("verbose", no_argument, 'v',
"Be verbose. Add multiple times for more verbosity.",
[&]() {
settings.verbose++;
return 0;
});
opt.add("build", required_argument, key++,
"Configure for building on specified architecture.",
[&]() {
build_arch = optarg;
return 0;
});
opt.add("build-path", required_argument, key++,
"Set path to build tool-chain.",
[&]() {
build_path = optarg;
return 0;
});
opt.add("host", required_argument, key++,
"Cross-compile to build programs to run on specified architecture.",
[&]() {
host_arch = optarg;
return 0;
});
opt.add("host-path", required_argument, key++,
"Set path to cross-compile tool-chain.",
[&]() {
host_path = optarg;
return 0;
});
opt.add("help", no_argument, 'h',
"Print this help text.",
[&]() {
std::cout << "configure usage stuff\n";
opt.help();
exit(0);
return 0;
});
opt.process(argc, argv);
if(host_arch.empty())
{
host_arch = build_arch;
}
auto tasks = getTasks(settings);
bool needs_cpp{false};
bool needs_c{false};
bool needs_ar{false};
bool needs_asm{false};
for(const auto& task :tasks)
{
switch(task->sourceLanguage())
{
case Language::Auto:
std::cerr << "TargetLanguage not deduced!\n";
exit(1);
break;
case Language::C:
needs_cpp = false;
break;
case Language::Cpp:
needs_c = true;
break;
case Language::Asm:
needs_asm = true;
break;
}
}
// CC=clang
// CXX=clang++
std::string path_env = std::getenv("PATH");
std::cout << path_env << "\n";
std::vector<std::string> paths;
{
std::stringstream ss(path_env);
std::string path;
while (std::getline(ss, path, ':'))
{
paths.push_back(path);
}
}
for(const auto& path_str : paths)
{
std::filesystem::path path(path_str);
auto gcc = path / "gcc";
if(std::filesystem::exists(gcc))
{
std::cout << "Found file gcc in path: " << path << "\n";
auto perms = std::filesystem::status(gcc).permissions();
if((perms & std::filesystem::perms::owner_exec) != std::filesystem::perms::none)
{
std::cout << " - executable by owner\n";
}
if((perms & std::filesystem::perms::group_exec) != std::filesystem::perms::none)
{
std::cout << " - executable by group\n";
}
if((perms & std::filesystem::perms::others_exec) != std::filesystem::perms::none)
{
std::cout << " - executable by others\n";
}
}
}
exit(0);
{
std::ofstream istr(configurationFile);
istr << "#include \"libcppbuild.h\"\n\n";
istr << "const std::map<std::string, std::string>& configuration()\n";
istr << "{\n";
istr << " static std::map<std::string, std::string> c =\n";
istr << " {\n";
istr << " { \"cmd\", \"" << cmd_str << "\" },\n";
istr << " { \"" << cfg::builddir << "\", \"" << settings.builddir << "\" },\n";
istr << " { \"" << cfg::target_cc << "\", \"/usr/bin/gcc\" },\n";
istr << " { \"" << cfg::target_cpp << "\", \"/usr/bin/g++\" },\n";
istr << " { \"" << cfg::target_ar << "\", \"/usr/bin/ar\" },\n";
istr << " { \"" << cfg::target_ld << "\", \"/usr/bin/ld\" },\n";
istr << " { \"" << cfg::host_cc << "\", \"/usr/bin/gcc\" },\n";
istr << " { \"" << cfg::host_cpp << "\", \"/usr/bin/g++\" },\n";
istr << " { \"" << cfg::host_ar << "\", \"/usr/bin/ar\" },\n";
istr << " { \"" << cfg::host_ld << "\", \"/usr/bin/ld\" },\n";
istr << " };\n";
istr << " return c;\n";
istr << "}\n";
}
{
std::ofstream istr(configHeaderFile);
istr << "#pragma once\n\n";
istr << "#define HAS_FOO 1\n";
istr << "//#define HAS_BAR 1\n";
}
return 0;
}
|