Subversion Repositories DevTools

Rev

Rev 381 | Rev 5709 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 381 Rev 5672
Line 53... Line 53...
53
my $opt_show_cmds;
53
my $opt_show_cmds;
54
my $opt_type = 'P';
54
my $opt_type = 'P';
55
my $opt_platform;
55
my $opt_platform;
56
my @opt_defs;
56
my @opt_defs;
57
my @opt_incdirs;
57
my @opt_incdirs;
-
 
58
my $opt_localbindir;
-
 
59
my @opt_external_modules;
-
 
60
my @opt_external_modules_paths;
-
 
61
my $opt_clean;
58
 
62
 
59
#
63
#
60
#   Extract arguments
64
#   Extract arguments
61
#
65
#
62
my $result = GetOptions (
66
my $result = GetOptions (
63
                "help+"         => \$opt_help,              # flag, multiple use allowed
67
                "help+"             => \$opt_help,              # flag, multiple use allowed
64
                "manual"        => \$opt_manual,            # flag, multiple use allowed
68
                "manual"            => \$opt_manual,            # flag, multiple use allowed
65
                "verbose+"      => \$opt_verbose,           # flag, multiple use allowed
69
                "verbose+"          => \$opt_verbose,           # flag, multiple use allowed
66
                "Output=s"      => \$opt_output,
70
                "Output=s"          => \$opt_output,
67
                "GccPath=s"     => \$opt_gcc_path,
71
                "GccPath=s"         => \$opt_gcc_path,
68
                "Arch=s"        => \$opt_arch,
72
                "Arch=s"            => \$opt_arch,
69
                "Driver=s"      => \$opt_driver,
73
                "Driver=s"          => \$opt_driver,
70
                "LeaveTmp:s"    => \$opt_leavetmp,
74
                "LeaveTmp:s"        => \$opt_leavetmp,
71
                "Verbose:s"     => \$opt_show_cmds,
75
                "Verbose:s"         => \$opt_show_cmds,
72
                "Type=s"        => \$opt_type,
76
                "Type=s"            => \$opt_type,
73
                "Platform=s"    => \$opt_platform,
77
                "Platform=s"        => \$opt_platform,
74
                "Define=s"      => \@opt_defs,
78
                "Define=s"          => \@opt_defs,
75
                "Define=s"      => \@opt_defs,
79
                "Define=s"          => \@opt_defs,
76
                "Incdir=s"      => \@opt_incdirs,
80
                "Incdir=s"          => \@opt_incdirs,
-
 
81
                "LocalBinDir=s"     => \$opt_localbindir,
-
 
82
                "ExternalModule=s"  => \@opt_external_modules,
-
 
83
                "Clean"             => \$opt_clean,
77
                );
84
                );
78
 
85
 
79
#
86
#
80
#   Process help and manual options
87
#   Process help and manual options
81
#
88
#
Line 104... Line 111...
104
    $KERNELDIR = $test_dir;
111
    $KERNELDIR = $test_dir;
105
}
112
}
106
Error ("Could not find the Kernel Headers",
113
Error ("Could not find the Kernel Headers",
107
       "Need a package that contains include/$opt_platform/Makefile"
114
       "Need a package that contains include/$opt_platform/Makefile"
108
      ) unless ( $KERNELDIR );
115
      ) unless ( $KERNELDIR );
-
 
116
#
-
 
117
#   Must have a nice name for the driver
109
 
118
#
-
 
119
Error ("No driver name specified") unless ( $opt_driver );
110
 
120
 
111
#
121
#
112
#   Calculate required bits
122
#   Calculate required bits
113
#   The generated file. Based on the name of the desired output file and the
123
#   The generated file. Based on the name of the desired output file and the
114
#   source path.
124
#   source path.
115
#
125
#
116
my $gen_file = StripDir($opt_output);
126
my $gen_file = StripDir($opt_output);
-
 
