I am trying to copy files befoe compilation (I have two source files with same name so I copy the files to a files with a different name) and delete them at the end of the MAKEFILE. I am trying to do the folliwng but probably there is mismatch in the execution order. How can I do it correctly?
all: copy_dup_files $(dst_dir) $(APP_TARGET_LIB) delete_dup_files
copy_dup_files:
@echo "COPYING DUP FILES"
$(shell cp /aaa/hmac.c /aaa/hmac1.c )
$(shell cp /bbb/hmac.c /bbb/hmac2.c )
delete_dup_files:
@echo "DELETING DUP FILES"
$(shell rm /aaa/hmac1.c )
$(shell rm /bbb/hmac2.c )
Thanks
答案 0 :(得分:2)
The purpose of pjsua_media.c .Shutting down media..
is to produce an output which Make reads. The recipe lines should not have this construct at all.
$(shell)
So, all the # this is evaluated when the Makefile is read
value := $(shell echo "Use the shell to produce a value for a variable")
# this is evaluated when you say "make foo"
foo:
echo 'No $$(shell ...) stuff here'
stuff in your attempt gets evaluated when the $(shell ...)
is read, but before any actual target is executed.
答案 1 :(得分:0)
您的makefile试图说/aaa/hmac1.c
取决于/aaa/hmac.c
。
因此我们有:
/aaa/hmac1.c: /aaa/hmac.c
cp $< $@
/bbb/hmac2.c: /bbb/hmac.c
cp $< $@
/aaa/hmac1.o /bbb/hmac2.o: %.o: %.c
gcc $< -o $@
myprog: /aaa/hmac1.o /bbb/hmac2.o
gcc $^ -o $@
这是干净且并行的安全(对任何makefile的一个很好的测试)。
您可以进行无数的样式改进,例如
.h
文件等).o
和临时.c
)放在他们自己的构建文件夹中和C。 &安培; C。