Skip to content

Commit

Permalink
Merge pull request #1187 from stan-dev/makefile/split-object-file-build
Browse files Browse the repository at this point in the history
Split building of .o file from executable
  • Loading branch information
WardBrian authored Sep 6, 2023
2 parents 3f05dfb + a05424c commit 5bcf7c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ src/docs/**/*.pdf
output.csv
output*.csv
*.d
*.o
# gdb
.gdb_history
15 changes: 11 additions & 4 deletions make/program
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ endif

%.d: %.hpp

.PRECIOUS: %.hpp
%$(EXE) : %.hpp $(CMDSTAN_MAIN_O) $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS) $(PRECOMPILED_MODEL_HEADER)
ifeq ($(KEEP_OBJECT), true)
.PRECIOUS: %.o
endif

%.o : %.hpp
@echo ''
@echo '--- Compiling, linking C++ code ---'
@echo '--- Compiling C++ code ---'
$(COMPILE.cpp) $(CXXFLAGS_PROGRAM) -x c++ -o $(subst \,/,$*).o $(subst \,/,$<)

%$(EXE) : %.o $(CMDSTAN_MAIN_O) $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS) $(PRECOMPILED_MODEL_HEADER)
@echo ''
@echo '--- Linking model ---'
$(LINK.cpp) $(subst \,/,$*.o) $(CMDSTAN_MAIN_O) $(LDLIBS) $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS) $(subst \,/,$(OUTPUT_OPTION))
$(RM) $(subst \,/,$*).o

ifeq ($(OS),Windows_NT)
ifeq (,$(findstring tbb.dll, $(notdir $(shell where tbb.dll))))
@echo 'Intel TBB is not in PATH.'
Expand Down
2 changes: 1 addition & 1 deletion make/tests
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ TEST_MODELS := $(wildcard src/test/test-models/*.stan)

.PHONY: test-models-hpp
test-models-hpp:
$(MAKE) $(patsubst %.stan,%.hpp,$(TEST_MODELS))
$(MAKE) $(patsubst %.stan,%$(EXE),$(TEST_MODELS))

##
# Tests that depend on compiled models
##
Expand Down

0 comments on commit 5bcf7c2

Please sign in to comment.