Skip to content

Commit

Permalink
Make precompiled headers optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrueger committed Feb 2, 2016
1 parent 225b8f7 commit 08092c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/greetings/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ include $(TOP)/build/header.mk

products_$(d) := helloworld goodbyeworld

helloworld_precompiled_header_$(d) := helloworld.hpp
helloworld_precompiled_$(d) := helloworld.hpp
helloworld_sources_$(d) := helloworld.cpp
helloworld_target_dir_$(d) := bin
helloworld_cxx_flags_$(d) := -O2
helloworld_ld_flags_$(d) :=

goodbyeworld_precompiled_header_$(d) := goodbyeworld.hpp
goodbyeworld_precompiled_$(d) :=
goodbyeworld_sources_$(d) := goodbyeworld.cpp
goodbyeworld_target_dir_$(d):= bin
goodbyeworld_cxx_flags_$(d) := -g -O0
Expand Down
6 changes: 3 additions & 3 deletions footer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ define RECIPES
__odir := $(BUILD_DIR)/$(d)/$$(__t)
__tdir := $(BUILD_DIR)/$($(strip $1)_target_dir_$(d))
__qtgt := $$(__tdir)/$$(__t)
$$(__t)_pch_$(d) := $$($$(__t)_precompiled_header_$(d):%.hpp=%.hpp.pch)
$$(__t)_pch_$(d) := $$($$(__t)_precompiled_$(d):%.hpp=%.hpp.pch)
$$(__t)_pch_$(d) := $$($$(__t)_pch_$(d):%=$(BUILD_DIR)/$(d)/$$(__t)/%)
$$(__t)_objects_$(d) := $$($$(__t)_sources_$(d):%.cpp=%.o)
$$(__t)_objects_$(d) := $$($$(__t)_objects_$(d):%.c=%.o)
$$(__t)_objects_$(d) := $$($$(__t)_objects_$(d):%=$(BUILD_DIR)/$(d)/$$(__t)/%)
$$(__t)_deps_$(d) := $$($$(__t)_sources_$(d):%.cpp=%.d)
$$(__t)_deps_$(d) := $$($$(__t)_deps_$(d):%.c=%.d)
$$(__t)_deps_$(d) += $$($$(__t)_precompiled_header_$(d):%.hpp=%.d)
$$(__t)_deps_$(d) += $$($$(__t)_precompiled_$(d):%.hpp=%.d)
$$(__t)_deps_$(d) := $$($$(__t)_deps_$(d):%=$(BUILD_DIR)/$(d)/$$(__t)/%)
$$(__odir) $$(__tdir)::
$(VERBOSE)mkdir -p $$@
$$(__qtgt): $$($$(__t)_objects_$(d)) | $$(__tdir)
$(CXX_LD_RECIPE)
$$(__qtgt): c_local_flags := $$($$(__t)_c_flags_$(d))
$$(__qtgt): cxx_local_flags := $$($$(__t)_cxx_flags_$(d))
$$(__qtgt): cxx_local_pch := $$($$(__t)_pch_$(d))
$$(__qtgt): cxx_local_pch := $$($$(__t)_pch_$(d):%=-include-pch %)
$$(__qtgt): ld_local_flags := $$($$(__t)_ld_flags_$(d))
$$(__odir)/%.hpp.pch: $(d)/src/%.hpp
$(PCH_RECIPE)
Expand Down
4 changes: 2 additions & 2 deletions rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ endef
define CXX_RECIPE
@echo [C++] $$<
$(VERBOSE)mkdir -p $$(dir $$@)
$(VERBOSE)$(CXX) $(CXX_FLAGS) $$(cxx_local_flags) -include-pch $$(cxx_local_pch) -c -MM -MT $$@ -MF $$(patsubst %.o,%.d,$$@) $$<
$(VERBOSE)$(CXX) $(CXX_FLAGS) $$(cxx_local_flags) -include-pch $$(cxx_local_pch) -c -o $$@ $$<
$(VERBOSE)$(CXX) $(CXX_FLAGS) $$(cxx_local_flags) $$(cxx_local_pch) -c -MM -MT $$@ -MF $$(patsubst %.o,%.d,$$@) $$<
$(VERBOSE)$(CXX) $(CXX_FLAGS) $$(cxx_local_flags) $$(cxx_local_pch) -c -o $$@ $$<
endef

define CXX_LD_RECIPE
Expand Down

0 comments on commit 08092c5

Please sign in to comment.