summaryrefslogtreecommitdiff
path: root/Makefile.fpc
blob: 4210b89c41bc0e85deda7607f34971d9889f3ac1 (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
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
#
#   Makefile.fpc for Free Pascal Source Tree
#

[package]
name=fpc
version=2.3.1

[target]
dirs=compiler rtl utils fv packages ide installer

[require]
nortl=y

[install]
fpcpackage=y

[default]
fpcdir=.
rule=help

[prerules]
# make versions < 3.77 (OS2 version) are buggy
ifndef inOS2
override FPCDIR:=$(BASEDIR)
export FPCDIR
endif

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

# New ppc386 (or ppc68k if on m68k machine !)
ifndef PPNEW
ifeq ($(CPU_TARGET),m68k)
PPSUF=68k
endif
ifeq ($(CPU_TARGET),i386)
PPSUF=386
endif
ifeq ($(CPU_TARGET),x86_64)
PPSUF=x64
endif
ifeq ($(CPU_TARGET),sparc)
PPSUF=sparc
endif
ifeq ($(CPU_TARGET),powerpc)
PPSUF=ppc
endif
ifeq ($(CPU_TARGET),powerpc64)
PPSUF=ppc64
endif
ifeq ($(CPU_TARGET),alpha)
PPSUF=axp
endif
ifeq ($(CPU_TARGET),arm)
PPSUF=arm
endif

# cross compilers uses full cpu_target, not just ppc-suffix.
ifdef CROSSCOMPILE
PPPRE=ppcross
else
PPPRE=ppc
endif

PPNEW=$(BASEDIR)/compiler/$(PPPRE)$(PPSUF)$(SRCEXEEXT)
endif

# Check if install/ subdir is available
ifneq ($(wildcard install),)
CVSINSTALL=install
else
CVSINSTALL=.
endif

# Install target, for snapshots we don't install examples.
# Cross installation only needs the .ppu files
ifdef SNAPSHOT
INSTALLTARGET=install
else
ifdef CROSSINSTALL
INSTALLTARGET=install
else
INSTALLTARGET=distinstall
endif
endif

# All target
ifdef SNAPSHOT
ALLTARGET=all
else
ifndef ALLTARGET
SHAREDTARGETS=
SMARTTARGETS=win32 go32v2 linux freebsd netbsd openbsd netware netwlibc
ifneq ($(findstring $(OS_TARGET),$(SHAREDTARGETS)),)
ALLTARGET=shared
else
ifneq ($(findstring $(OS_TARGET),$(SMARTTARGETS)),)
ALLTARGET=smart
else
ALLTARGET=all
endif
endif
endif
endif
# Prefix for units
ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
PKGUNITSPRE=u
else
PKGUNITSPRE=units-
endif

# Cross compile needs a prefix to not conflict with original packages
ifdef CROSSINSTALL
PKGPRE=$(FULL_TARGET)-
else
PKGPRE=
endif

# Always compile for release
override RELEASE=1
export RELEASE

# We want to have the resulting .zips in the current dir
ifndef DIST_DESTDIR
export DIST_DESTDIR:=$(BASEDIR)
endif

# Temporary path to pack a file
BASEPACKDIR=$(BASEDIR)/basepack

# Newly created fpcmake
ifeq ($(FULL_SOURCE),$(FULL_TARGET))
FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(EXEEXT)
else
FPCMAKENEW=fpcmake
endif

# Build/install options
CLEANOPTS=FPC=$(PPNEW)
BUILDOPTS=FPC=$(PPNEW) RELEASE=1
INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)

# Not compile FV for following target(s)
ifneq ($(wildcard fv),)
NOFVTARGETS=wince
ifeq ($(findstring $(OS_TARGET),$(NOFVTARGETS)),)
FV=1
endif
endif

# Compile also IDE (check for ide and fv dir)
# Skipped by default for cross compiles, because it depends on libc
ifndef CROSSCOMPILE
ifneq ($(wildcard ide),)
ifneq ($(wildcard fv),)
IDETARGETS=go32v2 win32 linux freebsd os2 emx
ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
IDE=1
endif
endif
endif
endif

[rules]
.NOTPARALLEL:

# These values can change
unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE

# Only process directories that really exists
override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))

#####################################################################
# Main targets
#####################################################################

