File: Makefile.fpc

package info (click to toggle)
lazarus 2.0.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (451 lines) | stat: -rw-r--r-- 15,366 bytes parent folder | download | duplicates (2)
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#
#   Makefile.fpc for Lazarus for Free Pascal
#

[package]
name=lazarus
version=$(IDEVERSION)

[require]
packages=regexpr

[target]
programs=lazarus startlazarus lazbuild
dirs=

[compiler]

[clean]
files=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) $(wildcard *$(RSTEXT)) $(wildcard *.lfm)

[install]
fpcpackage=n
basedir=share/lazarus

[dist]
destdir=$(BASEDIR)/dist

[prerules]
RCPP?=$(strip $(firstword cpp$(SRCEXEEXT)))
#
LAZARUS_INSTALL_DIR=$(INSTALL_PREFIX)/share/lazarus
INSTALL_MAN_DIR=$(INSTALL_PREFIX)/share/man
ifneq ($(findstring $(OS_TARGET),win32 win64),)
LAZARUS_INSTALL_DIR=C:\lazarus
endif
ifneq ($(findstring $(OS_TARGET),freebsd),)
LAZARUS_INSTALL_DIR=/usr/local/lazarus
endif
ifneq ($(findstring $(OS_TARGET),win32 win64),)
IDEVERSION=$(shell .\tools\install\get_lazarus_version.bat)
else
IDEVERSION=$(shell ./tools/install/get_lazarus_version.sh)
endif

#-----------------------------------------------------------------------------
[rules]
.PHONY: help registration lazutils codetools tools lcl basecomponents bigidecomponents lazbuild ide idepkg idebig cleanide bigide useride starter lhelp all clean purge distclean install

#-----------------------------------------------------------------------------
help:
	@$(ECHO)
	@$(ECHO) " Main targets"
	@$(ECHO) "                  Without any target, target 'all' will be invoked."
	@$(ECHO) "   all            build all needed, i.e. minimal IDE, lazbuild, startlazarus."
	@$(ECHO) "   clean          deletes files that 'bigide' creates. It does not clean up all possible"
	@$(ECHO) "                  targets. Clean other target: make clean LCL_PLATFORM=qt"
	@$(ECHO) "   distclean      Clean all targets and common leftovers."
	@$(ECHO) "   lazbuild       build lazbuild and lcl with nogui widgetset"
	@$(ECHO) "   bigide         as all, except that the IDE is built with a lot of extra packages"
	@$(ECHO) "   useride        calls lazbuild to build an IDE with your active profile, requires lazbuild"
	@$(ECHO) "   install        installs Lazarus under $(LAZARUS_INSTALL_DIR)"
	@$(ECHO) "                  You can change the directory by appending INSTALL_PREFIX=/some/path"
	@$(ECHO)
	@$(ECHO) " Sub targets"
	@$(ECHO) "   registration   build package FCL"
	@$(ECHO) "   lazutils       build package LazUtils, requires registration"
	@$(ECHO) "   codetools      build package CodeTools, requires lazutils"
	@$(ECHO) "   lcl            build package LCLBase and LCL, requires lazutils"
	@$(ECHO) "   tools          build lazres, svn2revisioninc, updatepofiles, lrstolfm,"
	@$(ECHO) "                  requires LCL with nogui widgetset"
	@$(ECHO) "   basecomponents build debuggerintf, lazdebuggergdbmi, lazcontrols, synedit, ideintf"
   	@$(ECHO) "                  for the LCL_PLATFORM, requires lcl"
	@$(ECHO) "   bigidecomponents build many extra packages for the LCL_PLATFORM, requires basecomponents"
	@$(ECHO) "   lhelp          build lhelp, requires bigidecomponents"
	@$(ECHO) "   starter        build startlazarus, requires basecomponents"
	@$(ECHO) "   examples       build basic examples, requires basecomponents"
	@$(ECHO) "                  Note: There are more examples having their own directory"
	@$(ECHO)
	@$(ECHO) " Flags:"
	@$(ECHO) "   PP=/path/to/fpc        use another compiler"
	@$(ECHO) "   USESVN2REVISIONINC=0   do not update ide/revision.inc"
	@$(ECHO) "   INSTALL_PREFIX=/usr    used by 'install' as path prefix"
	@$(ECHO) "   FPC_DIR=/usr/share/fpcsrc/3.0.4   used by fpcmake when regenerating Makefiles"
	@$(ECHO) "   OPT='-vwnbq -gh'       append these options when calling the compiler"
	@$(ECHO)
	@$(ECHO) " Usage examples:"
	@$(ECHO)
	@$(ECHO) " Updating svn and build a minimal IDE, startlazarus and lazbuild:"
	@$(ECHO) "   make clean"
	@$(ECHO) "   svn up"
	@$(ECHO) "   make clean all"
	@$(ECHO)
	@$(ECHO) " Note: You can start lazarus with 'startlazarus'"
	@$(ECHO) " Note: Use the IDE or lazbuild to compile your projects/packages."
	@$(ECHO)
	@$(ECHO) " Updating svn and build an IDE with your last set of packages:"
	@$(ECHO) "   make clean"
	@$(ECHO) "   svn up"
	@$(ECHO) "   make clean lazbuild useride"
	@$(ECHO)
	@$(ECHO) " Clean up:"
	@$(ECHO) "  There is no command to clean up a svn repository completely, but"
	@$(ECHO) "  you can use the following command under Linux/OS X:"
	@$(ECHO) "  svn status | grep '\?' | sed -e 's/\? *//' | xargs rm -r"
	@$(ECHO)
	@$(ECHO) "  Another possibility is to create a clean copy via the "svn export" command."
	@$(ECHO)
	@$(ECHO) " Install:"
	@$(ECHO) "   Note: You can use Lazarus without installing. Just start the lazarus executable."
	@$(ECHO) "   1. Build Lazarus as normal user with one of the above commands."
	@$(ECHO) "   2. Install as root into /usr"
	@$(ECHO) "          sudo make install"
	@$(ECHO) "      This installs startlazarus, lazarus-ide, lazbuild under /usr/bin"
	@$(ECHO) "      and copies the whole lazarus source directory to /usr/share/lazarus"
	@$(ECHO)
	@exit

