summaryrefslogtreecommitdiff
path: root/win32/adwaita-msvc.mak.in
blob: 22b04fbe5070dd67ddd20e03a16a5ba8ea55cf7f (plain)
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
179
180
181
182
183
# NMake Makefile to generate the
# complete index.theme file and to
# install the icons

!include detectenv-msvc.mak

!IF "$(SRCROOTDIR)" == ""
SRCROOTDIR=..
!ENDIF

# Python.exe either needs to be in your PATH or you need to pass
# in PYTHON=<full-path-to-your-Python-executable> for this to work.
# Either Python 2.7 or 3.x can be used

!IF "$(PYTHON)" == ""
PYTHON=python
!ENDIF

# Prefix of your installation.  Pass in PREFIX=<your-installation-prefix>
# if needed.  gtk-update-icon-cache need to be found
# in $(PREFIX)\bin
!IF "$(PREFIX)" == ""
PREFIX=$(SRCROOTDIR)\..\vs$(VSVER)\$(PLAT)
!ENDIF

ERRNUL  = 2>NUL
_HASH=^#
NULL=
ICON_SUBDIR=share\icons\Adwaita
GDK_PIXBUF_MOD_VERSION=2.10.0
ADWAITA_VERSION=@VERSION@
ADWAITA_PC_FILES=adwaita-icon-theme.pc

# Generate the NMake Makefile modules for the listing of subdirs for each icon size
!if [@for /f %s in ('dir /b /on $(SRCROOTDIR)\Adwaita') do @if not "%s" == "cursors" (@echo SIZE_%s_dirs = \> %s.mak) & (@for /f %d in ('dir /b $(SRCROOTDIR)\Adwaita\%s') do @echo %s/%d \>> %s.mak) & @echo ^$(NULL) >> %s.mak]
!endif

# We want underscores instead of dashes in the Makefile varnames
!if [ren scalable-up-to-32.mak scalable-up-to-32.mak.tmp]
!endif
!if [$(PYTHON) replace.py --action=replace-str -i=scalable-up-to-32.mak.tmp -o=scalable-up-to-32.mak --instring=SIZE_scalable-up-to-32_dirs --outstring=SIZE_scalable_up_to_32_dirs]
!endif
!if [del scalable-up-to-32.mak.tmp]
!endif

# Include the generated NMake Makefile modules to have the full listing of directories, and then get rid of them...
!include 8x8.mak
!include 16x16.mak
!include 22x22.mak
!include 24x24.mak
!include 32x32.mak
!include 48x48.mak
!include 64x64.mak
!include 96x96.mak
!include 256x256.mak
!include scalable.mak
!include scalable-up-to-32.mak

!if [@for /f %s in ('dir /b /on $(SRCROOTDIR)\Adwaita') do @if not "%s" == "cursors" del %s.mak]
!endif

FIXED_ICON_DIRS = \
	$(SIZE_8x8_dirs)	\
	$(SIZE_16x16_dirs)	\
	$(SIZE_22x22_dirs)	\
	$(SIZE_24x24_dirs)	\
	$(SIZE_32x32_dirs)	\
	$(SIZE_48x48_dirs)	\
	$(SIZE_64x64_dirs)	\
	$(SIZE_96x96_dirs)

CONTEXT_PYTHON_CMD = $(PYTHON) -c "print('Context=' + '%d'['%d'.rfind('/') + 1:].title())"
SIZE_256 = 256
SIZE_256_MIN = 56
SIZE_SCALABLE = 16
SIZE_SCALABLE_32_MIN = 16
SIZE_SCALABLE_32_MAX = 32
SIZE_SCALABLE_MIN = 8
SIZE_SCALABLE_MAX = 512

all: index.theme

index.theme: index.theme.tmp
#	From index.theme.tmp, append then to the file the info for each subdir
#	under each icon size
#
#	The fixed-sized icons...
	@for %d in ($(FIXED_ICON_DIRS))	do					\
	@(echo [%d])>>$@.tmp &							\
	@($(CONTEXT_PYTHON_CMD))>>$@.tmp &					\
	@($(PYTHON) -c "print('Size=' + '%d'[:'%d'.find('x')])")>>$@.tmp &	\
	@(echo Type=Fixed)>>$@.tmp &	\
	@(echo.)>>$@.tmp

#	The 256x256 icons...
	@for %d in ($(SIZE_256x256_dirs)) do		\
	@(echo [%d]>>$@.tmp) &				\
	@($(CONTEXT_PYTHON_CMD))>>$@.tmp &		\
	@(echo Size=$(SIZE_256))>>$@.tmp &		\
	@(echo MinSize=$(SIZE_256_MIN))>>$@.tmp &	\
	@(echo MaxSize=$(SIZE_SCALABLE_MAX))>>$@.tmp &	\
	@(echo Type=Scalable)>>$@.tmp &			\
	@(echo.)>>$@.tmp

#	The scalable icons...
	@for %d in ($(SIZE_scalable_dirs)) do		\
	@(echo [%d]>>$@.tmp) &				\
	@($(CONTEXT_PYTHON_CMD))>>$@.tmp &		\
	@(echo Size=$(SIZE_SCALABLE))>>$@.tmp &		\
	@(echo MinSize=$(SIZE_SCALABLE_MIN))>>$@.tmp &	\
	@(echo MaxSize=$(SIZE_SCALABLE_MAX))>>$@.tmp &	\
	@(echo Type=Scalable)>>$@.tmp &			\
	@(echo.)>>$@.tmp

