-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (112 loc) · 3.19 KB
/
Makefile
File metadata and controls
128 lines (112 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Detect operating system
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
DETECTED_OS := Linux
LINUX_DISTRO := $(shell cat /etc/os-release | grep -E "^ID=" | cut -d'=' -f2 | tr -d '"')
endif
ifeq ($(UNAME_S),Darwin)
DETECTED_OS := macOS
endif
endif
# Python and pip commands
ifeq ($(DETECTED_OS),Windows)
PYTHON := python
PIP := pip
VENV_ACTIVATE := .venv\Scripts\activate
VENV_CREATE := python -m venv .venv
else
PYTHON := python3
PIP := pip3
VENV_ACTIVATE := .venv/bin/activate
VENV_CREATE := $(PYTHON) -m venv .venv
endif
.PHONY: all test install environment debug clean run runCameraReel runCameraSimu
# Default target
all: environment
# Install dependencies
install:
$(PIP) install -r requirements.txt
# Set up development environment
environment:
@echo "> Creating virtual environment for $(DETECTED_OS)"
ifeq ($(DETECTED_OS),Linux)
ifeq ($(LINUX_DISTRO),arch)
@if ! command -v python-venv &> /dev/null || ! command -v tk &> /dev/null; then \
echo "> Installing required system packages for Arch Linux"; \
sudo pacman -S --noconfirm python; \
fi
else
@if ! command -v python3-venv &> /dev/null || ! command -v python3-tk &> /dev/null; then \
echo "> Installing required system packages for Ubuntu/Debian"; \
sudo apt-get update; \
sudo apt-get install python3-venv python3-tk -y; \
fi
endif
endif
ifeq ($(DETECTED_OS),Windows)
@if not exist .venv (
$(PYTHON) -m venv .venv
)
else
@if [ ! -d ".venv" ]; then \
$(VENV_CREATE); \
fi
endif
@echo "> Activating virtual environment and installing dependencies"
ifeq ($(DETECTED_OS),Windows)
@.venv\Scripts\activate && $(PIP) install -r requirements.txt
else
@. $(VENV_ACTIVATE) && $(PIP) install -r requirements.txt
endif
@echo "> Environment setup complete for $(DETECTED_OS)"
# Clean up virtual environment
clean:
ifeq ($(DETECTED_OS),Windows)
@echo Are you sure you want to remove the virtual environment? (Type 'y' to confirm)
@read confirm && if [ "$confirm" = "y" ]; then \
rmdir /s /q .venv; \
echo "> Virtual environment removed"; \
else \
echo "> Aborted"; \
fi
else
@read -p "> Remove virtual environment? (y/N) " answer; \
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then \
rm -rf .venv; \
echo "> Virtual environment removed"; \
else \
echo "> Aborted"; \
fi
endif
# Run specific scripts
runCameraReel:
ifeq ($(DETECTED_OS),Windows)
@.venv\Scripts\activate && $(PYTHON) src\mainCameraReel.py
else
@. $(VENV_ACTIVATE) && $(PYTHON) src/mainCameraReel.py
endif
runCameraSimu:
ifeq ($(DETECTED_OS),Windows)
@.venv\Scripts\activate && $(PYTHON) src\mainCameraSimu.py
else
@. $(VENV_ACTIVATE) && $(PYTHON) src/mainCameraSimu.py
endif
run:
ifeq ($(DETECTED_OS),Windows)
@.venv\Scripts\activate && $(PYTHON) src\main.py
else
@. $(VENV_ACTIVATE) && $(PYTHON) src/main.py
endif
# Placeholder for testing (add your test command)
test:
ifeq ($(DETECTED_OS),Windows)
@.venv\Scripts\activate && $(PYTHON) src\test.py
else
@. $(VENV_ACTIVATE) && $(PYTHON) src/test.py
endif
# Debug target (can be customized)
debug:
@echo "> Debug mode for $(DETECTED_OS) (not fully implemented)"