127
my $out_dir = StripFileExt($opt_output);
-
 
128
my $symdir = catdir($opt_localbindir, $opt_driver);
117
 
129
 
118
#
130
#
119
#   Cross-compiler toolchain root
131
#   Cross-compiler toolchain root
120
#   Based on GccPath, remove the gcc bit
132
#   Based on GccPath, remove the gcc bit
121
#
133
#
Line 137... Line 149...
137
#
149
#
138
@opt_source = @ARGV;
150
@opt_source = @ARGV;
139
Error ("No source files specified" ) unless ( @opt_source );
151
Error ("No source files specified" ) unless ( @opt_source );
140
 
152
 
141
#
153
#
142
#   Must have a nice name for the driver
154
#   Locate required symvers files
143
#
155
#
144
Error ("No driver name specified") unless ( $opt_driver );
-
 
145
 
-
 
146
 
-
 
147
Message    "======================================================================";
-
 
148
Message    "Build Linux Device Driver using the native build method";
-
 
149
Message    "         Driver : $opt_driver";
-
 
150
Message    "          Arch  : $ARCH";
-
 
151
Message    "          Type  : $opt_type";
-
 
152
Message    "         Output : $opt_output";
-
 
153
Message    "       Platform : $opt_platform";
-
 
154
Message    " Cross Compiler : $CROSS_COMPILE";
-
 
155
Message    " Kernel Headers : $KERNELDIR";
-
 
156
Message    "         Source : @opt_source";
-
 
157
foreach  ( @opt_defs )
156
if (@opt_external_modules)
158
{
157
{
-
 
158
    foreach my $emodule (@opt_external_modules)
-
 
159
    {
-
 
160
        my $mpath = catfile($opt_localbindir,$emodule,'Module.symvers');
-
 
161
        ReportError("External Module symbols not found for: " . $emodule) unless ((-f $mpath) || $opt_clean); 
-
 
162
        push @opt_external_modules_paths, $mpath;
-
 
163
    }
159
    Message    "         Define : $_";
164
    ErrorDoExit() unless $opt_clean;
160
}
165
}
-
 
166
 
161
foreach  ( @opt_incdirs )
167
unless ($opt_clean)
162
{
168
{
-
 
169
    Message    "======================================================================";
-
 
170
    Message    "Build Linux Device Driver using the native build method";
-
 
171
    Message    "         Driver : $opt_driver";
-
 
172
    Message    "          Arch  : $ARCH";
-
 
173
    Message    "          Type  : $opt_type";
-
 
174
    Message    "         Output : $opt_output";
-
 
175
    Message    "       Platform : $opt_platform";
-
 
176
    Message    " Cross Compiler : $CROSS_COMPILE";
-
 
177
    Message    " Kernel Headers : $KERNELDIR";
-
 
178
    Message    "         Source : @opt_source";
-
 
179
    foreach  ( @opt_external_modules )
-
 
180
    {
-
 
181
        Message    "External Module : $_";
-
 
182
    }
-
 
183
    foreach  ( @opt_defs )
-
 
184
    {
-
 
185
        Message    "         Define : $_";
-
 
186
    }
-
 
187
    foreach  ( @opt_incdirs )
-
 
188
    {
163
    Message    "         Incdir : $_";
189
        Message    "         Incdir : $_";
164
}
190
    }
165
 
191
 
166
Message    "======================================================================";
192
    Message    "======================================================================";
-
 
193
}
167
 
194
 
168
#
195
#
169
#   Convert the list of source files into object files
196
#   Convert the list of source files into object files
170
#   Needed for cleaning
197
#   Needed for cleaning
171
#
198
#
Line 174... Line 201...
174
#
201
#
175
#   Clean any existing build artifacts
202
#   Clean any existing build artifacts
176
#   The build options to place things in a different diractory are broken.
203
#   The build options to place things in a different diractory are broken.
177
#   We must be able to build for multiple targets without confusion so we
204
#   We must be able to build for multiple targets without confusion so we
178
#   clean, then build, then copy out the bits we need.
205
#   clean, then build, then copy out the bits we need.
179
clean();
206
cleanAll();
-
 
