Skip to content

Commit

Permalink
Update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoys authored Aug 28, 2023
1 parent c09bc7e commit 5b5a9fe
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ endif

EXEC = smilei

default: $(EXEC) $(EXEC)_test
default: $(PYHEADERS) $(EXEC) $(EXEC)_test

#-----------------------------------------------------
# Header
Expand Down Expand Up @@ -303,6 +303,12 @@ $(BUILD_DIR)/%.d: %.cpp
$(Q) if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)"; fi;
$(Q) $(SMILEICXX) $(CXXFLAGS) -MF"$@" -MM -MP -MT"$@ $(@:.d=.o)" $<

# Calculate dependencies: special for Params.cpp which needs pyh files
$(BUILD_DIR)/src/Params/Params.d: src/Params/Params.cpp $(PYHEADERS)
@echo "Checking dependencies for $<"
$(Q) if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)"; fi;
$(Q) $(SMILEICXX) $(CXXFLAGS) -MF"$@" -MM -MP -MT"$@ $(@:.d=.o)" $<

ifeq ($(findstring icpc, $(COMPILER_INFO)), icpc)

$(BUILD_DIR)/src/Diagnostic/DiagnosticScalar.o : src/Diagnostic/DiagnosticScalar.cpp
Expand Down Expand Up @@ -341,19 +347,15 @@ $(EXEC)_test : $(OBJS:Smilei.o=Smilei_test.o)
$(Q) $(SMILEICXX) $(OBJS:Smilei.o=Smilei_test.o) -o $(BUILD_DIR)/$@ $(LDFLAGS)
$(Q) cp $(BUILD_DIR)/$@ $@

# Avoid to check dependencies and to create .pyh if not necessary
FILTER_RULES=clean distclean help env debug doc tar happi uninstall_happi
ifeq ($(filter-out $(wildcard print-*),$(MAKECMDGOALS)),)
ifeq ($(filter $(FILTER_RULES),$(MAKECMDGOALS)),)
# Let's try to make the next lines clear: we include $(DEPS) and pygenerator
-include $(DEPS) pygenerator
# and pygenerator will create all the $(PYHEADERS) (which are files)
pygenerator : $(PYHEADERS)
endif
endif

# these are not file-related rules
.PHONY: pygenerator $(FILTER_RULES)
PHONY_RULES=clean distclean help env debug doc tar happi uninstall_happi
.PHONY: $(PHONY_RULES)

# Check dependencies only when necessary
GOALS = $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default)
ifneq ($(filter-out $(PHONY_RULES) print-%, $(GOALS)),)
-include $(DEPS)
endif

#-----------------------------------------------------
# Doc rules
Expand Down

0 comments on commit 5b5a9fe

Please sign in to comment.