dmuck / redding-stan

ReddingStan smuggles log probabilities and gradients out of Stan models
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Create build rules using `make` #4

Closed syclik closed 2 years ago

syclik commented 2 years ago

This PR adds rules to the Makefile that will enable building an executable from a Stan file. This should work on both Linux and Mac.

Rules added to the Makefile:

This allows an executable to be created and runable.

I didn't include an example in the code, but as an example, you can copy any .stan program into the working directory. Let's call it model.stan for example. We should be able to install it by typing:

  1. make install. This will install bin/stanc, get the submodules, build the TBB libraries, and build src/main.o from src/main.cpp.
  2. make model. This will build the model executable by first generating the .cpp file from .stan file, compile a .o from the .cpp file, then linking it all together into an executable.

Note: if we get fancy, we could load the library dynamically at runtime instead of creating a new executable.

syclik commented 2 years ago

@dmuck, can you check to see that this works for you? We can always upgrade some of the make stuff later. I didn't pass through the compiler all the way to building the TBB library.

dmuck commented 2 years ago

This worked on my Linux machine. Thanks for putting this together!