Debian Codegraph @

tests/Makefile

raw
1 CFLAGS=-mwindows -g
2 MINGW64=x86_64-w64-mingw32-
3 MINGW32=i686-w64-mingw32-
4
5 .PHONY: all win64 win32 win16 clean
6
7 WATCOM ?= /opt/watcom
8 WCL_EXE := $(shell command -v wcl 2>/dev/null)
9 DOCKER_EXE := $(shell command -v docker 2>/dev/null)
10 WCL_FLAGS := -k -bt=windows -ml -l=windows
11 WRC_FLAGS := -q -bt=windows
12
13 # OpenWatcom is not available in most distros. For convenience, this will try a
14 # community Docker image if it is not already installed
15 ifneq ($(WCL_EXE),)
16 WCL = INCLUDE="$(WATCOM)/h:$(WATCOM)/h/win" wcl $(WCL_FLAGS)
17 WRC = INCLUDE="$(WATCOM)/h:$(WATCOM)/h/win" wrc $(WRC_FLAGS)
18 else ifneq ($(DOCKER_EXE),)
19 OPENWATCOM_DOCKER = docker run --rm \
20 -u "$(shell id -u):$(shell id -g)" \
21 --network none \
22 -v $(CURDIR):/src \
23 -e INCLUDE="$(WATCOM)/h:$(WATCOM)/h/win" \
24 ghcr.io/arlaneenalra/watcom-docker
25 WCL = $(OPENWATCOM_DOCKER) wcl $(WCL_FLAGS)
26 WRC = $(OPENWATCOM_DOCKER) wrc $(WRC_FLAGS)
27 endif
28
29 # Win16 is excluded by default as it requires a different compiler
30 all: win64 win32
31
32 win64: testapp64.exe testapp64-nores.exe testapp64-noicon.exe \
33 testapp64-with128.exe testapp64-with192.exe \
34 testapp64-string-res.exe
35
36 win32: testapp32.exe testapp32-nores.exe testapp32-noicon.exe \
37 testapp32-smallonly.exe testapp32-bpp.exe
38
39 win16: testapp16.exe testapp16-nores.exe testapp16-noicon.exe
40
41 tmp-testapp-16.bmp: testapp.png
42 convert testapp.png -resize 16x16 tmp-testapp-16.bmp
43
44 tmp-testapp-32.bmp: testapp.png
45 convert testapp.png -resize 32x32 tmp-testapp-32.bmp
46
47 tmp-testapp-48.bmp: testapp.png
48 convert testapp.png -resize 48x48 tmp-testapp-48.bmp
49
50 # icon with standard sizes: 16x16, 32x32, 48x48, 256x256
51 testapp.ico: testapp.png tmp-testapp-16.bmp tmp-testapp-32.bmp tmp-testapp-48.bmp
52 convert testapp.png tmp-testapp*.bmp testapp.ico
53
54 # Small icon (only up to 48x48)
55 testapp-smallonly.ico: testapp.png tmp-testapp-16.bmp tmp-testapp-32.bmp tmp-testapp-48.bmp
56 convert tmp-testapp-*.bmp testapp-smallonly.ico
57
58 # All standard sizes + 128x128
59 testapp-with128.ico: testapp.png tmp-testapp-16.bmp tmp-testapp-32.bmp tmp-testapp-48.bmp
60 convert testapp.png -resize 128x128 tmp-testapp-128.png
61 convert testapp.png tmp-testapp*.bmp tmp-testapp*.png testapp-with128.ico
62
63 # All small sizes + 128x128 + 192x192 (excluding 256x256)
64 testapp-with192.ico: testapp-with128.ico
65 convert testapp.png -resize 192x192 tmp-testapp-192.png
66 convert tmp-testapp*.bmp tmp-testapp-128.png tmp-testapp-192.png testapp-with192.ico
67
68 # $(1) = Toolchain prefix
69 # $(2) = Base output name (e.g., testapp64-with128)
70 define build-mingw-target =
71 $(1)windres tmp-$(2).rc -O coff -o $(2).o
72 $(1)gcc $(CFLAGS) -o $(2).exe testapp.c $(2).o
73 endef
74
75 # Build with (optional) icon + version resource
76 # $(1) = architecture (64, 32, or empty for both)
77 # $(2) = resource ID (defaults to 2)
78 define build-testapp =
79 $(eval ICON_FILE := $(filter %.ico,$^))
80 $(eval APP_NAME := $(basename $@))
81 $(eval RC_NAME := tmp-$(APP_NAME).rc)
82
83 cp testapp-base.rc $(RC_NAME)
84 $(if $(ICON_FILE), \
85 echo "$(if $(2),$(2),2) ICON $(ICON_FILE)" >> $(RC_NAME) \
86 )
87
88 $(if $(filter 64 $(1),$(if $(1),$(1),64)), \
89 $(call build-mingw-target,$(MINGW64),$(APP_NAME)) \
90 )
91 $(if $(filter 32 $(1),$(if $(1),$(1),32)), \
92 $(call build-mingw-target,$(MINGW32),$(APP_NAME)) \
93 )
94 endef
95
96 testapp64.exe testapp32.exe: testapp.c testapp.ico
97 $(call build-testapp,,)
98
99 testapp32-smallonly.exe: testapp.c testapp-smallonly.ico
100 $(call build-testapp,32,)
101
102 testapp64-with128.exe: testapp.c testapp-with128.ico
103 $(call build-testapp,64,)
104
105 testapp64-with192.exe: testapp.c testapp-with192.ico
106 $(call build-testapp,64,)
107
108 testapp64-string-res.exe: testapp.c testapp.ico
109 $(call build-testapp,32,MY_APP_ICON)
110
111 # Build with only version resource
112 testapp64-noicon.exe testapp32-noicon.exe: testapp.c
113 $(call build-testapp,,)
114
115 # Build with no resource info at all
116 testapp64-nores.exe testapp32-nores.exe: testapp.c
117 $(MINGW64)gcc $(CFLAGS) -o testapp64-nores.exe testapp.c
118 $(MINGW32)gcc $(CFLAGS) -o testapp32-nores.exe testapp.c
119
120 ## BPP tests (monochrome et al.)
121 testapp-bpp.ico: bmp-monochrome.bmp bmp-color.bmp
122 convert bmp-monochrome.bmp bmp-color.bmp testapp-bpp.ico
123
124 testapp32-bpp.exe: testapp-bpp.ico testapp.c
125 $(call build-testapp,32,3)
126
127 ## Win16
128 testapp16-nores.exe: testapp.c
129 $(WCL) testapp.c -fe=testapp16-nores.exe -fo=testapp16.o
130
131 testapp16-noicon.exe: testapp16-nores.exe
132 cp testapp16-nores.exe tmp-testapp16-noicon.exe
133 $(WRC) testapp16-base.rc tmp-testapp16-noicon.exe
134 mv tmp-testapp16-noicon.exe testapp16-noicon.exe
135
136 testapp16.exe: testapp16-nores.exe testapp-bpp.ico
137 cp testapp16-base.rc tmp-testapp16.rc
138 echo 'IDI_APPICON ICON "testapp-bpp.ico"' >> tmp-testapp16.rc
139 cp testapp16-nores.exe tmp-testapp16.exe
140 $(WRC) tmp-testapp16.rc tmp-testapp16.exe
141 mv tmp-testapp16.exe testapp16.exe
142
143 clean:
144 $(RM) tmp*.* *.ico *.exe *.o *.res