#-----------------------------------------------------------------------------
# build package FCL (shared by all LCL_PLATFORMs)
registration:
	$(MAKE) -C packager/registration

#-----------------------------------------------------------------------------
# build package LazUtils, requires registration (shared by all LCL_PLATFORMs)
lazutils:
	$(MAKE) -C components/lazutils

#-----------------------------------------------------------------------------
# build package CodeTools, requires lazutils (shared by all LCL_PLATFORMs)
codetools:
	$(MAKE) -C components/codetools

#-----------------------------------------------------------------------------
# build package LCLBase and LCL for LCL_PLATFORM
# requires lazutils
lcl:
	$(MAKE) -C lcl

#-----------------------------------------------------------------------------
# build required LCL components needed by IDE for the LCL_PLATFORM
# (Note: lazutils and codetools are shared on all LCL platforms)
# requires lcl
basecomponents:
	$(MAKE) -C components/debuggerintf
	$(MAKE) -C components/lazcontrols
	$(MAKE) -C components/synedit
	$(MAKE) -C components/ideintf
	$(MAKE) -C components/lazdebuggergdbmi

#-----------------------------------------------------------------------------
# build a lot of extra packages for the LCL_PLATFORM
# requires basecomponents
bigidecomponents:
	$(MAKE) -C components bigide

#-----------------------------------------------------------------------------
# build lazres, svn2revisioninc, updatepofiles, lrstolfm
# requires codetools and LCL with nogui widgetset
tools:
	$(MAKE) -C tools

#-----------------------------------------------------------------------------
# create/update ide/revision.inc
# requires tools
revisioninc:
	$(MAKE) -C ide revisioninc

#-----------------------------------------------------------------------------
# build lazarus exe with minimum of packages for the LCL_PLATFORM
# requires basecomponents and tools
ide:
	$(MAKE) -C ide ide

