-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (120 loc) · 4.46 KB
/
Makefile
File metadata and controls
133 lines (120 loc) · 4.46 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
SHELL := /bin/bash
HOMEDIR := /home/$(USER)
AHK_BIN := /mnt/c/Program\ Files/AutoHotkey/Compiler/Ahk2Exe.exe
DOCDIR := /mnt/f/OneDrive/Documents
LIBDIR := $(DOCDIR)/AutoHotkey/Lib
DEVHOME := $(DOCDIR)/Dev/Projects
SCRIPTDIR := /mnt/c/scripts
APP := BirdingKeys
VER :=
APPEXE := $(APP)$(VER).exe
TARGET_EXE := $(SCRIPTDIR)/$(APPEXE)
SRCDIR := .
SRC := $(APP).ahk
SRCS := $(wildcard $(SRCDIR)/*.ahk)
INICFG := $(APP).ini
TARGET_INICFG := $(SCRIPTDIR)/$(INICFG)
INCLUDES := $(shell cat includes.txt 2>/dev/null || echo "")
IMGDIR := $(SRCDIR)/$(APP) Images
DESTIMGDIR := $(LIBDIR)/$(APP) Images
IMGSUBDIRS := 7OF9 VW
IMGS := $(shell find "$(IMGDIR)" -maxdepth 2 -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.gif' \) 2>/dev/null)
.PHONY: all build install clean force-install images ini shortcut shortcut-check force-shortcut
all: images ini build
build: $(APPEXE)
$(APPEXE): $(SRC) includes.txt $(shell cat includes.txt 2>/dev/null)
@if /mnt/c/Windows/System32/tasklist.exe | grep -i "$(APP).exe" > /dev/null; then \
/mnt/c/Windows/System32/taskkill.exe /IM "$(APP).exe" /F; \
sleep 2; \
fi
$(AHK_BIN) /in $(SRC) /out $(APPEXE)
@echo build completed at $$(date)
@if [ ! -f $(TARGET_EXE) ]; then \
$(MAKE) --no-print-directory force-install; \
else \
$(MAKE) --no-print-directory install; \
fi
@$(MAKE) --no-print-directory shortcut-check
includes.txt: $(SRC)
@$(HOMEDIR)/bin/makeincludes --output includes.txt.tmp && \
if [ -f $@ ] && cmp -s includes.txt.tmp $@; then \
rm includes.txt.tmp; \
else \
mv includes.txt.tmp $@; \
fi
ini:
@if [ ! -f $(TARGET_INICFG) ] || [ $(INICFG) -nt $(TARGET_INICFG) ]; then \
cp $(INICFG) $(TARGET_INICFG); \
echo $(INICFG) copied to $(TARGET_INICFG) at $$(date); \
else \
echo "$(TARGET_INICFG) is up to date"; \
fi
images:
@if [ -d "$(IMGDIR)" ]; then \
mkdir -p "$(DESTIMGDIR)"; \
for subdir in $(IMGSUBDIRS); do \
if [ -d "$(IMGDIR)/$$subdir" ]; then \
mkdir -p "$(DESTIMGDIR)/$$subdir"; \
rsync -av --delete --info=NAME "$(IMGDIR)/$$subdir"/ "$(DESTIMGDIR)/$$subdir" 2>/dev/null || true; \
fi; \
done; \
mkdir -p "$$(dirname "$(DESTIMGDIR)/.images.installed")"; \
touch "$(DESTIMGDIR)/.images.installed"; \
chmod -R a-w "$(DESTIMGDIR)"/*/*.{png,jpg,jpeg,gif} 2>/dev/null || true; \
echo "Images copied at $$(date)"; \
else \
echo "Note: Image directory not found: $(IMGDIR)"; \
fi
install: images ini
@if /mnt/c/Windows/System32/tasklist.exe | grep -i "$(APP).exe" > /dev/null; then \
/mnt/c/Windows/System32/taskkill.exe /IM "$(APP).exe" /F; \
sleep 2; \
fi
@cp -vf $(APPEXE) $(TARGET_EXE)
@echo install completed at $$(date)
force-install: install
@echo force-install completed at $$(date)
clean:
@if /mnt/c/Windos/System32/tasklist.exe | grep -i "$(APP).exe" > /dev/null; then \
/mnt/c/Windows/System32/taskkill.exe /IM "$(APP).exe" /F; \
sleep 2; \
fi
@rm -vf $(APPEXE)
@rm -vf $(TARGET_EXE)
@rm -vf $(TARGET_INICFG)
@rm -rf "$(DESTIMGDIR)"
@echo "Removed image cache: $(DESTIMGDIR)"
@rm -vf includes.txt
@echo clean completed at $$(date)
shortcut: install shortcut-check
shortcut-check:
@powershell.exe -Command " \
\$$DesktopPath = [Environment]::GetFolderPath('Desktop'); \
\$$ShortcutPath = Join-Path \$$DesktopPath '$(APP).lnk'; \
if (-not (Test-Path \$$ShortcutPath)) { \
\$$WshShell = New-Object -ComObject WScript.Shell; \
\$$Shortcut = \$$WshShell.CreateShortcut(\$$ShortcutPath); \
\$$Shortcut.TargetPath = '`wslpath -w $(TARGET_EXE)`'; \
\$$Shortcut.WorkingDirectory = '$(SCRIPTDIR)'; \
\$$Shortcut.Save(); \
Write-Host 'Desktop shortcut created: $(APP).lnk'; \
} else { \
Write-Host 'Desktop shortcut already exists: $(APP).lnk'; \
}"
@echo "Shortcut check completed at $$(date)"
force-shortcut: install
@powershell.exe -Command " \
$$DesktopPath = [Environment]::GetFolderPath('Desktop'); \
$$ShortcutPath = Join-Path $$DesktopPath '$(APP).lnk'; \
if (Test-Path $$ShortcutPath) { \
Remove-Item $$ShortcutPath -Force; \
Write-Host 'Removed: $(APP).lnk'; \
} \
$$WshShell = New-Object -ComObject WScript.Shell; \
$$Shortcut = $$WshShell.CreateShortcut($$ShortcutPath); \
$$Shortcut.TargetPath = '`wslpath -w $(TARGET_EXE)`'; \
$$Shortcut.WorkingDirectory = '$(SCRIPTDIR)'; \
$$Shortcut.Save(); \
Write-Host 'Created: $(APP).lnk'; \
"
@echo "Force shortcut creation completed at $$(date)"