-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
89 lines (63 loc) · 3.19 KB
/
Makefile
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
include cross.mk
-include config.mak
APP_NAME := mlinstall
CAMLIB_SRC ?= camlib/src
APP_CORE := $(addprefix src/,main.o drive.o installer.o model.o platform.o ptp.o data.o)
CAMLIB_CORE := transport.o operations.o packet.o enums.o data.o enum_dump.o lib.o canon.o liveview.o bind.o ml.o conv.o generic.o canon_adv.o no_ip.o
CFLAGS := -Wall -Wpedantic -I$(CAMLIB_SRC) -I../libui-cross/ -O2 -g
UNIX_FILES := $(APP_CORE) src/libui.o src/drive-unix.o $(addprefix $(CAMLIB_SRC)/,$(CAMLIB_CORE) libusb.o)
ifeq ($(TARGET),l) # ++++++++++++++++
CFLAGS += $(shell pkg-config --cflags libusb-1.0)
LDFLAGS += $(shell pkg-config --libs libusb-1.0) -lui
FILES := $(call convert_target,$(UNIX_FILES))
linux.out: $(FILES)
$(CC) $(FILES) $(CFLAGS) $(LDFLAGS) -o linux.out
install: linux.out
cp linux.out /bin/mlinstall
APPIMAGE_VARS := UPDATE_INFORMATION="gh-releases-zsync|petabyt|mlinstall|latest|mlinstall-x86_64.AppImage"
mlinstall-x86_64.AppImage: linux.out
$(APPIMAGE_VARS) linuxdeploy --appdir=AppDir --executable=linux.out -d assets/mlinstall.desktop -i assets/mlinstall.png
appimagetool AppDir
else ifeq ($(TARGET),m) # ++++++++++++
LDFLAGS += -lui -lusb-1.0.0
CFLAGS += -I/usr/local/include/libusb-1.0
FILES := $(call convert_target,$(UNIX_FILES))
mac.out: $(FILES)
$(CC) $(FILES) $(CFLAGS) $(LDFLAGS) -o mac.out
.PHONY: pkg
pkg: mac.out
bash assets/appify.sh -i assets/mlinstall.png -s mac.out -n mlinstall
mkdir mlinstall.app/Contents/Frameworks
cp /opt/local/lib/libusb-1.0.0.dylib mlinstall.app/Contents/Frameworks
cp /usr/local/lib/libui.dylib mlinstall.app/Contents/Frameworks
install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib "@executable_path/../Frameworks/libusb-1.0.0.dylib" ./mlinstall.app/Contents/MacOS/mlinstall
install_name_tool -change libui.dylib "@executable_path/../Frameworks/libui.dylib" ./mlinstall.app/Contents/MacOS/mlinstall
else ifeq ($(TARGET),w) # +++++++++++++++
WIN_FILES := $(APP_CORE) src/libui.o src/drive-win.o $(addprefix $(CAMLIB_SRC)/,$(CAMLIB_CORE) libwpd.o)
WIN_FILES := $(call convert_target,$(WIN_FILES))
LIBS := -luser32 -lkernel32 -lgdi32 -lcomctl32 -luxtheme -lmsimg32 -lcomdlg32 -ld2d1 -ldwrite -lole32 -loleaut32 -loleacc
LIBS += -lstdc++ -lgcc -static -lpthread -lssp -lurlmon -luuid
# Remove cmd window from startup
LIBS+=-Wl,-subsystem,windows
windows: mlinstall.exe
mlinstall.exe: $(WIN_FILES) assets/win.res win.mak $(LIBWPD_A) $(LIBUI_A)
$(CC) $(WIN_FILES) $(LIBUI_A) $(LIBWPD_A) assets/win.res $(LIBS) -s -o mlinstall.exe
mlinstall_x86_64.exe: mlinstall.exe
cp mlinstall.exe mlinstall_x86_64.exe
else
$(info Unknown target $(TARGET))
endif # +++++++++++++
-include src/*.d camlib/src/*.d
%.$(TARGET).o: %.c
$(CC) -MMD -c $< $(CFLAGS) -o $@
%.$(TARGET).o: %.S
$(CC) -c $< $(CFLAGS) -o $@
distclean:
$(RM) -r src/*.o camlib/src/*.o src/*.d camlib/src/*.d *.out *.exe assets/*.res libusb $(CAMLIB_SRC)/*.o
clean: distclean
rm -rf *.zip *.AppImage win64* win32* SD_BACKUP *.dll linux *.dylib AppDir *.tar.gz *.app
release:
make TARGET=w mlinstall_x86_64.exe
make TARGET=l mlinstall-x86_64.AppImage
darling shell -c "make TARGET=m pkg" && tar -czf mlinstall-mac-x86_64.app.tar.gz mlinstall.app
.PHONY: clean clean-out release win32-gtk win64-gtk all style