Using bash variables in Makefile

前端 未结 3 1232
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 16:58

I want to use the bash timing variables in my makefile for example in my terminal I can do this and it works

 MY_TIME=$SECONDS 
 echo $MY_TIME
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 17:29

    PROGRAM_NAME = myLittleProgram
    
    ...
    
    $(PROGRAM_NAME) : myLittleProgram.o
    

    I know the above works, as it is in my own makefile (program names and object names changed to protect the innocent).


    "Variable references can be used in any context: targets, dependencies, commands, most directives, and new variable values. Here is an example of a common case, where a variable holds the names of all the object files in a program:"

    objects = program.o foo.o utils.o
    program : $(objects)
        cc -o program $(objects)
    
    $(objects) : defs.h
    

    http://web.mit.edu/gnu/doc/html/make_6.html

提交回复
热议问题