c++ - makefile to link each other -
i have multiple unit test files in dir test, "test_a.cc" "test_b.cc" "test_c.cc"(each 1 has main function), , want build every 1 executable file, "test_a", "test_b", "test_c", each 1 executable file.so how write general makefile achieve goal?
currently, using makefile this, want discard '.out' suffix:
sources = $(shell find . -name '*.cc') objects = $(sources:.cc=.o) executable = $(sources:.cc=.out) : $(executable) %.out:%.cc $(cc) $(cflags) $< -o $@
"i want discard '.out' suffix"
the simplest way achieve renaming executable file after build:
%.out:%.cc $(cc) $(cflags) $< -o $@ mv $@ $(patsubst %.out,%,$@)
another way leave out .out
sources = $(shell find . -name '*.cc') objects = $(sources:.cc=.o) executable = $(sources:.cc=) : $(executable) % : %.cc $(cc) $(cflags) $< -o $@
Comments
Post a Comment