#	The scalable-up-to-32 icons...
	@for %d in ($(SIZE_scalable_up_to_32_dirs)) do		\
	@(echo [%d]>>$@.tmp) &					\
	@($(CONTEXT_PYTHON_CMD))>>$@.tmp &			\
	@(echo Size=$(SIZE_SCALABLE))>>$@.tmp &			\
	@(echo MinSize=$(SIZE_SCALABLE_32_MIN))>>$@.tmp &	\
	@(echo MaxSize=$(SIZE_SCALABLE_32_MAX))>>$@.tmp &	\
	@(echo Type=Scalable)>>$@.tmp &				\
	@(echo.)>>$@.tmp

	@$(PYTHON) replace.py -i=$@.tmp -o=$@.tmp1 --action=replace-str --instring=App --outstring=Application
	@$(PYTHON) replace.py -i=$@.tmp1 -o=$@ --action=replace-str --instring=Mimetype --outstring=MimeType
	@del $@.tmp1

index.theme.tmp: $(SRCROOTDIR)\index.theme.in dir_list.py
#	First generate a temporary index.theme.tmp that has @THEME_DIRS@ replaced appropriately
	@echo Generating index.theme...
	@$(PYTHON) apply_dirs.py -i=$(SRCROOTDIR)\$(@B).in -o=$@

dir_list.py:
#	Generate a Python list of subdirs under Adwaita/ for the icons
	@echo icon_dirs = [>$@
	@for %d in ($(FIXED_ICON_DIRS) $(SIZE_256x256_dirs) $(SIZE_scalable_dirs) $(SIZE_scalable_up_to_32_dirs)) do @echo '%d',>>$@
	@echo ]>>$@

.SUFFIXES: .svg .png

$(ADWAITA_PC_FILES): ..\adwaita-icon-theme.pc.in
	@echo Generating $@...
	$(PYTHON) adwaitapc.py --prefix=$(PREFIX) --version=$(ADWAITA_VERSION)

# Copy the icon and cursor files, and convert the SVG symbolic icons if:
# -The gtk-encode-symbolic-svg tool is found in $(PREFIX)\bin -AND-
# -The SVG GDK-Pixbuf loader can be found in $(PREFIX)\lib\gdk-pixbuf-2.0\2.10.0\loaders
install: index.theme $(ADWAITA_PC_FILES)
	@-mkdir $(PREFIX)\$(ICON_SUBDIR)
	copy index.theme $(PREFIX)\$(ICON_SUBDIR)
	for /f %d in ('dir /b $(SRCROOTDIR)\Adwaita') do								\
	@(echo Copying files for %d...) & 										\
	@(mkdir $(PREFIX)\$(ICON_SUBDIR)\%d) & 										\
	@(if not "%d" == "cursors"											\
		(for /f %f in ('dir /b /on $(SRCROOTDIR)\Adwaita\%d') do						\
		 (mkdir $(PREFIX)\$(ICON_SUBDIR)\%d\%f) &								\
		 (copy /b $(SRCROOTDIR)\Adwaita\%d\%f\* $(PREFIX)\$(ICON_SUBDIR)\%d\%f))				\
	  else (copy /b $(SRCROOTDIR)\Adwaita\%d\* $(PREFIX)\$(ICON_SUBDIR)\%d))
	@if exist $(PREFIX)\bin\gtk-encode-symbolic-svg.exe								\
	if exist $(PREFIX)\lib\gdk-pixbuf-2.0\$(GDK_PIXBUF_MOD_VERSION)\loaders\libpixbufloader-svg.dll			\
	if exist $(PREFIX)\lib\gdk-pixbuf-2.0\$(GDK_PIXBUF_MOD_VERSION)\loaders.cache 					\
		@(echo Converting symbolic SVG icons to PNG...) &							\
		@(for %z in (16x16 24x24 32x32 48x48 64x64 96x96) do							\
			@(echo Converting symbolic SVG icons to %z PNG...) &						\
			@(for /f %d in ('dir /b /on $(SRCROOTDIR)\Adwaita\scalable') do					\
				@(for /f %f in ('dir /b /on $(SRCROOTDIR)\Adwaita\scalable\%d') do			\
					@($(PREFIX)\bin\gtk-encode-symbolic-svg $(SRCROOTDIR)\Adwaita\scalable\%d\%f	\
					 %z -o $(PREFIX)\$(ICON_SUBDIR)\%z\%d))))
	if not exist $(PREFIX)\share\pkgconfig mkdir $(PREFIX)\share\pkgconfig
	copy adwaita-icon-theme.pc $(PREFIX)\share\pkgconfig
	@if exist $(PREFIX)\bin\gtk-update-icon-cache.exe 								\
	@(echo Update icon cache...) &											\
	@($(PREFIX)\bin\gtk-update-icon-cache -q $(PREFIX)\$(ICON_SUBDIR))
	@echo Adwaita icon theme install complete.

clean:
	@-del index.theme
	@-del index.theme.tmp
	@-del dir_list.py
	@-del adwaita-icon-theme.pc
	@-for %a in (*.pyc) do @del *.pyc
	@-if exist __pycache__ rmdir /s /q __pycache__