This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.et
executable file
·60 lines (47 loc) · 1.79 KB
/
build.et
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
#!/usr/bin/env et
import std.( os, fs, str, term );
import cxxproj.cxxproj;
# will set CC variable accordingly
eth = cxx_new_proj();
self_prefix = false;
prefix = os.get_env( 'PREFIX' );
if prefix.empty() {
prefix = os.get_env( 'PWD' );
self_prefix = true;
}
eth.add_flags( [ '-fPIC', '-Wall', '-Wextra', '-Wno-unused-parameter',
'-DBUILD_PREFIX_DIR=' + prefix, '-Wl,-rpath,' + prefix + '/lib/ethereal/' ] );
if os.get_env( 'CC' ) != 'g++' {
eth.add_flags( [ "-Wno-c99-extensions", "-Wno-unused-command-line-argument" ] );
}
eth.add_lib_dirs( [ '-L./buildfiles' ] );
if args.len() > 1 && args.find( 'debug' ) >= 0 || args.find( 'memlog' ) >= 0 {
if os.exec( 'stat buildfiles 1>/dev/null 2>&1' ) == 0 && os.exec( 'stat buildfiles/.debug_mode 1>/dev/null 2>&1' ) != 0 {
#os.exec( 'rm -rf buildfiles && mkdir buildfiles && touch buildfiles/.debug_mode' );
}
if args.find( 'debug' ) >= 0 { eth.add_flags( [ '-DDEBUG_MODE', '-DMEM_LOGS' ] ); }
else { eth.add_flags( [ '-DMEM_LOGS' ] ); }
} else {
if os.exec( 'stat buildfiles 1>/dev/null 2>&1' ) == 0 && os.exec( 'stat buildfiles/.debug_mode 1>/dev/null 2>&1' ) == 0 {
#os.exec( 'rm -rf buildfiles' );
}
eth.add_flags( [ '-march=native', '-O2', '-flto' ] );
}
if !eth.use_lib( 'libdl' ) {
println( 'libdl (required) was not found, quitting' );
exit( 1 );
}
if !eth.use_lib( 'gmpxx' ) {
println( 'libgmpxx (required) was not found, quitting' );
exit( 1 );
}
srcs = fs.dir_entries( 'src', fs.ent.RECURSE );
eth.add_build( 'et', 'dynamic' ).add_files( srcs, '' );
println( eth );
if args.len() > 1 && args.find( 'install' ) >= 0 || self_prefix == true {
if os.get_env( 'EUID' ).empty() || os.name == 'osx' {
#os.install( 'buildfiles/et', os.get_env( 'PREFIX' ) + '/bin/' );
} else {
cprintln( '{r}Run as root to install the built files{0}' );
}
}