Makefile pattern rule for no extension?

£可爱£侵袭症+ 提交于 2019-12-02 18:07:46

This looks like a job for a static pattern rule:

$(apps) : % : %.o $(objects)
    $(link)
%: %.o $(objects)
    $(link)

The above should work.

You can limit the scope of the rule by converting it into a static pattern rule, so that it is only considered for your list of targets:

$(apps) : % : %.o $(objects) # only consider this for $(apps) targets
    $(link)

not an answer to what you are looking for , but a reason that might explain why such level of generic code might not yield good results. ....

static patterns rely on the presence of a stem to match and build a dependency chain. pretty much in the same manner as the implicit rules (which are used for targets that dont have any recipie.)

i see what you were trying to achive , making a generic rule that will satisfy all the target checks for object and link in your code.

something like this ::

 % : % : $(rule1)
         echo / generic code ;

so that it gets invoked for all apps in differnt scenarios

since you dont want to add a extension (this becomes the root of some issues ) the issue with this is that the target will get reflected in the dependency as well since there will be no way of differentiating the dependencies form the targets.

hence if you did try that i think you will get here ...

 $ make -nf mk.t
   mk.t:18: *** mixed implicit and static pattern rules.  Stop.

:) , i will give this a try again tomorrow to see if i can get this working in a real generic way. Nice question though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!