.PHONY: help

help:
        @$(ECHO)
        @$(ECHO) Targets
        @$(ECHO)    all         Alias for build
        @$(ECHO)    build       Build a new compiler and all packages
        @$(ECHO)    install     Install newly build files
        @$(ECHO)    zipinstall  Create zip/tar of installed files
        @$(ECHO)    singlezipinstall  Alias for zipinstall
        @$(ECHO)
        @exit


#####################################################################
# Dependencies
#####################################################################

#######################################
# Compiler
#######################################

.PHONY: compiler_cycle

compiler_cycle:
        $(MAKE) -C compiler cycle


#######################################
# Packages
#######################################

.PHONY: packages_base_all packages_base_smart packages_base_shared \
        packages_fcl_all packages_fcl_smart packages_fcl_shared \
        packages_extra_all packages_extra_smart packages_extra_shared

packages_base_all:
        $(MAKE) -C packages base_all

packages_base_smart:
        $(MAKE) -C packages base_smart

packages_base_shared:
        $(MAKE) -C packages base_shared

packages_fcl_all:
        $(MAKE) -C packages fcl_all

packages_fcl_smart:
        $(MAKE) -C packages fcl_smart

packages_fcl_shared:
        $(MAKE) -C packages fcl_shared

packages_extra_all:
        $(MAKE) -C packages extra_all

packages_extra_smart:
        $(MAKE) -C packages extra_smart

packages_extra_shared:
        $(MAKE) -C packages extra_shared

##########################################################################
# Packaging
##########################################################################

BUILDSTAMP=build-stamp.$(FULL_TARGET)

.PHONY: all clean distclean build install installbase installother zipinstallbase zipinstallotherzipinstall singlezipinstall

all: build

clean: $(addsuffix _distclean,$(TARGET_DIRS))
        -$(DEL) build-stamp.*

distclean: clean

build: $(BUILDSTAMP)
$(BUILDSTAMP):
# create new compiler
        $(MAKE) compiler_cycle RELEASE=1
# clean
        $(MAKE) rtl_clean $(CLEANOPTS)
        $(MAKE) packages_clean $(CLEANOPTS)
ifdef FV
        $(MAKE) fv_clean $(CLEANOPTS)
endif
        $(MAKE) utils_clean $(CLEANOPTS)
ifdef IDE
        $(MAKE) ide_clean $(CLEANOPTS)
        $(MAKE) installer_clean $(CLEANOPTS)
endif
# build everything
        $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
        $(MAKE) packages_base_$(ALLTARGET) $(BUILDOPTS)
        $(MAKE) packages_fcl_$(ALLTARGET) $(BUILDOPTS)
ifdef FV
        $(MAKE) fv_$(ALLTARGET) $(BUILDOPTS)
endif
        $(MAKE) packages_extra_$(ALLTARGET) $(BUILDOPTS)
        $(MAKE) utils_all $(BUILDOPTS)
ifdef IDE
        $(MAKE) ide_all $(BUILDOPTS)
        $(MAKE) installer_all $(BUILDOPTS)
endif
        $(ECHOREDIR) Build > $(BUILDSTAMP)

installbase:
# create dirs
        $(MKDIR) $(INSTALL_BASEDIR)
        $(MKDIR) $(INSTALL_BINDIR)
# install compiler+rtl
        $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
        $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)

installother:
        $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
ifdef FV
        $(MAKE) fv_$(INSTALLTARGET) $(INSTALLOPTS)
endif
        $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
ifdef IDE
        $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
endif

zipinstallbase:
        $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)

zipinstallother:
        $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
ifdef FV
        $(MAKE) fv_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
endif
        $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
ifdef IDE
        $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
endif


install: $(BUILDSTAMP)
        $(MAKE) installbase $(INSTALLOPTS)
        $(MAKE) installother $(INSTALLOPTS)

singlezipinstall: zipinstall
zipinstall: $(BUILDSTAMP)
        $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)


##########################################################################
# Cross installation (installation of cross compiler and units)
##########################################################################

.PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall

crossall:
        $(MAKE) all CROSSINSTALL=1

crossinstall:
        $(MAKE) install CROSSINSTALL=1

crosszipinstall:
        $(MAKE) zipinstall CROSSINSTALL=1

crosssinglezipinstall:
        $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)