如何在makefile规则中更改文件名

时间:2017-11-07 11:33:10

标签: makefile

使用gcc生成dep没有问题

if(!empty($recurring_duration)){
                                try {
                                    $plan = \Stripe\Plan::retrieve($planname);
                                } catch (Error\InvalidRequest $exception) {
                                    $plan = \Stripe\Plan::create(array(
                                        "name" => "Basic Plan",
                                        "id" => $planname,    
                                        "interval" => "$recurring_duration",
                                        "currency" => strtolower($currency),
                                        "amount" => $amount,
                                    ));
                                }

                                $plan = \Stripe\Plan::create(array(
                                        "name" => "Basic Plan",
                                        "id" => $planname,    
                                        "interval" => "$recurring_duration",
                                        "currency" => strtolower($currency),
                                        "amount" => $amount,
                                ));
                            } 

$customer = \Stripe\Customer::create(array(
                                'email'     => $email,
                                'source'    => $token
                            ));

                            if(!empty($recurring_duration)){

                                $charge = \Stripe\Subscription::create(array(
                                    "customer" => $customer->id,
                                    "items" => array(
                                      array(
                                        "plan" => $planname,
                                      ),
                                    ),
                                ));

                            }else{

                                $charge = \Stripe\Charge::create(array(
                                                'customer'    => $customer->id,
                                                'amount'      => $amount,
                                                'currency'    => strtolower($currency),
                                                'description' => '',
                                        )
                                ); 

                            }

                            $val = BSP_add_form_data($charge);

现在我更改为armcc并且需要以下选项来生成%.o: %.c $(CC) -MMD -c $< -o $< ,我可以运行此单个命令来生成.d

.d

如何使armcc适应gcc代码部分?我尝试下面的代码,但没有帮助,它没有生成armcc --md -depend=a.d -c a.c -o a.o 文件

.d

更新

我使用以下来自anwser的代码:

%.o: %.c
    armcc --md -depend=$(patsubst %o, %.d, $@) -c @< -o $@

并且仍然没有%.o: %.c armcc --md -depend=$(@:%.o=%.d) -c @< -o $@ 输出,我检查控制台:

.d

我在编译期间发现,即使我的armcc -c -o a1.o a1.c armcc -c -o a2.o a2.c armcc -c -o a3.o a3.c armcc -c -o main.o main.c armlink -o test a1.o a2.o a3.o main.o --md选项未被应用?

1 个答案:

答案 0 :(得分:0)

%.o: %.c
    armcc --md -depend=$(@:%.o=%.d) -c @< -o $@

这只会告诉GNU make将object.o替换为object.d

$@是您的目标 %.o=%.d返回目标文件的* .d名称。