makefile - How to run Linux shell commands from GNU make file to setup preconditions for a build target -
my issue in make file want create directory object code before building , cannot find way whithout having impact output of make. also, want in 1 place , not each , every object file.
i have tried this:
build: setup exe.i686 setup: mkdir -p obj exe.i686: $(objs) @echo 'building target: $@' @echo 'invoking: gcc c++ linker' ${gcc_location}/linux/i686/bin/i686-pc-linux-gnu-g++ $(objs) -o "exe.i686" -l... @echo 'finished building target: $@' @echo ' '
where objs object code. if don't run setup first , there no ./obj directory present build fail because of missing directory when trying build object code.
just clear, here example of how 1 object file built:
./obj/cell.o: ${cell_root}/main/cell/cell/src/cell.cc @echo 'building file: $<' @echo 'invoking: gcc c++ compiler' $(gcc_c++_build) -mf"$(@:%.o=%.d)" -mt"$(@:%.o=%.d)" -o "$@" "$<" @echo 'finished building: $<' @echo ' '
i don't want build object code in same directory have make file.
now actual problem. when build tarket "build" first time works fine:
make build
but if build again , there no updates in source code (object code up-to-date) behaves this:
[7:37] [user1] [/local/repo/user1/project_x/test/bin] $ make build mkdir -p obj [7:37] [user1] [/local/repo/user1/project_x/test/bin] $
in situation have liked make return nothing-to-be-done string this:
[7:37] [user1] [/local/repo/user1/project_x/test/bin] $ make build make: nothing done `build'. [7:41] [user1] [/local/repo/user1/project_x/test/bin] $
this have been case if didn't have depend on setup target (which added .phony). alternative each object code file? possible suppose wanted avoid if possible clutters make file quite bit. @ least in opinion.
thanks
your target setup
executed because has no dependency.
you have 2 choices:
(1) make stamp
or use other mechanism there actual dependency. directory can target may incur wrinkles: see http://www.gnu.org/software/make/manual/html_node/prerequisite-types.html example.
modified relevant extract linked article:
$(objs): | obj obj: mkdir $(objdir)
(2) suppress output testing existence:
setup: test -d obj || mkdir -p obj
Comments
Post a Comment