-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.PL
172 lines (147 loc) · 4.63 KB
/
Build.PL
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
#!/usr/bin/perl
# Build.PL
# Script to build and install this distribution
#
# $Id: Build.PL 7048 2009-05-12 18:18:13Z [email protected] $
#
# Copyright (C) 2009 Jonathan Yu <[email protected]>. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version. See the LICENSE file, included in this distribution,
# for full details.
use strict;
use warnings;
use Getopt::Long;
use Module::Build;
use lib 'inc';
use QtBuilder;
my( $userSmokeDir, $userSmokeIncDir, $userSmokeLibDir,
$userQtDir, $userQtIncDir, $userQtLibDir );
my @flags;
my @libs;
my $build_puic = 1;
GetOptions(
'--with-smoke-dir:s' => \$userSmokeDir,
'--with-smoke-inc-dir:s' => \$userSmokeIncDir,
'--with-smoke-lib-dir:s' => \$userSmokeLibDir,
'--with-qt-dir:s' => \$userQtDir,
'--with-qt-inc-dir:s' => \$userQtIncDir,
'--with-qt-lib-dir:s' => \$userQtLibDir,
'--with-debug' => sub {push(@flags, '-DDEBUG')},
'--puic!' => \$build_puic,
);
if( $userSmokeDir ) {
$userSmokeIncDir = "$userSmokeDir/include" if !$userSmokeIncDir;
$userSmokeLibDir = "$userSmokeDir/lib" if !$userSmokeLibDir;
}
if( $userQtDir ) {
$userQtIncDir = "$userQtDir/include" if !$userQtIncDir;
$userQtLibDir = "$userQtDir/lib" if !$userQtLibDir;
}
# The bindings should be compiled with the flags for libsmokeqt and qt4
push(@flags,
'-std=gnu++98',
'-Wall',
'-xc++',
'-I.',
);
# If the user specified a specific path for Qt or Smoke, make sure that's in
# the include path
foreach my $path ( $userSmokeIncDir, $userQtIncDir ) {
push(@flags, "-I$path") if $path;
}
# Find libsmokeqt using pkg-config;
# Currently there is no .pc file installed, so we guess...
push(@libs, '-lsmokeqt');
# If the user specified a specific path for Qt or Smoke, make sure that's in
# the lib path
foreach my $path ( $userSmokeLibDir, $userQtLibDir ) {
push(@libs, "-L$path") if $path;
}
# Find QtGui using pkg-config
# QtGui depends on QtCore, so both libraries will be loaded
my $flags = `pkg-config --cflags QtGui QtCore QtXml`;
if (defined($flags) && length($flags)) {
push(@flags, split(' ', $flags));
# If pkg-config got the cflags, we can assume libs will work too
push(@libs, split(' ', `pkg-config --libs QtGui QtCore QtXml`));
}
else {
# If pkg-config couldn't find it, try qmake
#$flags = `qmake`;
#if (defined($flags) && length($flags)) {
#}
#else {
print STDERR 'Could not find SmokeQt4, QtCore and QtGui automatically; ' .
"using some defaults.\n";
print STDERR "To override this behaviour, see INSTALLING\n";
# Some sane defaults
push(@flags,
'-DQT_SHARED',
'-I/usr/include/qt4',
'-I/usr/include/qt4/QtCore',
'-I/usr/include/qt4/QtGui',
);
push(@libs,
'-lQtGui',
'-lQtCore',
);
#}
}
my $builder = QtBuilder->new(
module_name => 'Qt',
license => 'gpl',
dist_author => 'Chris Burel <[email protected]>',
dist_version_from => 'lib/Qt.pm',
dynamic_config => 1,
create_readme => 1,
recursive_test_files => 1,
sign => 1,
create_packlist => 1,
# Maintain compatibility with ExtUtils::MakeMaker installations
create_makefile_pl => 'passthrough',
# Location of our special C and XS source files
c_source => 'src',
xs_files => {
'src/Qt.xs' => 'lib/Qt.xs'
},
extra_compiler_flags => \@flags,
extra_linker_flags => \@libs,
build_puic => $build_puic,
requires => {
'perl' => 5.006,
# Pragmatic and special modules
'Carp' => 1.04,
'version' => 0,
'warnings' => 0,
'strict' => 0,
},
build_requires => {
'ExtUtils::CBuilder' => 0,
'ExtUtils::ParseXS' => 0,
'Test::More' => 0.88,
'Module::Build' => 0.35,
},
recommends => {
},
conflicts => {
},
configure_requires => {
'Module::Build' => 0.35,
},
add_to_cleanup => [ 'Qt-*' ],
script_files => [],
meta_merge => {
resources => {
# Custom resources (must begin with an uppercase letter)
Ratings => 'http://cpanratings.perl.org/d/Qt',
# Official keys (homepage, license, bugtracker)
repository => 'http://perlqt4.googlecode.com/svn/trunk/PerlQt4/perl/',
bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=Qt',
license => 'http://www.opensource.org/licenses/gpl-2.0.php',
},
},
);
$builder->create_build_script();