Compare commits

..

5 Commits

Author SHA1 Message Date
Fabian Mujdrica
d8c6e25376 Merge pull request #1 from fabfabfabiiii/features/makefile
Features/makefile
2025-09-12 14:25:48 +02:00
BuildTools
1adff08581 update readme 2025-09-12 14:03:11 +02:00
BuildTools
d12f68d001 add new Make commands 2025-09-12 14:02:37 +02:00
Mujdrica
5ea0bff54e new commands to set Shell 2025-09-10 11:37:20 +02:00
Mujdrica
4b3d9840ef ignore .env file 2025-09-10 11:36:56 +02:00
3 changed files with 104 additions and 9 deletions

3
.gitignore vendored
View File

@@ -60,3 +60,6 @@ Thumbs.db
# Editor-spezifische Dateien (optional) # Editor-spezifische Dateien (optional)
*.swp *.swp
*.swo *.swo
#config files
.env

View File

@@ -1,6 +1,13 @@
.PHONY: help build-thesis build-expose clean clean-paper .PHONY: help build-thesis build-expose clean clean-paper check-variables set-shell set-directory
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
# --- Load .env if it exists (no error if missing) ---
-include .env
# --- Set default directory if not defined ---
DIRECTORY ?= $(shell pwd)
# Variables # Variables
LATEX_DIR = paper LATEX_DIR = paper
LATEX_CONTAINER = texlive/texlive:TL2024-historic LATEX_CONTAINER = texlive/texlive:TL2024-historic
@@ -11,13 +18,14 @@ EXPOSE_SRC = expose.tex
# Colors # Colors
GREEN := \033[1;32m GREEN := \033[1;32m
WHITE := \033[0;37m WHITE := \033[0;37m
GRAY := \033[0;37m
RESET := \033[0m RESET := \033[0m
help: ## Show this help message help: ## Show this help message
@echo "Available commands:" @echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ @grep -E "^[a-zA-Z_-]+:.*?## .*$$" "$(firstword $(MAKEFILE_LIST))" \
| awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)make %-12s$(RESET) $(WHITE)%s$(RESET)\n", $$1, $$2}' \ | sort \
| sort | awk -v GREEN="$(GREEN)" -v RESET="$(RESET)" -v GRAY="$(GRAY)" 'BEGIN {FS=":.*?## "} {printf " %smake %-15s%s %s%s\n", GREEN, $$1, RESET, GRAY, $$2}'
clean: clean-paper ## Remove all auxiliary files (calls clean-paper) clean: clean-paper ## Remove all auxiliary files (calls clean-paper)
@@ -33,10 +41,53 @@ clean-paper: ## Remove LaTeX auxiliary files from the 'paper' directory
$(LATEX_DIR)/*.bcf \ $(LATEX_DIR)/*.bcf \
$(LATEX_DIR)/*.run.xml $(LATEX_DIR)/*.run.xml
build-thesis: clean-paper ## Build the main thesis PDF (dokumentation.tex) using Docker and latexmk build-thesis: clean-paper ## Build the main thesis PDF (dokumentation.tex) using DockerJa, and latexmk
@docker run --rm -v $(PWD)/$(LATEX_DIR):/data -w /data $(LATEX_CONTAINER) \ @docker run --rm -v "$(DIRECTORY)/$(LATEX_DIR):/data" -w //data $(LATEX_CONTAINER) latexmk -pdf $(THESIS_SRC)
latexmk -pdf $(THESIS_SRC)
build-expose: clean-paper ## Build the expose PDF (expose.tex) using Docker and latexmk build-expose: clean-paper ## Build the expose PDF (expose.tex) using Docker and latexmk
@docker run --rm -v $(PWD)/$(LATEX_DIR):/data -w /data $(LATEX_CONTAINER) \ @docker run --rm -v "$(DIRECTORY)/$(LATEX_DIR):/data" -w //data $(LATEX_CONTAINER) latexmk -pdf $(EXPOSE_SRC)
latexmk -pdf $(EXPOSE_SRC)
set-shell: ## Set the shell Make should use
ifeq ($(LOCAL_SHELL),)
@echo "Usage: make set-shell LOCAL_SHELL=<path to shell> [LOCAL_SHELLFLAGS='<flags>']"
@echo "Example: make set-shell LOCAL_SHELL=\"C:/Progra~1/Git/usr/bin/bash.exe\" LOCAL_SHELLFLAGS=\"--login -i -c\""
else
@echo "LOCAL_SHELL parameter detected, updating .env..."
@if grep -q '^SHELL=' .env 2>/dev/null; then \
sed -i 's|^SHELL=.*|SHELL=$(LOCAL_SHELL)|' .env; \
echo "Updated SHELL in .env"; \
else \
echo "SHELL=$(LOCAL_SHELL)" >> .env; \
echo "Added SHELL to .env"; \
fi
ifneq ($(LOCAL_SHELLFLAGS),)
@echo "LOCAL_SHELLFLAGS parameter detected, updating .env..."
@if grep -q '^SHELLFLAGS=' .env 2>/dev/null; then \
sed -i 's|^SHELLFLAGS=.*|SHELLFLAGS=$(LOCAL_SHELLFLAGS)|' .env; \
echo "Updated SHELLFLAGS in .env"; \
else \
echo "SHELLFLAGS=$(LOCAL_SHELLFLAGS)" >> .env; \
echo "Added SHELLFLAGS to .env"; \
fi
endif
endif
set-directory: ## Set the project directory Make should use
ifeq ($(LOCAL_DIRECTORY),)
@echo "Usage: make set-directory LOCAL_DIRECTORY=<path to project>"
else
@echo "LOCAL_DIRECTORY parameter detected, updating .env..."
@if grep -q '^DIRECTORY=' .env 2>/dev/null; then \
sed -i 's|^DIRECTORY=.*|DIRECTORY=$(LOCAL_DIRECTORY)|' .env; \
echo "Updated DIRECTORY in .env"; \
else \
echo "DIRECTORY=$(LOCAL_DIRECTORY)" >> .env; \
echo "Added DIRECTORY to .env"; \
fi
endif
check-variables: ## Checks which variables Make is using (SHELL, SHELLFLAGS, DIRECTORY)
@echo "---- Makefile Variables Check ----"
@echo "SHELL = $(SHELL)"
@echo "SHELLFLAGS = $(SHELLFLAGS)"
@echo "DIRECTORY = $(DIRECTORY)"

View File

@@ -27,6 +27,47 @@ make build-thesis
make build-expose make build-expose
``` ```
---
### Windwows-specific notes
- On **Windows**, you may need to adjust the shell used by Make, especially if you are running PowerShell.
- It is recommended to use **Git Bash** as the shell for full compatibility.
- You may also need to adjust the `DIRECTORY` variable in `.env` if Docker requires a Windows-style path (e.g., `C:/Users/...`).
#### Setting shell and directory
You can set the shell and project directory with Make targets:
```
make set-shell LOCAL_SHELL="C:/Program Files/Git/usr/bin/bash.exe" LOCAL_SHELLFLAGS="--login -i -c"
make set-directory LOCAL_DIRECTORY="C:/users/admin/project"
```
- `set-shell` updates `SHELL` and `SHELLFLAGS` in `.env`.
You can run it like this:
- `set-directory` updates `DIRECTORY` in `.env`.
#### Checking variables
You can check which variables Make is using:
```
make check-variables
```
#### Manual `.env` setup
If nothing works yet, you can manually create or edit `.env` in the project root:
```text
SHELL=C:/Program Files/Git/usr/bin/bash.exe
SHELLFLAGS=--login -i -c
DIRECTORY=C:/users/admin/project
```
---
## Project Structure ## Project Structure
<pre> <pre>
. .