Create Makefiles for easier compilation

This commit is contained in:
Cory Balaton 2023-09-24 15:39:37 +02:00
parent f186b52548
commit 58c58a97af
No known key found for this signature in database
GPG Key ID: 3E5FCEBFD80F432B
4 changed files with 74 additions and 5 deletions

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
MAKE=make
.PHONY: code latex docs
code:
$(MAKE) -C src
latex:
$(MAKE) -C latex
docs:
$(MAKE) -C src doxygen

View File

@ -4,7 +4,7 @@
- [Project](https://anderkve.github.io/FYS3150/book/projects/project2.html) - [Project](https://anderkve.github.io/FYS3150/book/projects/project2.html)
## Compile and run ## Compile and run C++ programs
Compiling and linking is done using Make, make sure you are in the root folder. To create executable files, run shell commands Compiling and linking is done using Make, make sure you are in the root folder. To create executable files, run shell commands
@ -18,13 +18,61 @@ To run `script-name`
./main ./main
``` ```
There are two ways of compiling the code.
The first way is to go into the src directory and compile
```shell
cd src && make
```
or you could use make in the project directory
```shell
make code
```
and it will compile everything with you needing to move into **src**.
You can run any of the compiled programs by going into the src directory
and then doing
```shell
./program-name
```
## Generate plots ## Generate plots
To generate plots, the Python scripts is run using To generate plots, you can do
```shell ```shell
python3 <script-name> python3 plot.py
``` ```
The plots will be saved inside [latex/images](../blob/main/latex/images). and the plots will be saved inside [latex/images](latex/images).
## Generate documentation
For this project, we have used Doxygen to generate some nice and readable
documentation for the C++ code.
If you want to generate the documentation you can do
```shell
make docs
```
in the project root, and the documentation will be made into the **docs**
directory.
## Generate project document
If you want to recompile the Pdf file, you can do
```shell
make latex
```
and a Pdf file will be produced inside the **latex** directory.

5
latex/Makefile Normal file
View File

@ -0,0 +1,5 @@
.PHONY: latex
latex:
pdflatex assignment-2.tex

View File

@ -16,7 +16,7 @@ else
endif endif
.PHONY: clean .PHONY: doxygen clean
all: test_suite main all: test_suite main
@ -31,6 +31,10 @@ test_suite: test_suite.o $(LIBOBJS)
%.o: %.cpp %.o: %.cpp
$(CC) -c $^ -o $@ $(DBGFLAG) -I$(INCLUDE) $(CC) -c $^ -o $@ $(DBGFLAG) -I$(INCLUDE)
# Make documentation
doxygen:
doxygen
clean: clean:
rm *.o rm *.o
rm test_suite rm test_suite