aboutsummaryrefslogtreecommitdiff
blob: 6fd46c2a285ea839e01ca1e6dce6bc2339fd9dd1 (plain)
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
diff --git a/Configure.pl b/Configure.pl
index 72a5dad..f829d5c 100755
--- a/Configure.pl
+++ b/Configure.pl
@@ -32,7 +32,7 @@ GetOptions(\%args, qw(
     os=s shell=s toolchain=s compiler=s
     ar=s cc=s ld=s make=s has-sha has-libuv
     static has-libtommath has-libatomic_ops
-    has-dyncall has-libffi
+    has-dyncall has-libffi pkgconfig=s
     build=s host=s big-endian jit! enable-jit lua=s has-dynasm
     prefix=s bindir=s libdir=s mastdir=s make-install asan ubsan),
     'no-optimize|nooptimize' => sub { $args{optimize} = 0 },
@@ -99,6 +99,7 @@ $config{config} = join ' ', map { / / ? "\"$_\"" : $_ } @args;
 $config{osname} = $^O;
 $config{osvers} = $Config{osvers};
 $config{lua} = $args{lua} // './3rdparty/dynasm/minilua@exe@';
+$config{pkgconfig} = $args{pkgconfig} // '/usr/bin/pkg-config';
 
 # set options that take priority over all others
 my @keys = qw( ar cc ld make );
@@ -164,12 +165,33 @@ if (-e '3rdparty/libuv/src/unix/threadpool' . $defaults{obj}
     system($defaults{make}, 'realclean')
 }
 
+# test whether pkg-config works
+if (-e "$config{pkgconfig}") {
+    print("\nTesting pkgconfig ... ");
+    system("$config{pkgconfig}", "--version");
+    if ( $? == 0 ) {
+        $config{pkgconfig_works} = 1;
+    } else {
+        $config{pkgconfig_works} = 0;
+    }
+}
+
 # conditionally set include dirs and install rules
 $config{cincludes} //= '';
 $config{install}   //= '';
 if ($args{'has-libuv'}) {
     $defaults{-thirdparty}->{uv} = undef;
     unshift @{$config{usrlibs}}, 'uv';
+    if ($config{pkgconfig_works}) {
+        my $result = `$config{pkgconfig} --cflags libuv`;
+        if ( $? == 0 ) {
+            $result =~ s/\n/ /g;
+            $config{cincludes} .= ' ' . "$result";
+            print("Adding extra include for libuv: $result\n");
+        } else {
+            print("Error occured when running $config{pkgconfig} --cflags libuv.\n");
+        }
+    }
 }
 else {
     $config{cincludes} .= ' ' . $defaults{ccinc} . '3rdparty/libuv/include'
@@ -181,6 +203,16 @@ else {
 if ($args{'has-libatomic_ops'}) {
     $defaults{-thirdparty}->{lao} = undef;
     unshift @{$config{usrlibs}}, 'atomic_ops';
+    if ($config{pkgconfig_works}) {
+        my $result = `$config{pkgconfig} --cflags atomic_ops`;
+        if ( $? == 0 ) {
+            $result =~ s/\n/ /g;
+            $config{cincludes} .= ' ' . "$result";
+            print("Adding extra include for atomic_ops: $result\n");
+        } else {
+            print("Error occured when running $config{pkgconfig} --cflags atomic_ops.\n");
+        }
+    }
 }
 else {
     $config{cincludes} .= ' ' . $defaults{ccinc} . '3rdparty/libatomic_ops/src';
@@ -216,7 +248,8 @@ if ($args{'has-libtommath'}) {
 }
 else {
     $config{cincludes} .= ' ' . $defaults{ccinc} . '3rdparty/libtommath';
-    $config{install}   .= "\t\$(CP) 3rdparty/libtommath/*.h \$(DESTDIR)\$(PREFIX)/include/libtommath\n";
+    $config{install}   .= "\t\$(MKPATH) \$(DESTDIR)\$(PREFIX)/include/libtommath\n"
+                        . "\t\$(CP) 3rdparty/libtommath/*.h \$(DESTDIR)\$(PREFIX)/include/libtommath\n";
 }
 
 if ($args{'has-dynasm'}) {
@@ -232,6 +265,16 @@ if ($args{'has-libffi'}) {
     $config{nativecall_backend} = 'libffi';
     unshift @{$config{usrlibs}}, 'ffi';
     push @{$config{defs}}, 'HAVE_LIBFFI';
+    if ($config{pkgconfig_works}) {
+        my $result = `$config{pkgconfig} --cflags libffi`;
+        if ( $? == 0 ) {
+            $result =~ s/\n/ /g;
+            $config{cincludes} .= ' ' . "$result";
+            print("Adding extra include for libffi: $result\n");
+        } else {
+            print("Error occured when running $config{pkgconfig} --cflags libffi.\n");
+        }
+    }
 }
 elsif ($args{'has-dyncall'}) {
     unshift @{$config{usrlibs}}, 'dyncall_s', 'dyncallback_s', 'dynload_s';
@@ -364,6 +407,7 @@ my $order = $config{be} ? 'big endian' : 'little endian';
 print "\n", <<TERM, "\n";
         make: $config{make}
      compile: $config{cc} $config{cflags}
+    includes: $config{cincludes}
         link: $config{ld} $config{ldflags}
         libs: $config{ldlibs}
 
@@ -873,6 +917,10 @@ Build and install MoarVM in addition to configuring it.
 
 =item --has-libffi
 
+=item --pkgconfig=/path/to/pkgconfig/executable
+
+Provide path to the pkgconfig executable. Default: /usr/bin/pkg-config
+
 =item --no-jit
 
 Disable JIT compiler, which is enabled by default to JIT-compile hot frames.
diff --git a/build/Makefile.in b/build/Makefile.in
index 56a4c8a..b94e847 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -454,9 +454,6 @@ install: all
 	$(CP) src/strings/*.h $(DESTDIR)$(PREFIX)/include/moar/strings
 	$(CP) src/jit/*.h $(DESTDIR)$(PREFIX)/include/moar/jit
 	$(CP) src/instrument/*.h $(DESTDIR)$(PREFIX)/include/moar/instrument
-	$(MKPATH) $(DESTDIR)$(PREFIX)/include/libuv
-	$(MKPATH) $(DESTDIR)$(PREFIX)/include/libtommath
-	$(CP) 3rdparty/libuv/include/*.h $(DESTDIR)$(PREFIX)/include/libuv
 @install@
 
 lib: @moar@
diff --git a/build/setup.pm b/build/setup.pm
index 324cc88..c87d79e 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -125,7 +125,7 @@ our %TC_POSIX = (
     ccshared   => '-fPIC',
     ldshared   => '-shared @ccshared@',
     moarshared => '',
-    ldrpath    => '-Wl,-rpath,@libdir@ -Wl,-rpath,@prefix@/share/perl6/site/lib',
+    ldrpath    => '-Wl,-rpath,/@libdir@ -Wl,-rpath,@prefix@/share/perl6/site/lib',
 
     arflags => 'rcs',
     arout   => '',