If you absolutely have to use gnu make and can’t use something else like Boost.Build or you don’t want to invest in the infrastructure for a small project here’s some useful macros:
exec = output=$$($(1) 2>&1) || (ret=$$?; echo -e "$(1)\n$${output}"; exit $$ret); configure = echo "configure in $(1)"; $(call exec,cd $(1) && ./configure) make = echo "make in $(1) $(2)"; $(call exec,make -C $(1) $(2)) compile-cxx = echo "compile-c++ $(2) -> $$(basename $(1))"; \ $(call exec,g++ -fPIC -o $(1) -c $(2) -Wall ${INCS} ${CXXFLAGS}) link-shared = echo "link-shared $$(basename $(1))"; \ $(call exec,g++ -fPIC -shared -o $(1) $(2) $(3)) %.o: %.cpp Makefile @$(call compile-cxx,$@,$<)
No comments:
Post a Comment