207
exit if $opt_clean;
180
 
208
 
181
#
209
#
182
#   Generate a Makefile for use by the driver Builder
210
#   Generate a Makefile for use by the driver Builder
183
#   This encapsulates the complete driver build mechanism
211
#   This encapsulates the complete driver build mechanism
184
#
212
#
Line 209... Line 237...
209
 
237
 
210
System ( 'make', @make_args );
238
System ( 'make', @make_args );
211
 
239
 
212
Error  ("Generated output module file not found: $gen_file") unless ( -f $gen_file );
240
Error  ("Generated output module file not found: $gen_file") unless ( -f $gen_file );
213
copy ( $gen_file, $opt_output ) || Error ("Cannot copy output file: $opt_output");
241
copy ( $gen_file, $opt_output ) || Error ("Cannot copy output file: $opt_output");
-
 
242
 
-
 
243
#
-
 
244
#   Copy Module.symvers into a local directory for inter-module building
-
 
245
#   So far this is only supported within the same build - ie: Module.symvers
-
 
246
#   must be created in this build. The file will not be sourced from a package.
-
 
247
#   #
-
 
248
my $symfile = 'Module.symvers';
-
 
249
if ( -f $symfile && -s $symfile  )
-
 
250
{
-
 
251
    mkpath ($symdir) || Error ("Can't create $symdir", $!); 
-
 
252
    copy ( $symfile, $out_dir ) || Error ("Cannot copy $symfile to $out_dir");
-
 
253
    copy ( $symfile, $symdir ) || Error ("Cannot copy $symfile to $symdir");
-
 
254
}
214
clean() unless $opt_leavetmp;
255
clean() unless $opt_leavetmp;
215
 
256
 
216
Message "Script complete";
257
Message "Script complete";
217
exit 0;
258
exit 0;
218
 
259
 
Line 264... Line 305...
264
            }
305
            }
265
            print KBUILD "# End of User definitions\n";
306
            print KBUILD "# End of User definitions\n";
266
            next;
307
            next;
267
        }
308
        }
268
 
309
 
-
 
310
        if ( m~__EXTERNAL_MODULES__~ )
-
 
311
        {
-
 
312
            print KBUILD "# Start of KBUILD_EXTRA_SYMBOLS\n";
-
 
313
            foreach my $line ( @opt_external_modules_paths )
-
 
314
            {
-
 
315
                if ( -s $line)
-
 
316
                {
-
 
317
                    print KBUILD "KBUILD_EXTRA_SYMBOLS += \$(PWD)/$line\n";
-
 
318
                }
-
 
319
            }
-
 
320
            print KBUILD "# End of KBUILD_EXTRA_SYMBOLS\n";
-
 
321
            next;
-
 
322
        }
-
 
323
 
269
        if ( m~__INCDIR__~ )
324
        if ( m~__INCDIR__~ )
