forked from LaurieWired/XplaneFlightData
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (156 loc) · 6.49 KB
/
Copy pathMakefile
File metadata and controls
179 lines (156 loc) · 6.49 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Makefile for X-Plane MFD and Flight Calculators
# Supports both JSF-compliant and non-compliant versions
CXX = g++
# JSF-compliant flags: strict warnings, optimization, C++20
CXXFLAGS_COMPLIANT = -std=c++20 -O3 -Wall -Wextra -Wpedantic -Werror=return-type -Icompliant
# Non-compliant flags: standard C++20, less strict
CXXFLAGS_NON_COMPLIANT = -std=c++20 -O3 -Wall -Wextra
# Default to compliant version
CXXFLAGS = $(CXXFLAGS_COMPLIANT)
SRC_DIR = compliant
# Calculator names (built in root directory)
TARGETS = wind_calculator flight_calculator turn_calculator vnav_calculator density_altitude_calculator
.PHONY: all compliant non-compliant clean test run install-fonts jsf-check help switch-compliant switch-non-compliant
# Default target: build compliant version
all: compliant
# Build JSF-compliant version
compliant:
@echo "========================================"
@echo "Building JSF-COMPLIANT calculators"
@echo "Source: compliant/"
@echo "========================================"
@$(MAKE) switch-compliant
@$(MAKE) build-all SRC_DIR=compliant CXXFLAGS="$(CXXFLAGS_COMPLIANT)"
@echo ""
@echo "JSF-compliant calculators built successfully!"
@echo "Run with: ./run_mfd.sh"
# Build non-compliant version
non-compliant:
@echo "========================================"
@echo "Building NON-COMPLIANT calculators"
@echo "Source: non-compliant/"
@echo "========================================"
@$(MAKE) switch-non-compliant
@$(MAKE) build-all SRC_DIR=non-compliant CXXFLAGS="$(CXXFLAGS_NON_COMPLIANT)"
@echo ""
@echo "Non-compliant calculators built successfully!"
@echo "Run with: ./run_mfd.sh"
# Internal target to build all calculators from specified directory
build-all: wind_calculator flight_calculator turn_calculator vnav_calculator density_altitude_calculator
wind_calculator:
@echo "Compiling wind calculator from $(SRC_DIR)..."
$(CXX) $(CXXFLAGS) -o wind_calculator $(SRC_DIR)/wind_calculator.cpp
@echo "✓ Wind calculator built!"
flight_calculator:
@echo "Compiling flight calculator from $(SRC_DIR)..."
$(CXX) $(CXXFLAGS) -o flight_calculator $(SRC_DIR)/flight_calculator.cpp
@echo "✓ Flight calculator built!"
turn_calculator:
@echo "Compiling turn calculator from $(SRC_DIR)..."
$(CXX) $(CXXFLAGS) -o turn_calculator $(SRC_DIR)/turn_calculator.cpp
@echo "✓ Turn calculator built!"
vnav_calculator:
@echo "Compiling VNAV calculator from $(SRC_DIR)..."
$(CXX) $(CXXFLAGS) -o vnav_calculator $(SRC_DIR)/vnav_calculator.cpp
@echo "✓ VNAV calculator built!"
density_altitude_calculator:
@echo "Compiling density altitude calculator from $(SRC_DIR)..."
$(CXX) $(CXXFLAGS) -o density_altitude_calculator $(SRC_DIR)/density_altitude_calculator.cpp
@echo "✓ Density altitude calculator built!"
# Create marker file to indicate which version is active
switch-compliant:
@echo "compliant" > .active_version
@echo "Switched to JSF-COMPLIANT version"
switch-non-compliant:
@echo "non-compliant" > .active_version
@echo "Switched to NON-COMPLIANT version"
clean:
@echo "Cleaning build artifacts..."
rm -f $(TARGETS)
rm -f .active_version
rm -rf __pycache__
rm -f *.pyc
@echo "Clean complete!"
test: $(TARGETS)
@echo "Running calculator tests..."
@./test_calculators.sh
install-fonts:
@echo "Installing B612 Mono fonts..."
@cp fonts/B612Mono-Regular.ttf ~/Library/Fonts/ 2>/dev/null || true
@cp fonts/B612Mono-Bold.ttf ~/Library/Fonts/ 2>/dev/null || true
@echo "Fonts installed!"
run: $(TARGETS)
@echo "Launching X-Plane MFD..."
@./run_mfd.sh
jsf-check:
@echo "Checking JSF AV C++ Coding Standard compliance..."
@if [ -f .active_version ] && [ "$$(cat .active_version)" = "compliant" ]; then \
echo "✓ Currently using JSF-COMPLIANT version"; \
echo "✓ AV Rule 208: No exceptions (throw/catch/try) used"; \
echo "✓ AV Rule 209: Fixed-width types via jsf_types.h"; \
echo "✓ AV Rule 206: No dynamic memory allocation"; \
echo "✓ AV Rule 119: No recursion (binomial_coefficient is iterative)"; \
echo "✓ AV Rule 113: Single exit points"; \
echo "✓ AV Rule 157/204: No side effects in boolean operators"; \
echo "All calculators are JSF-compliant!"; \
else \
echo "Currently using NON-COMPLIANT version"; \
echo "To build compliant version: make compliant"; \
fi
status:
@echo "========================================"
@echo "X-Plane Calculator Build Status"
@echo "========================================"
@if [ -f .active_version ]; then \
VERSION=$$(cat .active_version); \
echo "Active version: $$VERSION"; \
echo "Source directory: $$VERSION/"; \
else \
echo "Active version: unknown (run 'make compliant' or 'make non-compliant')"; \
fi
@echo ""
@echo "Built executables:"
@for calc in $(TARGETS); do \
if [ -f $$calc ]; then \
echo " ✓ $$calc"; \
else \
echo " ✗ $$calc (not built)"; \
fi \
done
help:
@echo "========================================"
@echo "X-Plane MFD Makefile"
@echo "JSF AV C++ Coding Standard Support"
@echo "========================================"
@echo ""
@echo "Build Targets:"
@echo " make - Build JSF-compliant version (default)"
@echo " make compliant - Build JSF-compliant calculators from compliant/"
@echo " make non-compliant - Build non-compliant calculators from non-compliant/"
@echo " make clean - Remove build artifacts"
@echo ""
@echo "Run Targets:"
@echo " make test - Run calculator tests"
@echo " make run - Build and launch MFD"
@echo " make status - Show current build status"
@echo ""
@echo "Utility Targets:"
@echo " make install-fonts - Install B612 Mono fonts"
@echo " make jsf-check - Verify JSF compliance status"
@echo " make help - Show this help"
@echo ""
@echo "Built executables (in root directory):"
@echo " • flight_calculator - Comprehensive flight calculations"
@echo " • turn_calculator - Turn performance calculations"
@echo " • vnav_calculator - VNAV helpers (TOD, required VS)"
@echo " • density_altitude_calculator - Density altitude & performance"
@echo " • wind_calculator - Wind vector calculations"
@echo ""
@echo "Source directories:"
@echo " • compliant/ - JSF AV C++ Standard compliant code"
@echo " • non-compliant/ - Original non-compliant code"
@echo ""
@echo "Examples:"
@echo " make compliant && make run - Build compliant and run MFD"
@echo " make non-compliant && make test - Build non-compliant and test"
@echo "========================================"