#-----------------------------------------------------------------------------
# build lazarus exe with bigide packages for the LCL_PLATFORM
# requires bigidecomponents and tools
idebig:
	$(MAKE) -C ide bigide

#-----------------------------------------------------------------------------
# build lazarus exe with user's packages for the LCL_PLATFORM
# requires user's packages, idemake.cfg and staticpackages.inc
# called by the IDE/lazbuild
# the idemake.cfg and staticpackages.inc are created by the IDE or by lazbuild
idepkg:
	$(MAKE) -C ide idepkg

#-----------------------------------------------------------------------------
# calls lazbuild to build lazarus and packages with user's settings
# requires lazbuild
# ignores LCL_PLATFORM and OPTS
useride: 
	./lazbuild$(SRCEXEEXT) --lazarusdir=. --build-ide=

#-----------------------------------------------------------------------------
starter:
	$(MAKE) -C ide starter

#-----------------------------------------------------------------------------
lazbuild: registration lazutils codetools
	$(MAKE) -C lcl LCL_PLATFORM=nogui
	$(MAKE) -C tools
	$(MAKE) -C components/debuggerintf LCL_PLATFORM=nogui
	$(MAKE) -C components/lazcontrols LCL_PLATFORM=nogui
	$(MAKE) -C components/synedit LCL_PLATFORM=nogui
	$(MAKE) -C components/ideintf LCL_PLATFORM=nogui
	$(MAKE) -C components/lazdebuggergdbmi LCL_PLATFORM=nogui
	$(MAKE) -C ide lazbuilder LCL_PLATFORM=nogui

#-----------------------------------------------------------------------------
# build lhelp
# requires bigidecomponents
lhelp:
	$(MAKE) -C components/chmhelp/lhelp

#-----------------------------------------------------------------------------
# build examples for the LCL_PLATFORM
# requires basecomponents
examples:
	$(MAKE) -C examples

#-----------------------------------------------------------------------------
# build lazarus,lcl,lazbuild,startlazarus with base packages for the LCL_PLATFORM
all: lazbuild lcl basecomponents ide starter

#-----------------------------------------------------------------------------
# build lazarus,lcl,lazbuild,startlazarus,lhelp with bigide packages for the LCL_PLATFORM
bigide: lazbuild lcl basecomponents bigidecomponents idebig starter lhelp

#-----------------------------------------------------------------------------
cleanide:
	$(MAKE) -C ide cleanide

cleanlaz: cleanide
	$(MAKE) -C packager/registration clean
	$(MAKE) -C lcl cleanall
	$(MAKE) -C components clean

clean: cleanlaz
	$(MAKE) -C . cleanlaz LCL_PLATFORM=nogui
	$(MAKE) -C tools clean
	$(MAKE) -C components/chmhelp/lhelp clean

cleanbigide: clean

purge:
	$(MAKE) -C ide distclean
	$(MAKE) -C packager/registration distclean
	$(MAKE) -C lcl distclean
	$(MAKE) -C components distclean
	$(MAKE) -C tools distclean
	$(MAKE) -C components/chmhelp/lhelp distclean

	$(MAKE) -C examples clean
#	$(MAKE) -C doceditor clean

cleanall: purge

distclean: purge

# create dirs
installbase:
ifneq ($(findstring $(OS_TARGET),win32 win64),)

else
	$(MKDIR) $(INSTALL_PREFIX)/share
	$(MKDIR) $(INSTALL_PREFIX)/share/lazarus
	$(MKDIR) $(INSTALL_PREFIX)/share/applications
	$(MKDIR) $(INSTALL_PREFIX)/share/pixmaps
	$(MKDIR) $(INSTALL_PREFIX)/share/mime/packages
	$(MKDIR) $(INSTALL_PREFIX)/share/icons/hicolor/48x48/mimetypes
	$(MKDIR) $(INSTALL_BINDIR)
	$(MKDIR) $(INSTALL_MAN_DIR)
	$(MKDIR) $(INSTALL_MAN_DIR)/man1
