aboutsummaryrefslogtreecommitdiff
path: root/mmoc
diff options
context:
space:
mode:
authorAdrien Bustany <abustany@gnome.org>2010-04-12 10:20:38 -0400
committerTomas Junnonen <tomas.junnonen@nokia.com>2010-04-13 09:48:58 +0300
commitdcd0102432c839024d73e19977d0de0b9e8b3e64 (patch)
treef1427346e20d5b518d9285f993554b4440fd2ced /mmoc
parent9a48bff3264161fd4a3658d961d9e621af7636cf (diff)
Changes: Smart detection of moc path
RevBy: Tomas Details: Adapts the mmoc script to better detect the path to the moc executables. It adds the cases where QTDIR is defined but moc is not installed in that path (happens on fedora 12 with qt3 installed but not qt3-devel), and the case where the moc executable is named qt4, which is the case on various popular Linux distributions.
Diffstat (limited to 'mmoc')
-rwxr-xr-xmmoc/mmoc45
1 files changed, 33 insertions, 12 deletions
diff --git a/mmoc/mmoc b/mmoc/mmoc
index 2f0c0a8d..98737a56 100755
--- a/mmoc/mmoc
+++ b/mmoc/mmoc
@@ -2,24 +2,45 @@
use English;
-if ($ENV{"QTDIR"})
-{
- $::QT_MOC_PATH = "$ENV{\"QTDIR\"}/bin/moc";
-}
-else
-{
- $::QT_MOC_PATH = "moc";
- # here we need to do things differently for windows
- if ( "MSWin32" != "$OSNAME" )
- {
- $::QT_MOC_PATH = `which moc`;
- }
+$::QT_MOC_PATH = find_moc ();
+
+if (! -x $::QT_MOC_PATH) {
+ print "Unable to find moc, or is not executable\n";
+ exit (1);
}
chomp( $::QT_MOC_PATH );
exit main( @ARGV );
+sub find_moc
+{
+ my $mocpath;
+
+ if ($ENV{"QTDIR"} && -x "$ENV{\"QTDIR\"}/bin/moc")
+ {
+ return "$ENV{\"QTDIR\"}/bin/moc";
+ }
+
+ # here we need to do things differently for windows
+ if ( "MSWin32" ne "$OSNAME" )
+ {
+ $mocpath = `which moc 2>/dev/null`;
+ if ($? == 0) {
+ chomp $mocpath;
+ return $mocpath;
+ }
+
+ $mocpath = `which moc-qt4 2>/dev/null`;
+ if ($? == 0) {
+ chomp $mocpath;
+ return $mocpath;
+ }
+ } else {
+ return "moc";
+ }
+}
+
sub main
{
my @argv = @_;