-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
184 lines (160 loc) · 8.26 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
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
# On Linux, TARGET can be Gtk2 (default) or Qt5
# On FreeBSD, TARGET can be Gtk2 (default) or Qt5
# On Windows, TARGET can be Win32 (default) or Qt5
BGRABITMAP_DIR := bgrabitmap
BGRACONTROLS_DIR := bgracontrols
ifeq ($(OS),Windows_NT) # true for Windows_NT or later
SHELL := C:/Windows/System32/cmd.exe /c
UNAME := Windows
COPY := winmake\copyfile
REMOVE := winmake\remove
REMOVEDIR := winmake\removedir
CREATEDIR := winmake\createdir
ECHOFILE := type
THEN := &
RUN :=
NOERROR :=
else
UNAME := $(shell uname)
ifeq ($(UNAME),FreeBSD)
SHELL := /usr/local/bin/bash
else
SHELL := /bin/bash
endif
COPY := cp
REMOVE := rm -f
REMOVEDIR := rm -rf
CREATEDIR := mkdir -p
ECHOFILE := cat
THEN := ;
RUN := ./
NOERROR := 2>/dev/null
endif
lazdir := $(shell $(ECHOFILE) lazdir $(NOERROR))
fpcbin := $(shell $(ECHOFILE) fpcbin $(NOERROR))
package := lazpaint
ifeq ($(UNAME),Linux)
TARGET ?= Gtk2
prefix := $(shell $(ECHOFILE) prefix $(NOERROR))
ifeq ($(MULTIBIN),1)
package := lazpaint-$(shell echo $(TARGET) | tr A-Z a-z)
prefix := /../$(package)$(prefix)
endif
USER_DIR = $(DESTDIR)$(prefix)
BIN_DIR = $(USER_DIR)/bin
SHARE_DIR=$(USER_DIR)/share
RESOURCE_DIR=$(SHARE_DIR)/lazpaint
ICON_DIR=$(SHARE_DIR)/icons/hicolor
SOURCE_BIN_DIR=lazpaint/release/bin
SOURCE_SCRIPT_DIR=resources/scripts
SOURCE_ICON_DIR=resources/icon
SOURCE_DEBIAN_UPSTREAM=lazpaint/release/debian
ICON:=lazpaint/lazpaint.ico
ICONS=$(shell identify $(ICON) | awk -F '[[]|[]] | ' '{ printf "[%s]=%s ", $$2, $$4 }')
EXTRACTED_ICONS_DIR=resources/icon
EXTRACTED_ICONS=16x16 24x24 32x32 48x48 96x96 128x128 256x256
PO_FILES:=$(shell find "$(SOURCE_BIN_DIR)/i18n" -maxdepth 1 -type f -name *.po -printf "\"%f\" ")
MODEL_FILES:=$(shell find "$(SOURCE_BIN_DIR)/models" -maxdepth 1 -type f -printf "\"%f\" ")
SCRIPT_FILES:=$(shell find "$(SOURCE_SCRIPT_DIR)" -maxdepth 1 -type f -name *.py -printf "\"%f\" ")
SCRIPT_RUNTIME_FILES:=$(shell find "$(SOURCE_SCRIPT_DIR)/lazpaint" -maxdepth 1 -type f -name *.py -printf "\"%f\" ")
LAZARUSDIRECTORIES:="-Fu$(lazdir)/*" "-Fi$(lazdir)/*" "-Fu$(lazdir)/components/printers/unix" "-Fi$(lazdir)/components/printers/unix" "-Fu$(lazdir)/packager/registration" "-Fi$(lazdir)/packager/registration" "-Fu$(lazdir)/components/*" "-Fi$(lazdir)/components/*" "-Fu$(lazdir)/lcl/forms" "-Fi$(lazdir)/lcl/forms" "-Fu$(lazdir)/lcl/widgetset" "-Fi$(lazdir)/lcl/widgetset" "-Fu$(lazdir)/interfaces/*" "-Fi$(lazdir)/interfaces/*" "-Fu$(lazdir)/lcl/nonwin32" "-Fi$(lazdir)/lcl/nonwin32" "-Fu$(lazdir)/lcl/interfaces/gtk2" "-Fi$(lazdir)/lcl/interfaces/gtk2" "-Fu$(lazdir)/lcl/components/*" "-Fi$(lazdir)/lcl/components/*" "-Fu$(lazdir)/lcl/include" "-Fi$(lazdir)/lcl/include" "-Fu$(lazdir)/lcl" "-Fi$(lazdir)/lcl"
endif
ifeq ($(UNAME),FreeBSD)
TARGET ?= Gtk2
LAZARUSDIRECTORIES:="-Fu$(lazdir)/*" "-Fi$(lazdir)/*" "-Fu$(lazdir)/components/printers/unix" "-Fi$(lazdir)/components/printers/unix" "-Fu$(lazdir)/packager/registration" "-Fi$(lazdir)/packager/registration" "-Fu$(lazdir)/components/*" "-Fi$(lazdir)/components/*" "-Fu$(lazdir)/lcl/forms" "-Fi$(lazdir)/lcl/forms" "-Fu$(lazdir)/lcl/widgetset" "-Fi$(lazdir)/lcl/widgetset" "-Fu$(lazdir)/interfaces/*" "-Fi$(lazdir)/interfaces/*" "-Fu$(lazdir)/lcl/nonwin32" "-Fi$(lazdir)/lcl/nonwin32" "-Fu$(lazdir)/lcl/interfaces/gtk2" "-Fi$(lazdir)/lcl/interfaces/gtk2" "-Fu$(lazdir)/lcl/components/*" "-Fi$(lazdir)/lcl/components/*" "-Fu$(lazdir)/lcl/include" "-Fi$(lazdir)/lcl/include" "-Fu$(lazdir)/lcl" "-Fi$(lazdir)/lcl"
endif
ifeq ($(UNAME),Windows)
TARGET ?= Win32
LAZARUSDIRECTORIES:="-Fu$(lazdir)/*" "-Fi$(lazdir)/*" "-Fu$(lazdir)/components/printers/win32" "-Fi$(lazdir)/components/printers/win32" "-Fu$(lazdir)/packager/registration" "-Fi$(lazdir)/packager/registration" "-Fu$(lazdir)/components/*" "-Fi$(lazdir)/components/*" "-Fu$(lazdir)/lcl/forms" "-Fi$(lazdir)/lcl/forms" "-Fu$(lazdir)/lcl/widgetset" "-Fi$(lazdir)/lcl/widgetset" "-Fu$(lazdir)/interfaces/*" "-Fi$(lazdir)/interfaces/*" "-Fu$(lazdir)/lcl/interfaces/win32" "-Fi$(lazdir)/lcl/interfaces/win32" "-Fu$(lazdir)/lcl/components/*" "-Fi$(lazdir)/lcl/components/*" "-Fu$(lazdir)/lcl/include" "-Fi$(lazdir)/lcl/include" "-Fu$(lazdir)/lcl" "-Fi$(lazdir)/lcl"
endif
# determine buildmode/interface
BUILDMODE:=Release
INTERFACE:=LCL$(shell echo $(TARGET) | tr A-Z a-z)
ifeq ($(TARGET),Qt5)
BUILDMODE:=ReleaseQt5
endif
# Lazarus custom packages explicitely compiled
ifeq "$(FOREIGN_LPK)" "1"
FOREIGN_PACKAGES=$(BGRABITMAP_DIR)/bgrabitmappack.lpk $(BGRACONTROLS_DIR)/bgracontrols.lpk
endif
all: compile
install: prefix
ifeq ($(UNAME),Windows)
echo "Under Windows, use installation generated by InnoSetup with lazpaint/release/windows/lazpaint.iss"
endif
ifeq ($(UNAME),Linux)
install -D "$(SOURCE_BIN_DIR)/$(package)" "$(BIN_DIR)/lazpaint"
for f in $(PO_FILES); do install -D --mode=0644 "$(SOURCE_BIN_DIR)/i18n/$$f" "$(RESOURCE_DIR)/i18n/$$f"; done
for f in $(MODEL_FILES); do install -D --mode=0644 "$(SOURCE_BIN_DIR)/models/$$f" "${RESOURCE_DIR}/models/$$f"; done
for f in $(SCRIPT_FILES); do install -D --mode=0644 "$(SOURCE_SCRIPT_DIR)/$$f" "${RESOURCE_DIR}/scripts/$$f"; done
for f in $(SCRIPT_RUNTIME_FILES); do install -D --mode=0644 "$(SOURCE_SCRIPT_DIR)/lazpaint/$$f" "${RESOURCE_DIR}/scripts/lazpaint/$$f"; done
install -D "$(SOURCE_DEBIAN_UPSTREAM)/applications/lazpaint.desktop" "$(SHARE_DIR)/applications/lazpaint.desktop"
install -D "$(EXTRACTED_ICONS_DIR)/48x48.png" "$(SHARE_DIR)/pixmaps/lazpaint.png"
for s in $(EXTRACTED_ICONS); do install -D --mode=0644 "$(EXTRACTED_ICONS_DIR)/$$s.png" "$(ICON_DIR)/$$s/apps/lazpaint.png"; done
install -d "$(SHARE_DIR)/man/man1"
gzip -9 -n -c "$(SOURCE_DEBIAN_UPSTREAM)/man/man1/lazpaint.1" >"$(SHARE_DIR)/man/man1/lazpaint.1.gz"
chmod 0644 "$(SHARE_DIR)/man/man1/lazpaint.1.gz"
endif
uninstall: prefix
ifeq ($(UNAME),Windows)
echo "Under Windows, go to Add/Remove programs to uninstall"
endif
ifeq ($(UNAME),Linux)
$(REMOVE) $(BIN_DIR)/lazpaint
$(REMOVEDIR) $(RESOURCE_DIR)
$(REMOVE) "$(SHARE_DIR)/applications/lazpaint.desktop"
$(REMOVE) "$(SHARE_DIR)/pixmaps/lazpaint.png"
for s in $(EXTRACTED_ICONS); do $(REMOVE) $(ICON_DIR)/$$s/apps/lazpaint.png; done
$(REMOVE) "$(SHARE_DIR)/man/man1/lazpaint.1.gz"
endif
distclean: clean clean_configure
clean: clean_bgrabitmap clean_bgracontrols clean_lazpaint
clean_configure:
$(REMOVE) "prefix"
$(REMOVE) "lazdir"
$(REMOVE) "fpcbin"
clean_icons:
$(REMOVEDIR) "icons"
clean_bgrabitmap:
$(REMOVEDIR) "$(BGRABITMAP_DIR)/lib"
$(REMOVEDIR) "$(BGRABITMAP_DIR)/backup"
clean_bgracontrols:
$(REMOVEDIR) "$(BGRACONTROLS_DIR)/lib"
$(REMOVEDIR) "$(BGRACONTROLS_DIR)/backup"
clean_lazpaint:
$(REMOVEDIR) "lazpaintcontrols/lib"
$(REMOVEDIR) "lazpaint/debug"
$(REMOVEDIR) "lazpaint/release/lib"
$(REMOVE) "lazpaint/lazpaint.res"
ifeq ($(UNAME),Windows)
$(REMOVE) "lazpaint/release/bin/lazpaint.exe"
$(REMOVE) "lazpaint/release/bin/lazpaint32.exe"
$(REMOVE) "lazpaint/release/bin/lazpaint64.exe"
else
$(REMOVE) "lazpaint/release/bin/lazpaint"
$(REMOVE) "lazpaint/release/bin/lazpaint32"
$(REMOVE) "lazpaint/release/bin/lazpaint64"
$(REMOVE) "lazpaint/release/bin/lazpaint-gtk2"
$(REMOVE) "lazpaint/release/bin/lazpaint-qt5"
endif
$(REMOVEDIR) "lazpaint/backup"
$(REMOVEDIR) "lazpaint/test_embedded/backup"
compile: lazdir lazpaint
force:
#lazbuild or fpc will determine what to recompile
lazpaint: force $(FOREIGN_PACKAGES) lazpaintcontrols/lazpaintcontrols.lpk lazpaint/lazpaint.lpi
ifeq "$(lazdir)" ""
lazbuild -B -r --build-mode=$(BUILDMODE) $(FOREIGN_PACKAGES) lazpaintcontrols/lazpaintcontrols.lpk lazpaint/lazpaint.lpi
else
$(COPY) "resources/lazpaint.res" "lazpaint/lazpaint.res"
$(CREATEDIR) "lazpaint/release/lib"
cd lazpaint $(THEN) $(fpcbin) -B -orelease/lazpaint -Fu./buttons -Fi./buttons -Fu./image -Fi./image -Fu./cursors -Fi./cursors -Fu./buttons -Fi./buttons -Fu./* -Fi./* -Fu../$(BGRACONTROLS_DIR) -Fi../$(BGRACONTROLS_DIR) -Fu../$(BGRABITMAP_DIR) -Fi../$(BGRABITMAP_DIR) $(LAZARUSDIRECTORIES) -MObjFPC -Scgi -Cg -OoREGVAR -Xs -XX -l -vewnhibq -O1 -CX -vi -FUrelease/lib/ -dLCL -d$(INTERFACE) lazpaint.lpr
endif
ifeq ($(MULTIBIN),1)
mv "$(SOURCE_BIN_DIR)/lazpaint" "$(SOURCE_BIN_DIR)/$(package)"
endif
icons:
ifneq ($(UNAME),Windows)
$(CREATEDIR) -p icons
declare -A icons=($(ICONS)); for i in "$${!icons[@]}"; do convert $(ICON)[$$i] $(SOURCE_ICON_DIR)/$${icons[$$i]}.png; done
endif