Skip to content

Commit

Permalink
Merge pull request #140 from stan-dev/feature/makefile_issue
Browse files Browse the repository at this point in the history
updating make targets for models
  • Loading branch information
syclik committed Jul 10, 2013
2 parents 7a0e4ef + a091d22 commit 0547ad6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
44 changes: 44 additions & 0 deletions make/make_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
STAN_HOME = /Users/daniel/dev/stan
STAN_LIB = $(STAN_HOME)/lib
STAN_BIN = $(STAN_HOME)/bin

#CC = g++
CC = clang++
STANC = $(STAN_BIN)/stanc
AR = ar

O = 3
CFLAGS = -g -march=native -I$(STAN_HOME)/src -I$(STAN_LIB)/eigen_3.1.3 -I$(STAN_LIB)/boost_1.53.0 -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS
LDFLAGS = -L$(STAN_BIN) -lstan
EXE =
PATH_SEPARATOR = /

-include $(STAN_HOME)/make/detect_cc
-include $(STAN_HOME)/make/os_detect

MODEL_FILES = $(shell find . -type f -name '*.stan')
SRC_FILES = $(addsuffix .cpp,$(basename $(MODEL_FILES)))
OBJ_FILES = $(addsuffix .o,$(basename $(MODEL_FILES)))
EXE_FILES = $(addsuffix $(EXE),$(basename $(MODEL_FILES)))

models: normal

clean:
rm -f $(SRC_FILES) $(OBJ_FILES) $(EXE_FILES)

.PRECIOUS: %.o %.cpp
%.o : %.cpp
@echo ''
@echo '--- Compiling C++ code ---'
$(COMPILE.c) -O$O $(OUTPUT_OPTION) $<

$(patsubst %.stan,%,$(wildcard $(addsuffix .stan,$(MAKECMDGOALS)))) : %$(EXE): %.o
@echo ''
@echo '--- Linking C++ model ---'
$(LINK.c) -O$O $(OUTPUT_OPTION) $< $(LDLIBS)

%.cpp : %.stan
@echo ''
@echo '--- Translating Stan graphical model to C++ code ---'
$(STANC) $< --o=$@

8 changes: 7 additions & 1 deletion make/models
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
MODEL_HEADER := src/stan/model/model_header.hpp

.PRECIOUS: %.cpp %.o
%$(EXE): %.o bin/libstan.a
$(patsubst %.stan,%,$(wildcard $(addsuffix .stan,$(MAKECMDGOALS)))) : %$(EXE): %.o bin/libstan.a
@echo ''
@echo '--- Linking C++ model ---'
$(LINK.c) -O$O $(OUTPUT_OPTION) $< $(LDLIBS)

%.exe: %.o bin/libstan.a
@echo ''
@echo '--- Linking C++ model ---'
$(LINK.c) -O$O $(OUTPUT_OPTION) $< $(LDLIBS)


.PRECIOUS: %.cpp
%.cpp : %.stan $(MODEL_HEADER)$(PCH) bin/stanc$(EXE)
@echo ''
Expand Down
3 changes: 0 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ PATH_SEPARATOR = /
##
-include make/os_detect

%$(EXE) : %.o %.cpp bin/libstan.a
$(LINK.c) -O$O $(OUTPUT_OPTION) $< $(LDLIBS)

##
# Tell make the default way to compile a .o file.
##
Expand Down

0 comments on commit 0547ad6

Please sign in to comment.