从脚本调用make

时间:2011-06-26 15:40:28

标签: bash shell makefile

我有一种情况,我必须经常更改变量后编译.cc文件。 我的脚本更改了.cc文件中的变量

然后我尝试编译它,首先通过说明改为shell脚本中的目录 cd

然后是make。 我的所有shell指令都保存在.sh文件中。

然而,当我运行这个时,我得到了错误

make: *** No targets specified and no makefile found.  Stop.

但是当我手动转到目录并键入make it works。

为什么shell脚本无法使make工作?

编辑我添加了脚本

#! /bin/sh
# simDir=/home/amm/ns-projects/EURANE/Release



simtime=21
high_users=5
low_users=3
rm user_throughput.txt qos_throughput.txt
echo "Iteration,Users, Low, High,Low average,High average, Average cell througput" >> qos_throughput.txt



for(( husers = 1; husers <= $high_users; husers++ ))      ### Outer for loop ###

do

for(( lusers = 1 ; lusers <= $low_users; lusers++ )) ### Inner for loop ###
do                  

                total_users=0
                let total_users=$husers+$lusers
                echo "$total_users $husers $lusers"
                #Configure the sh file
                num_users=0
                cd /home/chanditha/EURANE_multi_cells_itpp/simulation_scripts
                printf -v num_users "NUM_USERS=\"%d\"" $total_users
                rm hsdpa_ftp_4cells.sh
                perl -pe "s/.*/$num_users/ if $. == 5" hsdpa_ftp_4cells_old.sh > hsdpa_ftp_4cells.sh
                chmod u+x hsdpa_ftp_4cells.sh


                #Configure the awk file
                cd /home/chanditha/EURANE_multi_cells_itpp/simulation_scripts/scripts
                awkline=0
                printf -v awkline "class_cuttoff=max_flow-%d;" $husers
                rm tcp_performance_4cells.awk
                perl -pe "s/.*/$awkline/ if $. == 137" tcp_performance_4cells_old.awk > tcp_performance_4cells.awk




                #Change the directory and go to the .cc file
                cd /home/chanditha/ns-allinone-2.30/ns-2.30/umts
                printf -v cut_off "int cut_off = flow_max_-%d;" $husers;
                rm hsdpalink.cc
                perl -pe "s/.*/$cut_off/ if $. == 2109" hsdpalink_old.cc > hsdpalink.cc
                #Make it
                    make clean && make

done

            cd /home/chanditha/EURANE_multi_cells_itpp/simulation_scripts
            ./hsdpa_ftp_4cells_run_all.sh
done

1 个答案:

答案 0 :(得分:1)

这可能需要几次迭代。尝试运行此脚本并告诉我们发生了什么:

cd /home/chanditha/ns-allinone-2.30/ns-2.30/umts
make

此外,您的整个架构听起来不稳定。您使用脚本更改源中的变量,然后重新编译?为了天堂,使用参数文件:脚本写入它,可执行文件读取它。