compile headers dependencies with makefile

后端 未结 2 676
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 15:47

I am programming an UDP client server application in the C programming language; I want to automatically compile 2 sources files and 3 header files whenever the dependencies

2条回答
  •  别那么骄傲
    2021-01-13 16:22

    You did not say that edit.c includes your two specific headers, but I guess it must, if it links to the objects.

    This is exactly the scenario where makepp plays out one of its strengths: If you follow the convention that for every .o file you need to link there is an include statement of a corresponding name (in your case that would be client_UDP.h & server_UDP.h) then makepp will figure everything out itself, besides detecting the header files as dependencies.

    This even works recursively, so if you had a wrapHeader.c (where there is no corresponding include statement in edit.c), that would get automatically compiled and linked.

    So you don't need a makefile. But if you want to avoid calling makepp edit everytime, then you can create a one-liner

    edit:
    

    You will only need to learn make syntax, if you have more complex requirements. But if you do, there is no limit. Besides doing almost all that GNU make can, there are lots more useful things, and you can even extend your makefiles with some Perl programming.

提交回复
热议问题