Gnu Makefile - Handling dependencies

后端 未结 12 2512
滥情空心
滥情空心 2021-02-07 20:24

What approach do C++ programmers on Unix platform use to create and manage Makefiles?

I was using hand made Makefiles for my projects but they don\'t handle header file

12条回答
  •  温柔的废话
    2021-02-07 20:52

    1. I use that approach too and can't praise it highly enough. And I write my makefiles by hand and reuse them a lot on new projects.
    2. .The expression "s/ *\\$//" will work outside the context of Make. Within a makefile it doesn't work because Make tries to interpret "$/" before handing the result to the shell. So you must use "s/ *\\$$//" (note the extra $) within the makefile, but this won't work outside the context of Make (so testing it is a slight pain).



    EDIT:

    I've tried your makefile, and that sed statement seems to remove trailing backslashes just fine. Try something simpler, like this:

    backslash:
        @echo " \\" > $@
    
    test: backslash
        @echo without sed:
        @cat backslash
        @echo with sed:
        @sed -e 's/ *\\$$//' < backslash
    



    EDIT: All right, now I'm hooked. Could you try these experiments and tell us the results?

    Change the last character to 'z'      :  s/.$/z/
    Change a trailing backslash to 'z'    :  s/\\$/z/
    Change a trailing backslash to 'z'    :  sm\\$mzm
    Delete a trailing backslash           :  s/\\$//
    Delete spaces and a trailing backslash:  s/ *\\$//
    Try all of these inside and outside of Make, with '$' and '$$'.
    

提交回复
热议问题