270
        {
325
        {
271
            print KBUILD "# Search Include Directories\n";
326
            print KBUILD "# Search Include Directories\n";
272
            foreach my $line ( @opt_incdirs )
327
            foreach my $line ( @opt_incdirs )
273
            {
328
            {
Line 309... Line 364...
309
#
364
#
310
# Returns         : Nothing
365
# Returns         : Nothing
311
#
366
#
312
sub clean
367
sub clean
313
{
368
{
314
    foreach my $files (qw (*.o *~ core .depend .*.cmd *.ko *.mod.c Kbuild ), @obj_files )
369
    foreach my $files (qw (*.o *~ core .depend .*.cmd *.ko *.mod.c Kbuild Module.symvers Module.markers modules.order ), @obj_files )
315
    {
370
    {
316
        unlink ( glob ( $files ));
371
        unlink ( glob ( $files ));
317
    }
372
    }
318
    rmtree  ( '.tmp_versions' );
373
    rmtree  ( '.tmp_versions' );
319
}
374
}
320
 
375
 
-
 
376
#-------------------------------------------------------------------------------
-
 
377
# Function        : cleanAll
-
 
378
#
-
 
379
# Description     : Clobber all build artifacts
-
 
380
#
-
 
381
# Inputs          : Globals: @obj_files
-
 
382
#
-
 
383
# Returns         : Nothing
-
 
384
#
-
 
385
sub cleanAll
-
 
386
{
-
 
387
    clean();
-
 
388
    rmtree  ( $symdir );
-
 
389
}
-
 
390
 
-
 
391
 
321
__DATA__
392
__DATA__
322
#
393
#
323
#   This is a generated file
394
#   This is a generated file
324
#   Do not edit or check into version control
395
#   Do not edit or check into version control
325
################################################################################
396
################################################################################
Line 327... Line 398...
327
# Comment/uncomment the following line to disable/enable debugging
398
# Comment/uncomment the following line to disable/enable debugging
328
DEBUG = y __DEBUG_LINE__
399
DEBUG = y __DEBUG_LINE__
329
 
400
 
330
__DEFINES__
401
__DEFINES__
331
 
402
 
-
 
403
__EXTERNAL_MODULES__
-
 
404
 
332
__INCDIR__
405
__INCDIR__
333
 
406
 
334
# Add your debugging flag (or not) to EXTRA_CFLAGS
407
# Add your debugging flag (or not) to EXTRA_CFLAGS
335
ifeq ($(DEBUG),y)
408
ifeq ($(DEBUG),y)
336
  DEBFLAGS = -O -g -DDEV_DEBUG # "-O" is needed to expand inlines
409
  DEBFLAGS = -O -g -DDEV_DEBUG # "-O" is needed to expand inlines
Line 381... Line 454...
381
 
454
 
382
=head1 SYNOPSIS
455
=head1 SYNOPSIS
383
 
456
 
384
perl jats_buildlinux [options] source_files+
457
perl jats_buildlinux [options] source_files+
385
 
458
 
386
 Options:
459
 Options:               
387
    -help              - brief help message
460
    -help                 - brief help message
388
    -help -help        - Detailed help message
461
    -help -help           - Detailed help message
389
    -man               - Full documentation
462
    -man                  - Full documentation
390
    -Output=path       - Path to the output file
463
    -Output=path          - Path to the output file
391
    -Kernel=path       - Path to the Kernel Headers
464
    -Kernel=path          - Path to the Kernel Headers
392
    -GccPath=path      - Path to the gcc compiler to use
465
    -GccPath=path         - Path to the gcc compiler to use
393
    -Arch=name         - Architecture name
466
    -Arch=name            - Architecture name
394
    -Driver=name       - Base name of the driver to build
467
    -Driver=name          - Base name of the driver to build
395
    -LeaveTmp=num      - Leave tmp files after build
468
    -LeaveTmp=num         - Leave tmp files after build
396
    -Verbose=num       - Verbose command output
469
    -Verbose=num          - Verbose command output
397
    -Type=[P|D]        - Type of build
470
    -Type=[P|D]           - Type of build
398
    -Platform=name     - Target Platform
471
    -Platform=name        - Target Platform
399
    -Define=text       - Definitions to pass to compiler
472
    -Define=text          - Definitions to pass to compiler
400
    -Incdir=path       - Extend the header file search path
473
    -Incdir=path          - Extend the header file search path
-
 
474
    -LocalBinDir=path     - Path to store Module.symvers
-
 
475
    -ExternalModule=name  - Name of an external module
401
    
476
    -Clean                - Clean up generated files
402
 
477
 
403
=head1 OPTIONS
478
=head1 OPTIONS
404
 
479
 
405
=over 8
480
=over 8
406
 
481