178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar/* 278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Copyright (C) 2007-2008 ARM Limited 378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Licensed under the Apache License, Version 2.0 (the "License"); 578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * you may not use this file except in compliance with the License. 678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * You may obtain a copy of the License at 778e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 878e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * http://www.apache.org/licenses/LICENSE-2.0 978e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1078e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * Unless required by applicable law or agreed to in writing, software 1178e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * distributed under the License is distributed on an "AS IS" BASIS, 1278e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1378e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * See the License for the specific language governing permissions and 1478e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * limitations under the License. 1578e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar * 1678e52bfac041d71ce53b5b13c2abf78af742b09dLajos Molnar */ 170c1bc742181ded4930842b46e9507372f0b1b963James Dong#!/usr/bin/perl 180c1bc742181ded4930842b46e9507372f0b1b963James Dong# 190c1bc742181ded4930842b46e9507372f0b1b963James Dong# 200c1bc742181ded4930842b46e9507372f0b1b963James Dong# File Name: build_vc.pl 210c1bc742181ded4930842b46e9507372f0b1b963James Dong# OpenMAX DL: v1.0.2 220c1bc742181ded4930842b46e9507372f0b1b963James Dong# Revision: 12290 230c1bc742181ded4930842b46e9507372f0b1b963James Dong# Date: Wednesday, April 9, 2008 240c1bc742181ded4930842b46e9507372f0b1b963James Dong# 250c1bc742181ded4930842b46e9507372f0b1b963James Dong# 260c1bc742181ded4930842b46e9507372f0b1b963James Dong# 270c1bc742181ded4930842b46e9507372f0b1b963James Dong# 280c1bc742181ded4930842b46e9507372f0b1b963James Dong# This file builds the OpenMAX DL vc domain library omxVC.o. 290c1bc742181ded4930842b46e9507372f0b1b963James Dong# 300c1bc742181ded4930842b46e9507372f0b1b963James Dong 310c1bc742181ded4930842b46e9507372f0b1b963James Donguse File::Spec; 320c1bc742181ded4930842b46e9507372f0b1b963James Donguse strict; 330c1bc742181ded4930842b46e9507372f0b1b963James Dong 340c1bc742181ded4930842b46e9507372f0b1b963James Dongmy ($CC, $CC_OPTS, $AS, $AS_OPTS, $LIB, $LIB_OPTS, $LIB_TYPE); 350c1bc742181ded4930842b46e9507372f0b1b963James Dong 360c1bc742181ded4930842b46e9507372f0b1b963James Dong$CC = 'armcc'; 370c1bc742181ded4930842b46e9507372f0b1b963James Dong$CC_OPTS = '--no_unaligned_access --cpu Cortex-A8 -c'; 380c1bc742181ded4930842b46e9507372f0b1b963James Dong$AS = 'armasm'; 390c1bc742181ded4930842b46e9507372f0b1b963James Dong$AS_OPTS = '--no_unaligned_access --cpu Cortex-A8'; 400c1bc742181ded4930842b46e9507372f0b1b963James Dong# $LIB = 'armlink'; 410c1bc742181ded4930842b46e9507372f0b1b963James Dong# $LIB_OPTS = '--partial -o'; 420c1bc742181ded4930842b46e9507372f0b1b963James Dong# $LIB_TYPE = '.o'; 430c1bc742181ded4930842b46e9507372f0b1b963James Dong$LIB = 'armar'; 440c1bc742181ded4930842b46e9507372f0b1b963James Dong$LIB_OPTS = '--create -r'; 450c1bc742181ded4930842b46e9507372f0b1b963James Dong$LIB_TYPE = '.a'; 460c1bc742181ded4930842b46e9507372f0b1b963James Dong 470c1bc742181ded4930842b46e9507372f0b1b963James Dong#------------------------ 480c1bc742181ded4930842b46e9507372f0b1b963James Dong 490c1bc742181ded4930842b46e9507372f0b1b963James Dongmy (@headerlist, @filelist, $hd, $file, $ofile, $command, $objlist, $libfile, $h); 500c1bc742181ded4930842b46e9507372f0b1b963James Dong 510c1bc742181ded4930842b46e9507372f0b1b963James Dong# Define the list of directories containing included header files. 520c1bc742181ded4930842b46e9507372f0b1b963James Dong@headerlist = qw(api vc/api vc/m4p2/api vc/m4p10/api); 530c1bc742181ded4930842b46e9507372f0b1b963James Dong 540c1bc742181ded4930842b46e9507372f0b1b963James Dong# Define the list of source files to compile. 550c1bc742181ded4930842b46e9507372f0b1b963James Dongopen(FILES, '<filelist_vc.txt') or die("Can't open source file list\n"); 560c1bc742181ded4930842b46e9507372f0b1b963James Dong@filelist = <FILES>; 570c1bc742181ded4930842b46e9507372f0b1b963James Dongclose(FILES); 580c1bc742181ded4930842b46e9507372f0b1b963James Dong 590c1bc742181ded4930842b46e9507372f0b1b963James Dong# Fix the file separators in the header paths 600c1bc742181ded4930842b46e9507372f0b1b963James Dongforeach $h (@headerlist) 610c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 620c1bc742181ded4930842b46e9507372f0b1b963James Dong $h = File::Spec->canonpath($h); 630c1bc742181ded4930842b46e9507372f0b1b963James Dong} 640c1bc742181ded4930842b46e9507372f0b1b963James Dong 650c1bc742181ded4930842b46e9507372f0b1b963James Dong# Create the include path to be passed to the compiler 660c1bc742181ded4930842b46e9507372f0b1b963James Dong$hd = '-I' . join(' -I', @headerlist); 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James Dong# Create the build directories "/lib/" and "/obj/" (if they are not there already) 690c1bc742181ded4930842b46e9507372f0b1b963James Dongmkdir "obj", 0777 if (! -d "obj"); 700c1bc742181ded4930842b46e9507372f0b1b963James Dongmkdir "lib", 0777 if (! -d "lib"); 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong$objlist = ''; 730c1bc742181ded4930842b46e9507372f0b1b963James Dong 740c1bc742181ded4930842b46e9507372f0b1b963James Dong# Compile each file 750c1bc742181ded4930842b46e9507372f0b1b963James Dongforeach $file (@filelist) 760c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 770c1bc742181ded4930842b46e9507372f0b1b963James Dong my $f; 780c1bc742181ded4930842b46e9507372f0b1b963James Dong my $base; 790c1bc742181ded4930842b46e9507372f0b1b963James Dong my $ext; 800c1bc742181ded4930842b46e9507372f0b1b963James Dong my $objfile; 810c1bc742181ded4930842b46e9507372f0b1b963James Dong 820c1bc742181ded4930842b46e9507372f0b1b963James Dong chomp($file); 830c1bc742181ded4930842b46e9507372f0b1b963James Dong $file = File::Spec->canonpath($file); 840c1bc742181ded4930842b46e9507372f0b1b963James Dong 850c1bc742181ded4930842b46e9507372f0b1b963James Dong (undef, undef, $f) = File::Spec->splitpath($file); 860c1bc742181ded4930842b46e9507372f0b1b963James Dong $f=~s/[\n\f\r]//g; # Remove any end-of-line characters 870c1bc742181ded4930842b46e9507372f0b1b963James Dong 880c1bc742181ded4930842b46e9507372f0b1b963James Dong if(($base, $ext) = $f =~ /(.+)\.(\w)$/) 890c1bc742181ded4930842b46e9507372f0b1b963James Dong { 900c1bc742181ded4930842b46e9507372f0b1b963James Dong $objfile = File::Spec->catfile('obj', $base.'.o'); 910c1bc742181ded4930842b46e9507372f0b1b963James Dong 920c1bc742181ded4930842b46e9507372f0b1b963James Dong if($ext eq 'c') 930c1bc742181ded4930842b46e9507372f0b1b963James Dong { 940c1bc742181ded4930842b46e9507372f0b1b963James Dong $objlist .= "$objfile "; 950c1bc742181ded4930842b46e9507372f0b1b963James Dong $command = $CC.' '.$CC_OPTS.' '.$hd.' -o '.$objfile.' '.$file; 960c1bc742181ded4930842b46e9507372f0b1b963James Dong print "$command\n"; 970c1bc742181ded4930842b46e9507372f0b1b963James Dong system($command); 980c1bc742181ded4930842b46e9507372f0b1b963James Dong } 990c1bc742181ded4930842b46e9507372f0b1b963James Dong elsif($ext eq 's') 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong $objlist .= "$objfile "; 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong $command = $AS.' '.$AS_OPTS.' '.$hd.' -o '.$objfile.' '.$file; 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong print "$command\n"; 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong system($command); 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong print "Ignoring file: $f\n"; 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong die "No file extension found: $f\n"; 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong# Do the final link stage to create the libraries. 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong$libfile = File::Spec->catfile('lib', 'omxVC'.$LIB_TYPE); 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong$command = $LIB.' '.$LIB_OPTS.' '.$libfile.' '.$objlist; 1200c1bc742181ded4930842b46e9507372f0b1b963James Dongprint "$command\n"; 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong(system($command) == 0) and print "Build successful\n"; 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong 129