Skip to content

Commit 7ff95a4

Browse files
authored
Merge pull request #1217 from stan-dev/makefile/missing-submodules-cleanup
Improve missing submodule logic
2 parents 8efdfaa + 15963cc commit 7ff95a4

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

make/command

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ifeq ($(CMDSTAN_SUBMODULES),1)
21
bin/cmdstan/stansummary.o : src/cmdstan/stansummary_helper.hpp
32
bin/cmdstan/%.o : src/cmdstan/%.cpp
43
@mkdir -p $(dir $@)
@@ -11,5 +10,3 @@ bin/print$(EXE) bin/stansummary$(EXE) bin/diagnose$(EXE) : LDLIBS_MPI =
1110
bin/print$(EXE) bin/stansummary$(EXE) bin/diagnose$(EXE) : bin/%$(EXE) : bin/cmdstan/%.o $(TBB_TARGETS)
1211
@mkdir -p $(dir $@)
1312
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)
14-
15-
endif

make/stanc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ endef
99

1010
# if nothing was set to $(OS) that means that the Stan Math submodule is missing
1111
OS ?= missing-submodules
12-
CMDSTAN_SUBMODULES = 1
1312
STANC_DL_RETRY = 5
1413
STANC_DL_DELAY = 10
1514
STANC3_TEST_BIN_URL ?=
@@ -38,14 +37,11 @@ else ifeq ($(OS),Linux)
3837
endif
3938
endif
4039

41-
else ifeq ($(OS),missing-submodules)
42-
CMDSTAN_SUBMODULES = 0
4340
else
4441
$(error Cannot detect OS properly. $n This will impede automatically downloading the correct stanc. $n Please visit https://github.com/stan-dev/stanc3/releases and download a stanc binary for your OS and place it in ./bin/stanc. $n )
4542
endif
4643

47-
# bin/stanc build rules - requires stan, stan_math submodules in place
48-
ifeq ($(CMDSTAN_SUBMODULES),1)
44+
# bin/stanc build rules
4945
ifneq ($(STANC3),)
5046
# build stanc3 from local installation
5147
bin/stanc$(EXE) : $(call findfiles,$(STANC3)/src/,*.ml*) $(STANC#)
@@ -91,5 +87,4 @@ else
9187
curl -L https://github.com/stan-dev/stanc3/releases/download/$(STANC3_VERSION)/$(OS_TAG)$(ARCH_TAG)-stanc -o bin/stanc$(EXE) --retry $(STANC_DL_RETRY) --retry-delay $(STANC_DL_DELAY)
9288
chmod +x bin/stanc$(EXE)
9389
endif
94-
endif
9590
# end bin/stanc build rules

makefile

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ else
141141
PRECOMPILED_MODEL_HEADER=
142142
endif
143143

144-
-include $(MATH)make/compiler_flags
145-
-include $(MATH)make/dependencies
146-
-include $(MATH)make/libraries
144+
include $(MATH)make/compiler_flags
145+
include $(MATH)make/dependencies
146+
include $(MATH)make/libraries
147147
include make/stanc
148148
include make/program
149149
include make/tests
@@ -262,7 +262,6 @@ build-mpi: $(MPI_TARGETS)
262262
@echo ''
263263
@echo '--- boost mpi bindings built ---'
264264

265-
ifeq ($(CMDSTAN_SUBMODULES),1)
266265
.PHONY: build
267266
build: bin/stanc$(EXE) $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS) $(CMDSTAN_MAIN_O) $(PRECOMPILED_MODEL_HEADER) bin/stansummary$(EXE) bin/print$(EXE) bin/diagnose$(EXE)
268267
@echo ''
@@ -275,17 +274,6 @@ ifeq ($(OS),Windows_NT)
275274
@echo 'to automatically update your user configuration.'
276275
endif
277276
@echo '--- CmdStan v$(CMDSTAN_VERSION) built ---'
278-
else
279-
.PHONY: build
280-
build:
281-
@echo 'ERROR: Missing Stan submodules.'
282-
@echo 'Please run the following to fix:'
283-
@echo ''
284-
@echo 'git submodule update --init --recursive'
285-
@echo ''
286-
@echo 'And try building again'
287-
@exit 1
288-
endif
289277

290278
.PHONY: install-tbb
291279
install-tbb: $(TBB_TARGETS)
@@ -352,3 +340,20 @@ print-% : ; @echo $* = $($*)
352340

353341
.PHONY: clean-build
354342
clean-build: clean-all build
343+
344+
345+
##
346+
# This is only run if the `include` statements earlier fail to find a file.
347+
# We assume that means the submodule is missing
348+
##
349+
$(MATH)make/% :
350+
@echo 'ERROR: Missing Stan submodules.'
351+
@echo 'We tried to find the Stan Math submodule at:'
352+
@echo ' $(MATH)'
353+
@echo ''
354+
@echo 'The most likely source of the problem is CmdStan was cloned without'
355+
@echo 'the --recursive flag. To fix this, run the following command:'
356+
@echo ' git submodule update --init --recursive'
357+
@echo ''
358+
@echo 'And try building again'
359+
@exit 1

0 commit comments

Comments
 (0)