endif
#-----------------------------------------------------------------------------
# Most "make" users expect 'make install' to copy the binaries to somewhere
# Copy the lazarus tree to the install directory and set some links
# Copy everything except for 'debian' to avoid recursion and other platform files
install: installbase
	$(COPYTREE) packager debugger designer converter ide images languages lazarus.app units $(LAZARUS_INSTALL_DIR)
	$(COPYTREE) components docs doceditor examples lcl test tools $(LAZARUS_INSTALL_DIR)
	$(COPYTREE) Makefile* *.txt $(LAZARUS_INSTALL_DIR)
ifneq ($(findstring $(OS_TARGET),win32 win64),)
	$(COPYTREE) lazarus startlazarus lazbuild $(LAZARUS_INSTALL_DIR)
else
	$(INSTALLEXE) lazarus startlazarus lazbuild $(LAZARUS_INSTALL_DIR)

	# symlinks (they must be relative!)
	ln -sf ../$(INSTALL_BASEDIR)/lazarus $(INSTALL_PREFIX)/bin/lazarus-ide
	ln -sf ../$(INSTALL_BASEDIR)/startlazarus $(INSTALL_PREFIX)/bin/startlazarus
	ln -sf ../$(INSTALL_BASEDIR)/lazbuild $(INSTALL_PREFIX)/bin/lazbuild
	ln -sf ../$(INSTALL_BASEDIR)/tools/lazres $(INSTALL_PREFIX)/bin/lazres
	ln -sf ../$(INSTALL_BASEDIR)/tools/lrstolfm $(INSTALL_PREFIX)/bin/lrstolfm
	ln -sf ../$(INSTALL_BASEDIR)/tools/updatepofiles $(INSTALL_PREFIX)/bin/updatepofiles

	# man pages
	$(MAKE) -C install/man install PREFIX=$(INSTALL_PREFIX) GINSTALL=$(GINSTALL)

	# start menu item
	$(INSTALL) install/lazarus.desktop $(INSTALL_PREFIX)/share/applications/lazarus.desktop
	$(INSTALL) images/icons/lazarus128x128.png $(INSTALL_PREFIX)/share/pixmaps/lazarus.png

	# mime types and icons
	$(INSTALL) install/lazarus-mime.xml $(INSTALL_PREFIX)/share/mime/packages/lazarus.xml
	$(INSTALL) images/mimetypes/*.png $(INSTALL_PREFIX)/share/icons/hicolor/48x48/mimetypes/

	# create missing directories (needed when rebuilding IDE without write permission)
	$(MKDIR) $(LAZARUS_INSTALL_DIR)/units/$(FULL_TARGET)/nogui
	$(MKDIR) $(LAZARUS_INSTALL_DIR)/units/$(FULL_TARGET)/gtk
	$(MKDIR) $(LAZARUS_INSTALL_DIR)/units/$(FULL_TARGET)/gtk2
	$(MKDIR) $(LAZARUS_INSTALL_DIR)/units/$(FULL_TARGET)/qt
	$(MKDIR) $(LAZARUS_INSTALL_DIR)/components/synedit/design/languages
endif


##########################################################################
# Debian
##########################################################################

# Build dir
ifndef BUILDDIR
BUILDDIR=$(BASEDIR)/build
endif

ifeq ($(OS_TARGET),linux)

ifndef DEBDIR
DEBDIR=debian
endif

# Link Tree
ifdef LINKISCOPY
ifndef LINKTREE
LINKTREE:=$(CPPROG) -Rfpl
endif
else
ifndef LINKTREE
LINKTREE:=$(CPPROG) -Rfpl
endif
endif

ifneq ($(wildcard ${DEBDIR}/changelog),)

.PHONY: debcopy deb

DEBPACKAGEVERSION:=$(shell head -n 1 ${DEBDIR}/changelog | awk '{ print $$2 }' | tr -d '[()]')
DEBVERSION=$(firstword $(subst -, ,${DEBPACKAGEVERSION}))
DEBBUILD=$(lastword $(subst -, ,${DEBPACKAGEVERSION}))
DEBSRC=${PACKAGE_NAME}-${DEBVERSION}
DEBSRCDIR=${BUILDDIR}/${DEBSRC}
DEBSRC_ORIG=${PACKAGE_NAME}_${DEBVERSION}.orig
BUILDDATE=$(shell /bin/date --utc +%Y%m%d)
ifdef MENTORS
DEB_BUILDPKG_OPT=-sa
else
DEB_BUILDPKG_OPT=
endif
ifeq (${DEBBUILD},0)
DEBUSESVN=1
endif
ifeq (${DEBBUILD},1)
DEBUSESVN=1
endif
ifdef SNAPSHOT
DEBUSESVN=1
endif
ifndef SIGN
DEB_BUILDPKG_OPT+= -us -uc
endif

debcheck:
ifneq ($(DEBVERSION),$(PACKAGE_VERSION))
	! ${ECHO} "Debian version ($(DEBVERSION)) is not correct, expect $(PACKAGE_VERSION)"
endif
ifeq ($(wildcard ${DEBSRC_ORIG}.tar.gz),)
ifndef DEBUSESVN
	! ${ECHO} 'Need "${DEBSRC_ORIG}.tar.gz" to build for DEBBUILD = "${DEBBUILD}" > 1'
endif
endif

debcopy: distclean
	${DELTREE} ${BUILDDIR}
	${MKDIRTREE} ${DEBSRCDIR}
ifdef DEBUSESVN
	$(LINKTREE) -t $(DEBSRCDIR) \
		Makefile.fpc COPYING.* README.txt \
		components \
		converter \
		debugger \
		designer \
		doceditor \
		docs \
		install \
		examples \
		ide \
		images \
		languages \
		lazarus.app \
		lcl \
		packager \
		test \
		tools
	# add ide/revision.inc
	echo "const RevisionStr = '${SVNVERSION}';" > $(DEBSRCDIR)/ide/revision.inc
else
	tar -C ${BUILDDIR} -zxf ${DEBSRC_ORIG}.tar.gz ${DEBSRC}
	${DELTREE} $(DEBSRCDIR)/debian
endif

debsetup:
	$(COPYTREE) ${DEBDIR} $(DEBSRCDIR)/debian
ifdef SNAPSHOT
	sed -e 's/${DEBPACKAGEVERSION}/${DEBPACKAGEVERSION}~${BUILDDATE}/' -i $(DEBSRCDIR)/debian/changelog
endif
	chmod 755 $(DEBSRCDIR)/debian/rules
	find $(DEBSRCDIR) -name '.svn' | xargs ${DELTREE}

debbuild:
	cd ${DEBSRCDIR} ; dpkg-buildpackage ${DEB_BUILDPKG_OPT}

debcheckpolicy:
ifdef LINTIAN
	cd ${DEBSRCDIR} ; lintian -I -i ../*.changes
endif

debclean:
ifndef DEBUSESVN
	${DEL} ${BUILDDIR}/${DEBSRC_ORIG}.tar.gz
endif
	mv -v -t . \
	$(DEBSRCDIR)/../*.changes \
	$(DEBSRCDIR)/../*.deb \
	$(DEBSRCDIR)/../*.dsc \
	$(DEBSRCDIR)/../*.gz
	${DELTREE} $(DEBSRCDIR)
	rmdir $(BUILDDIR)

deb: debcheck debcopy deborigtargz debsetup debbuild debcheckpolicy debclean

deborigtargz:
ifdef DEBUSESVN
	#$(MAKE) fpc_zipinstall USETAR=y ZIPTARGET=debcopy PACKDIR=$(DEBSRCDIR) FULLZIPNAME=${DEBSRC_ORIG}
	tar -C ${BUILDDIR} -zcf ${BUILDDIR}/${DEBSRC_ORIG}.tar.gz --exclude-vcs ${DEBSRC}
else
	${LINKTREE} ${DEBSRC_ORIG}.tar.gz ${BUILDDIR}/${DEBSRC_ORIG}.tar.gz
endif

endif   # changelog found

endif