File: Makefile.fpc

package info (click to toggle)
fpc 3.2.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, experimental, sid
  • size: 338,552 kB
  • sloc: pascal: 3,794,737; xml: 191,997; ansic: 9,637; asm: 8,482; java: 5,346; sh: 4,664; yacc: 3,751; makefile: 2,688; lex: 2,538; javascript: 2,375; sql: 929; php: 473; cpp: 145; perl: 134; sed: 132; csh: 34; tcl: 7
file content (1221 lines) | stat: -rw-r--r-- 48,681 bytes parent folder | download | duplicates (3)
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
#
#   Makefile.fpc for Free Pascal Source Tree
#

[package]
name=fpc
version=3.2.0

[target]
dirs=fpcsrc fpcdocs

[require]
nortl=y

[install]
fpcpackage=y

[default]
fpcdir=.
rule=help

[prerules]
# Replace FPC_VERSION by PACKAGE_VERSION in order the install paths be set up
# using the package version instead of the starting compiler version.
# Save the original FPC_VERSION in order to restore it later.
BS_FPC_VERSION:=$(FPC_VERSION)
# Be sure to remove all suffixes like -beta from PACKAGE_VERSION
FPC_VERSION:=$(firstword $(subst -, ,$(PACKAGE_VERSION)))

# Check if install/ subdir is available
ifneq ($(wildcard install),)
CVSINSTALL=install
else
CVSINSTALL=.
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

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

# This list should be the same as in fpcsrc/Makefile.fpc and in fpcsrc/packages/ide/Makefile.fpc
GDBMI_DEFAULT_OS_LIST=aix darwin freebsd haiku linux netbsd openbsd solaris win32 win64


[rules]
# Restore FPC_VERSION
FPC_VERSION:=$(BS_FPC_VERSION)

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

.PHONY: help checkfpcdir

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 a zip/tar archive for every package
	@$(ECHO)    singlezipinstall
	@$(ECHO)                Create a single zip/tar archive
	@$(ECHO)    crosszipinstall
	@$(ECHO)                Build a cross compiler and create zip/tar for every package
	@$(ECHO)    crosssinglezipinstall
	@$(ECHO)                Build a cross compiler and a create single zip/tar archive
	@$(ECHO)
	@$(ECHO) Distribution Targets:
	@$(ECHO)    rpm         Build linux .rpm packages
	@$(ECHO)    deb         Build linux .deb packages
	@$(ECHO)    inno        "Build Windows (Innosetup) based installer"
	@$(ECHO)    innox64     "Build Win32-Win64 cross compiler installer"
	@$(ECHO)    innoce      "Build Win32-Wince cross compiler installer"
	@$(ECHO)    innomsdos   "Build Win32-MsDos cross compiler installer"
	@$(ECHO)    innoandroid "Build Win32-Android cross compiler installer"
	@$(ECHO)    tar         Build .tar installer
	@$(ECHO)
	@$(ECHO) FV based installer Targets:
	@$(ECHO)    go32v2zip   Build .zip files for go32v2
	@$(ECHO)    os2zip      Build .zip files for OS/2
	@$(ECHO)    sourcezip   Build .zip files for the sources
	@$(ECHO)
	@exit


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

ifdef LINKISCOPY
ifndef LINKTREE
LINKTREE:=$(CPPROG) -Rfp
endif
else
ifndef LINKTREE
LINKTREE:=$(CPPROG) -Rfpl
endif
endif

BUILDSTAMP=fpcsrc/build-stamp.$(FULL_TARGET)

.PHONY: all clean distclean build install installbase zipinstall singlezipinstall crosssinglezipinstall

all: build

build: $(BUILDSTAMP)
$(BUILDSTAMP):
	$(MAKE) -C fpcsrc build

buildx64: fpcsrc/build-stamp.x86_64-win64

fpcsrc/build-stamp.x86_64-win64:
	$(MAKE) -C fpcsrc build OS_TARGET=win64 CPU_TARGET=x86_64

buildce: fpcsrc/build-stamp.arm-wince

fpcsrc/build-stamp.arm-wince:
	$(MAKE) -C fpcsrc build OS_TARGET=wince CPU_TARGET=arm
		
buildjvm: fpcsrc/build-stamp.jvm-java fpcsrc/build-stamp.jvm-android

fpcsrc/build-stamp.jvm-java:
# currently, jvm supports only build base, so we have to use make all here		
	$(MAKE) -C fpcsrc all OS_TARGET=java CPU_TARGET=jvm
		
fpcsrc/build-stamp.jvm-android:
# currently, jvm supports only build base, so we have to use make all here		
	$(MAKE) -C fpcsrc all OS_TARGET=android CPU_TARGET=jvm

fpcsrc/build-stamp.cross-msdos:
	$(MAKE) -C fpcsrc clean buildbase OS_TARGET=msdos CPU_TARGET=i8086 OPT="-CX -XXs" BINUTILSPREFIX= CROSSOPT="-Wm$(MEMORY_MODEL) -Cp$(SUBARCH)"
	$(ECHO) $(DATE) > fpcsrc/build-stamp.cross-msdos

clean: $(addsuffix _distclean,$(TARGET_DIRS))
	-rm -f fpcsrc/build-stamp.*

distclean: clean

installbase:
# create dirs
	$(MKDIR) $(INSTALL_BASEDIR)
	$(MKDIR) $(INSTALL_BINDIR)
ifeq ($(OS_TARGET),wince)
	$(COPY) $(addprefix $(CVSINSTALL)/crossbinwce/, *.exe) $(INSTALL_BINDIR)
endif
ifeq ($(OS_TARGET),win64)
	$(COPY) $(addprefix $(CVSINSTALL)/crossbinw64/, *.exe) $(INSTALL_BINDIR)
endif
ifeq ($(OS_TARGET),msdos)
	$(COPY) $(addprefix $(CVSINSTALL)/crossbinmsdos/, *.exe) $(INSTALL_BINDIR)
endif
# readme, whatsnew, licenses and additional docs, they must be always included
	$(MKDIR) $(INSTALL_DOCDIR)
	-$(COPY) $(addprefix $(CVSINSTALL)/doc/,*.txt copying* license* faq.*) $(INSTALL_DOCDIR)
# but don't include readme-jvm.txt for lfn challenged targets (gives problems unzipping)
ifneq ($(findstring $(OS_TARGET),$(LIMIT83fs)),)
	$(DEL) $(INSTALL_DOCDIR)/readme-jvm.txt
endif
ifndef SNAPSHOT
ifndef CROSSINSTALL
# bingo32 (cwsdpmi,wmemu387.dxe)
ifeq ($(OS_TARGET),go32v2)
	$(COPY) $(CVSINSTALL)/bingo32/*.dxe $(INSTALL_BINDIR)
	$(COPY) $(CVSINSTALL)/bingo32/*.exe $(INSTALL_BINDIR)
endif
# binw32 (*.dll,*.exe,*.ico)
ifneq ($(patsubst %/,%,$(subst \,/,$(dir $(CPPROG)))),$(patsubst %/,%,$(subst \,/,$(INSTALL_BINDIR))))
ifeq ($(OS_TARGET),win32)
	$(COPY) $(addprefix $(CVSINSTALL)/binw32/,*.ico *.exe *.dll *.h *.manifest) $(INSTALL_BINDIR)
endif
# binw64 (some extensions have no corresponding files yet, thus we need to
# ignore errors.
ifeq ($(OS_TARGET),win64)
	-$(COPY) $(addprefix $(CVSINSTALL)/binw64/,*.ico *.exe *.dll *.h *.manifest) $(INSTALL_BINDIR)
endif
endif
# binos2 (emx.dll,emxwrap.dll,unzip32.dll,fp2.ico)
ifeq ($(OS_TARGET),os2)
	$(COPY) $(addprefix $(CVSINSTALL)/binos2/,*.ico *.dll) $(INSTALL_BINDIR)
endif
# binos2 (emx.dll,emxwrap.dll,unzip32.dll,fp2.ico)
ifeq ($(OS_TARGET),emx)
	$(COPY) $(addprefix $(CVSINSTALL)/binos2/,*.ico *.dll) $(INSTALL_BINDIR)
endif
# manpages for UNIX systems
ifneq ($(findstring $(OS_TARGET),linux freebsd netbsd openbsd sunos qnx),)
	$(MAKE) -C $(CVSINSTALL)/man installman
endif
# jvm utils
ifeq ($(CPU_TARGET),jvm)
	$(COPY) $(CVSINSTALL)/jvm/*.jar $(INSTALL_BINDIR)
endif
endif
endif
# install generated things, explicitly pass INSTALL_BASEDIR
	$(MAKE) -C fpcsrc installbase INSTALL_BASEDIR=$(INSTALL_BASEDIR)

install: $(BUILDSTAMP)
	$(MAKE) installbase
	$(MAKE) -C fpcsrc installother

crossinstall: $(BUILDSTAMP)
	$(MAKE) installbase CROSSINSTALL=1
	$(MAKE) -C fpcsrc installother CROSSINSTALL=1

zipinstall: $(BUILDSTAMP)
	$(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base
	$(MAKE) -C fpcsrc zipinstallother

singlezipinstall: $(BUILDSTAMP)
ifeq ($(FULL_SOURCE),$(FULL_TARGET))
	$(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX)
else
	$(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX).built.on.$(SOURCESUFFIX)
endif

crosszipinstall: $(BUILDSTAMP)
	$(MAKE) fpc_zipinstall CROSSINSTALL=1 ZIPTARGET=installbase ZIPNAME=base
	$(MAKE) -C fpcsrc zipinstallother CROSSINSTALL=1

crosssinglezipinstall: $(BUILDSTAMP)
	$(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(SOURCESUFFIX).cross.$(TARGETSUFFIX) CROSSINSTALL=1

##########################################################################
# Docs
##########################################################################

.PHONY: docspdf makepackdocs docsrcinstall docsrc

# We don't want the package name fpc in the path
DOCSOURCEDIR=$(INSTALL_SOURCEDIR)/../docs

docspdf:
	$(MAKE) -C fpcdocs pdfinstall DOCINSTALLDIR=$(PACKDIR)

# Used by makepack to generate unix installation .tar
makepackdocs:
	$(MAKE) fpc_zipinstall ZIPTARGET=docspdf FULLZIPNAME=docs

docsrcinstall:
	$(MAKE) -C fpcdocs distclean
	$(MKDIR) $(DOCSOURCEDIR)
	$(COPYTREE) fpcdocs/* $(DOCSOURCEDIR)

docsrc:
	$(MAKE) fpc_zipinstall ZIPTARGET=docsrcinstall FULLZIPNAME=docsrc


##########################################################################
# Demos
##########################################################################

.PHONY: demozip

# We don't want the package name fpc in the path
ifeq ($(MAKEPACK),)
ifdef UNIXHier
DEMOSOURCEDIR=$(INSTALL_DOCDIR)/../demo
else
DEMOSOURCEDIR=$(INSTALL_PREFIX)/demo
endif
else
DEMOSOURCEDIR=$(PACKDIR)
endif

demosrcinstall:
	$(MAKE) -C demo clean
	$(MKDIR) $(DEMOSOURCEDIR)
	$(COPYTREE) demo/* $(DEMOSOURCEDIR)

demozip:
	$(MAKE) fpc_zipinstall ZIPTARGET=demosrcinstall FULLZIPNAME=demo


##########################################################################
# Source targets
##########################################################################

.PHONY: sourcebase sourcezip

# We don't want the fpc/ package prefix
INSTALL_BASESOURCEDIR=$(INSTALL_SOURCEDIR)/..

sourcebase:
# base Makefiles needed for sources
	$(MKDIR) $(INSTALL_BASESOURCEDIR)
	$(MKDIR) $(INSTALL_BASESOURCEDIR)/packages
	$(COPY) fpcsrc/Makefile*  $(INSTALL_BASESOURCEDIR)
	$(COPY) fpcsrc/packages/Makefile* $(INSTALL_BASESOURCEDIR)/packages
	$(COPY) fpcsrc/packages/fpmake.pp $(INSTALL_BASESOURCEDIR)/packages
	$(COPY) fpcsrc/packages/fpmake_add.inc $(INSTALL_BASESOURCEDIR)/packages
	$(COPY) fpcsrc/packages/fpmake_proc.inc $(INSTALL_BASESOURCEDIR)/packages

sourcezip:
	$(MAKE) fpc_zipinstall ZIPTARGET=sourcebase ZIPNAME=base ZIPSUFFIX=$(ZIPSOURCESUFFIX)
	$(MAKE) -C fpcsrc compiler_zipsourceinstall
	$(MAKE) -C fpcsrc rtl_zipsourceinstall
	$(MAKE) -C fpcsrc packages_zipsourceinstall ZIPPREFIX=$(PKGUNITSPRE)
	$(MAKE) -C fpcsrc utils_zipsourceinstall
	$(MAKE) -C fpcsrc installer_zipsourceinstall


##########################################################################
# OS targets
##########################################################################

BUILDTARGETS=go32v2 win32 linux freebsd netbsd openbsd os2 emx sunos qnx beos win64 wince

.PHONY: go32v2 win32 win64 wince linux freebsd os2 emx netbsd openbsd go32v2zip win32zip linuxzip freebsdzip os2zip emxzip netbsdzip openbsdzip

$(BUILDTARGETS): checkfpcdir
	$(MAKE) install OS_TARGET=$@

$(addsuffix zip,$(filter-out beos sunos,$(BUILDTARGETS))): checkfpcdir
	$(MAKE) zipinstall OS_TARGET=$(subst zip,,$@)

beoszip : checkfpcdir
	$(MAKE) zipinstall OS_TARGET=beos USEZIP=1

sunoszip: checkfpcdir
	$(MAKE) zipinstall OS_TARGET=sunos TARPROG=gtar


##########################################################################
# Dos, OS/2 Short 8.3 Names
##########################################################################

.PHONY: renametoshort shortsrc shortbin shortnames

renametoshort:
# Compiler parts
	-mv $(PKGPRE)base$(ZIPSUFFIX).zip base$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)compiler$(ZIPSUFFIX).zip comp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)installer$(ZIPSUFFIX).zip inst$(ZIPSUFFIXSHORT).zip
# Utilities parts
	-mv $(PKGPRE)asld$(ZIPSUFFIX).zip asld$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)make$(ZIPSUFFIX).zip make$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)gdb$(ZIPSUFFIX).zip gdb$(ZIPSUFFIXSHORT).zip
# Packages in alphabetical order
	-mv $(PKGPRE)$(PKGUNITSPRE)a52$(ZIPSUFFIX).zip ua52$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ami-extra$(ZIPSUFFIX).zip uami$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)amunits$(ZIPSUFFIX).zip uamu$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)arosunits$(ZIPSUFFIX).zip uaru$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)aspell$(ZIPSUFFIX).zip uasp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)bfd$(ZIPSUFFIX).zip ubfd$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)bzip2$(ZIPSUFFIX).zip ubz2$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)cairo$(ZIPSUFFIX).zip ucai$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)cdrom$(ZIPSUFFIX).zip ucdr$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)chm$(ZIPSUFFIX).zip uchm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)cocoaint$(ZIPSUFFIX).zip ucoc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)dblib$(ZIPSUFFIX).zip udblb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)dbus$(ZIPSUFFIX).zip udbus$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)dts$(ZIPSUFFIX).zip udts$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fastcgi$(ZIPSUFFIX).zip ufcgi$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-async$(ZIPSUFFIX).zip ufcla$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-base$(ZIPSUFFIX).zip ufclb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-db$(ZIPSUFFIX).zip ufcld$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-extra$(ZIPSUFFIX).zip ufcex$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-fpcunit$(ZIPSUFFIX).zip ufclu$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-image$(ZIPSUFFIX).zip ufcli$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-js$(ZIPSUFFIX).zip ufcjs$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-json$(ZIPSUFFIX).zip ufclj$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-net$(ZIPSUFFIX).zip ufcln$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-passrc$(ZIPSUFFIX).zip ufcls$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-pdf$(ZIPSUFFIX).zip ufcpd$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-process$(ZIPSUFFIX).zip ufclp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-registry$(ZIPSUFFIX).zip ufclr$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-report$(ZIPSUFFIX).zip ufcre$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-res$(ZIPSUFFIX).zip ufcle$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-sdo$(ZIPSUFFIX).zip ufcsd$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-sound$(ZIPSUFFIX).zip ufsnd$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-stl$(ZIPSUFFIX).zip ufcst$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-web$(ZIPSUFFIX).zip ufclw$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fcl-xml$(ZIPSUFFIX).zip ufclx$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fftw$(ZIPSUFFIX).zip ufftw$(ZIPSUFFIXSHORT).zip
# This package corresponds to fpcsrc/packages main directory
	-mv $(PKGPRE)$(PKGUNITSPRE)fpc-all$(ZIPSUFFIX).zip ufpca$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fpgtk$(ZIPSUFFIX).zip ufpgt$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fpindexer$(ZIPSUFFIX).zip ufpi$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fpmkunit$(ZIPSUFFIX).zip ufpmk$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fppkg$(ZIPSUFFIX).zip ufppk$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fuse$(ZIPSUFFIX).zip ufuse$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)fv$(ZIPSUFFIX).zip ufv$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gdbint$(ZIPSUFFIX).zip ugdb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gdbm$(ZIPSUFFIX).zip ugdbm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ggi$(ZIPSUFFIX).zip uggi$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gmp$(ZIPSUFFIX).zip ugmp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gnome1$(ZIPSUFFIX).zip ugno1$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gnutls$(ZIPSUFFIX).zip ugtls$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)googleapi$(ZIPSUFFIX).zip ugapi$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)graph$(ZIPSUFFIX).zip ugrph$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gtk1$(ZIPSUFFIX).zip ugtk1$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)gtk2$(ZIPSUFFIX).zip ugtk2$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)hash$(ZIPSUFFIX).zip uhash$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)hermes$(ZIPSUFFIX).zip uherm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)httpd13$(ZIPSUFFIX).zip uhd13$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)httpd20$(ZIPSUFFIX).zip uhd20$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)httpd22$(ZIPSUFFIX).zip uhd22$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)httpd24$(ZIPSUFFIX).zip uhd24$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ibase$(ZIPSUFFIX).zip uibas$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)iconvenc$(ZIPSUFFIX).zip uicve$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ide$(ZIPSUFFIX).zip uide$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)imagemagick$(ZIPSUFFIX).zip uimgm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)imlib$(ZIPSUFFIX).zip uimlb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)iosxlocale$(ZIPSUFFIX).zip uiosl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)jni$(ZIPSUFFIX).zip ujni$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ldap$(ZIPSUFFIX).zip uldap$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libc$(ZIPSUFFIX).zip ulibc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libcups$(ZIPSUFFIX).zip ulcup$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libcurl$(ZIPSUFFIX).zip ulcur$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libenet$(ZIPSUFFIX).zip ulnet$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libffi$(ZIPSUFFIX).zip ulffi$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libfontconfig$(ZIPSUFFIX).zip ulfcg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libgbafpc$(ZIPSUFFIX).zip ulgba$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libgc$(ZIPSUFFIX).zip ulgc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libgd$(ZIPSUFFIX).zip ulgd$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libmagic$(ZIPSUFFIX).zip ulmag$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libmicrohttpd$(ZIPSUFFIX).zip ulmic$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libndsfpc$(ZIPSUFFIX).zip ulnds$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libogcfpc$(ZIPSUFFIX).zip ulogc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libpng$(ZIPSUFFIX).zip ulpng$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libsee$(ZIPSUFFIX).zip ulsee$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libtar$(ZIPSUFFIX).zip ultar$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libusb$(ZIPSUFFIX).zip ulusb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)libvlc$(ZIPSUFFIX).zip ulvlc$(ZIPSUFFIXSHORT).zip
# This package resides in fpcsrc/packages/libxml directory
	-mv $(PKGPRE)$(PKGUNITSPRE)libxml2$(ZIPSUFFIX).zip ulxml$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)lua$(ZIPSUFFIX).zip ulua$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)mad$(ZIPSUFFIX).zip umad$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)matroska$(ZIPSUFFIX).zip umatk$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)modplug$(ZIPSUFFIX).zip umplg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)morphunits$(ZIPSUFFIX).zip umrph$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)mysql$(ZIPSUFFIX).zip umysq$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ncurses$(ZIPSUFFIX).zip uncrs$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)newt$(ZIPSUFFIX).zip unewt$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)numlib$(ZIPSUFFIX).zip unlib$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)nvapi$(ZIPSUFFIX).zip unva$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)objcrtl$(ZIPSUFFIX).zip uobjc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)odata$(ZIPSUFFIX).zip uodat$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)odbc$(ZIPSUFFIX).zip uodbc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)oggvorbis$(ZIPSUFFIX).zip uoggv$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)openal$(ZIPSUFFIX).zip uoal$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)opencl$(ZIPSUFFIX).zip uocl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)opengl$(ZIPSUFFIX).zip uogl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)opengles$(ZIPSUFFIX).zip uogls$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)openssl$(ZIPSUFFIX).zip uossl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)oracle$(ZIPSUFFIX).zip uora$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)os2units$(ZIPSUFFIX).zip uos2$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)os4units$(ZIPSUFFIX).zip uos4$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)palmunits$(ZIPSUFFIX).zip upalm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)pasjpeg$(ZIPSUFFIX).zip upjp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)pastojs$(ZIPSUFFIX).zip up2js$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)paszlib$(ZIPSUFFIX).zip upzl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)pcap$(ZIPSUFFIX).zip upcap$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)postgres$(ZIPSUFFIX).zip upgr$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)proj4$(ZIPSUFFIX).zip uprj4$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)ptc$(ZIPSUFFIX).zip uptc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)pthreads$(ZIPSUFFIX).zip upthr$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)pxlib$(ZIPSUFFIX).zip upxl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)regexpr$(ZIPSUFFIX).zip ureg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rexx$(ZIPSUFFIX).zip urexx$(ZIPSUFFIXSHORT).zip
# This package resides in fpcsrc/packages/librsvg directory
	-mv $(PKGPRE)$(PKGUNITSPRE)rsvg$(ZIPSUFFIX).zip ursvg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rtl-console$(ZIPSUFFIX).zip urtlc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rtl-extra$(ZIPSUFFIX).zip urtle$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rtl-generics$(ZIPSUFFIX).zip urtlg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rtl-objpas$(ZIPSUFFIX).zip urtlo$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)rtl-unicode$(ZIPSUFFIX).zip urtlu$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)sdl$(ZIPSUFFIX).zip usdl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)sndfile$(ZIPSUFFIX).zip usndf$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)sqlite$(ZIPSUFFIX).zip usqlt$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)svgalib$(ZIPSUFFIX).zip usvga$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)symbolic$(ZIPSUFFIX).zip usymb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)syslog$(ZIPSUFFIX).zip usysl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)tcl$(ZIPSUFFIX).zip utcl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)tosunits$(ZIPSUFFIX).zip utos$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)univint$(ZIPSUFFIX).zip uuniv$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)unixutil$(ZIPSUFFIX).zip uunix$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)unzip$(ZIPSUFFIX).zip uzip$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)users$(ZIPSUFFIX).zip uuser$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)utmp$(ZIPSUFFIX).zip uutmp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)uuid$(ZIPSUFFIX).zip uuuid$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)vcl-compat$(ZIPSUFFIX).zip uvcl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)webidl$(ZIPSUFFIX).zip uwidl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)winceunits$(ZIPSUFFIX).zip uwice$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)winunits-base$(ZIPSUFFIX).zip uwib$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)winunits-jedi$(ZIPSUFFIX).zip uwij$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)x11$(ZIPSUFFIX).zip ux11$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)xforms$(ZIPSUFFIX).zip uxfrm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)zlib$(ZIPSUFFIX).zip uzlib$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)$(PKGUNITSPRE)zorba$(ZIPSUFFIX).zip uzorb$(ZIPSUFFIXSHORT).zip
# Utils packages in alphabetical order
	-mv $(PKGPRE)utils$(ZIPSUFFIX).zip utils$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-debugsrv$(ZIPSUFFIX).zip udbgs$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-dxegen$(ZIPSUFFIX).zip udxeg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpcm$(ZIPSUFFIX).zip ufpcm$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpcmkcfg$(ZIPSUFFIX).zip ufpck$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpcres$(ZIPSUFFIX).zip ufprs$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpcreslipo$(ZIPSUFFIX).zip ufprl$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpdoc$(ZIPSUFFIX).zip ufpdc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fpmc$(ZIPSUFFIX).zip ufpmc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fppkg$(ZIPSUFFIX).zip ufpkg$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-fprcp$(ZIPSUFFIX).zip ufprc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-h2pas$(ZIPSUFFIX).zip uh2pa$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-importtl$(ZIPSUFFIX).zip uimpt$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-instantfpc$(ZIPSUFFIX).zip uifpc$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-javaapp$(ZIPSUFFIX).zip ujvp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-json2pas$(ZIPSUFFIX).zip ujs2p$(ZIPSUFFIXSHORT).zip
# This package resides in fpcsrc/utils/tply directory
	-mv $(PKGPRE)utils-lexyacc$(ZIPSUFFIX).zip ulexy$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-mksymbian$(ZIPSUFFIX).zip umksb$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-pas2fpm$(ZIPSUFFIX).zip up2fp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-pas2jni$(ZIPSUFFIX).zip up2jn$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-pas2js$(ZIPSUFFIX).zip uupjs$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-pas2ut$(ZIPSUFFIX).zip up2ut$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-rmwait$(ZIPSUFFIX).zip urmw$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-sim_pasc$(ZIPSUFFIX).zip usmp$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-svn2cvs$(ZIPSUFFIX).zip us2c$(ZIPSUFFIXSHORT).zip
	-mv $(PKGPRE)utils-unicode$(ZIPSUFFIX).zip uucd$(ZIPSUFFIXSHORT).zip

# Sources only
	-mv $(PKGPRE)rtl$(ZIPSUFFIX).zip rtl$(ZIPSUFFIXSHORT).zip

shortsrc:
	$(MAKE) renametoshort ZIPSUFFIX=$(ZIPSOURCESUFFIX) ZIPSUFFIXSHORT=src
	$(MAKE) renametoshort ZIPSUFFIX=-$(FPC_VERSION)$(ZIPSOURCESUFFIX) ZIPSUFFIXSHORT=src

shortbin:
	$(MAKE) renametoshort ZIPSUFFIXSHORT=$(SHORTSUFFIX)
	$(MAKE) renametoshort ZIPSUFFIX=$(SHORTSUFFIX) ZIPSUFFIXSHORT=$(SHORTSUFFIX)
	$(MAKE) renametoshort PKGPRE=$(OS_TARGET)- ZIPSUFFIXSHORT=$(SHORTSUFFIX)

shortnames: shortsrc shortbin

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

# Use of GDBMI for text mode IDE, starting with version 3.1.1
# Use PACKAGE_VERSION here instead of FPC_VERSION
# to avoid checking for GDB if starting compiler is 3.0.4 release
ifeq ($(findstring 3.0.,$(PACKAGE_VERSION)),)
ifndef NOGDB
#  Determine if we should use GDBMI for Text Mode IDE compilation
ifndef NOGDBMI
ifneq ($(findstring $(OS_TARGET),$(GDBMI_DEFAULT_OS_LIST)),)
export GDBMI=1
endif
endif #NOGDB
endif #Not 3.0.X version

ifdef GDBMI
ifeq ($(GDBMI),0)
LOOKFORLIBGDBDIR=1
else
LOOKFORLIBGDBDIR=0
endif #GDBMI=0
else
ifndef NOGDB
LOOKFORLIBGDBDIR=1
else
LOOKFORLIBGDBDIR=0
endif #NOGDB
endif #GDBMI

#
# Automatic detection if libgdb.a is present (logic copied from packages/ide/Makefile.fpc)
#
ifeq ($(LOOKFORLIBGDBDIR),1)
# Try to find GDB library
# Look for a valid LIBGDBDIR environment variable
ifdef LIBGDBDIR
override LIBGDBFILE:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(LIBGDBDIR))))
endif

# Use default dirs if not available
ifeq ($(LIBGDBFILE),)
# Default locations <target>/<cpu> (linux) or <target> (win32,go32v2) only
override GDBLIBDIR=$(wildcard fpcsrc/libgdb/$(OS_TARGET)/$(CPU_TARGET))
override LIBGDBDIR=fpcsrc/libgdb
ifeq ($(GDBLIBDIR),)
override GDBLIBDIR=fpcsrc/libgdb/$(OS_TARGET)
override LIBGDBDIR=fpcsrc/libgdb
endif
# Detect if libgdb.a is available
override LIBGDBFILE:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(GDBLIBDIR))))
endif

# No custom libgdb.a found, try using system default library if available
ifeq ($(LIBGDBFILE),)
SYSLIBDIR=/lib /usr/lib /usr/local/lib
# Detect if libgdb.a is available
override LIBGDBFILE=$(firstword $(wildcard $(addsuffix /libgdb.a,$(SYSLIBDIR))))
ifneq (${LIBGDBFILE},)
$(warning Using system default libgdb file located in ${LIBGDBFILE})
override GDBLIBDIR=$(dir ${LIBGDBFILE})
override LIBGDBDIR=
endif
# Give an error when no libgdb.a found
ifeq ($(LIBGDBFILE),)
$(error No libgdb.a found, supply NOGDB=1 to disable debugger support)
endif
endif
endif  #ifeq ($(LOOKFORLIBGDBDIR),1)
endif  #NOGDB


##########################################################################
# Utilities (asld*.zip, make*.zip, gdb*.zip) for go32v2 and possibly os2
##########################################################################
.PHONY: utilities zip_util copy_utilfiles

UTILS_OUTDIR=$(INSTALL_PREFIX)/bin/$(TARGETSUFFIX)
ifeq ($(OS_TARGET),go32v2)
UTILS_BINSUFFIX=go32
else
UTILS_BINSUFFIX=$(SHORTSUFFIX)
endif

copy_utilfiles:
	$(MKDIRTREE) $(UTILS_OUTDIR)
	$(COPY) $(CVSINSTALL)/bin$(UTILS_BINSUFFIX)/$(UTILNAME)$(SHORTSUFFIX)/* $(UTILS_OUTDIR)

zip_util:
	$(MAKE) fpc_zipinstall ZIPTARGET=copy_utilfiles ZIPNAME=$(UTILNAME)

utilities:
	$(MAKE) zip_util UTILNAME=asld
	$(MAKE) zip_util UTILNAME=make
	$(MAKE) zip_util UTILNAME=gdb

##########################################################################
# Win32, Go32v2, OS/2
##########################################################################

.PHONY: dist

dist:
	$(MAKE) sourcezip
	$(MAKE) demozip
	$(MAKE) zipinstall
ifneq ($(findstring $(OS_TARGET),$(LIMIT83fs)),)
	$(MAKE) shortnames
endif

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

ifeq ($(OS_TARGET),linux)

ifndef DEBDIR
DEBDIR=${CVSINSTALL}/debian
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}_${PACKAGE_VERSION}.orig
BUILDDATE=$(shell /bin/date --utc +%Y%m%d)
ifdef MENTORS
DEB_BUILDPKG_OPT=-sa
else
DEB_BUILDPKG_OPT=
endif
ifdef NODOCS
	DEB_BUILDPKG_OPT+= -B
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})
ifneq (${SNAPSHOT},1)
	! ${ECHO} "Debian version ($(DEBVERSION)) is not correct, expect $(PACKAGE_VERSION)"
endif
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)/fpcsrc
ifdef DEBUSESVN
	$(LINKTREE) fpcsrc/Makefile* $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/compiler $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/rtl $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/installer $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/packages $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/tests $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) fpcsrc/utils $(DEBSRCDIR)/fpcsrc
	$(LINKTREE) demo $(DEBSRCDIR)
ifneq (${LIBGDBDIR},)
	$(LINKTREE) $(LIBGDBDIR) $(DEBSRCDIR)/fpcsrc
endif
	$(LINKTREE) fpcdocs $(DEBSRCDIR)
	${MKDIR} $(DEBSRCDIR)/install
	$(LINKTREE) install/man $(DEBSRCDIR)/install
	$(LINKTREE) install/doc $(DEBSRCDIR)/install
else
	tar -C ${BUILDDIR} -zxf ${DEBSRC_ORIG}.tar.gz ${DEBSRC}
	${DELTREE} $(DEBSRCDIR)/debian
endif

debsetup:
	$(COPYTREE) ${DEBDIR} $(DEBSRCDIR)/debian
ifeq (${SNAPSHOT},1)
ifneq (${DEBVERSION},${PACKAGE_VERSION})
	sed -i ${DEBSRCDIR}/debian/changelog \
	-e "1ifpc (${PACKAGE_VERSION}-0~${BUILDDATE}) unstable; urgency=low" \
	-e "1i\ " \
	-e "1i  * Build daily snapshots." \
	-e "1i\ " \
	-e "1i -- Abou Al Montacir <abou.almontacir@sfr.fr>  $(shell date -R)" \
	-e "1i\ "
else
	sed -e 's/${DEBPACKAGEVERSION}/${DEBPACKAGEVERSION}~${BUILDDATE}/' -i $(DEBSRCDIR)/debian/changelog
endif
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


##########################################################################
# RPM
##########################################################################

ifdef inUnix

# rpm available?
RPM:=$(strip $(wildcard $(addsuffix /rpm$(SRCEXEEXT),$(SEARCHPATH))))
ifneq ($(RPM),)

ifneq ($(wildcard $(CVSINSTALL)/fpc.spec),)

.PHONY: rpmcopy rpm

# Grab the version-suffix. Used to construct the filename of the source-archive
VERSION_SUFFIX:=$(shell echo $(PACKAGE_VERSION) | awk -F '.' '{ print substr($$3,2) }')
# Extract the patch version from the suffix. The suffix _may_ contain a leading '-', like
# -beta or -rc1. That has to be removed. 
MINOR_PATCH_VERSION:=$(shell echo $(VERSION_SUFFIX) | awk {'sub("^[-]", ""); print'})
MAIN_VERSION:=$(shell echo $(PACKAGE_VERSION) | awk {'sub("[A-Z,a-z,-].*", ""); print'})
ifeq ($(MINOR_PATCH_VERSION),)
RELEASE=1
else
RELEASE=0.$(MINOR_PATCH_VERSION)
endif
# Only the recent rpms have rpmbuild
RPMBUILD=$(firstword $(strip $(wildcard $(addsuffix /rpmbuild,$(SEARCHPATH)))))
ifeq ($(RPMBUILD),)
RPMBUILD=$(firstword $(strip $(wildcard $(addsuffix /rpm,$(SEARCHPATH)))))
endif
RPMDIR=$(BUILDDIR)/rpm
RPMSPECFILE:=$(RPMDIR)/SPECS/fpc-$(PACKAGE_VERSION).spec
RPMSOURCEFILE:=$(RPMDIR)/SOURCES/fpc-$(PACKAGE_VERSION)-src.tar.gz
RPMSRCDIR:=$(RPMDIR)/SOURCES/fpc
RPMDEFINES=--define "_topdir $(RPMDIR)" \
	   --define "_sourcedir $(RPMDIR)/SOURCES" \
	   --define "_builddir $(RPMDIR)/BUILD" \
	   --define "_rpmdir $(RPMDIR)/RPMS" \
	   --define "_srcrpmdir $(RPMDIR)/SRPMS"
rpmcopy: distclean
	# false || is needed to workaround fpcmake sections
	false || [ -d $(RPMDIR) ] || install -d $(RPMDIR)
	false || [ -d $(RPMDIR)/BUILD ] || install -d $(RPMDIR)/BUILD
	false || [ -d $(RPMDIR)/SOURCES ] || install -d $(RPMDIR)/SOURCES
	false || [ -d $(RPMDIR)/SPECS ] || install -d $(RPMDIR)/SPECS
	false || [ -d $(RPMDIR)/RPMS ] || install -d $(RPMDIR)/RPMS
	false || [ -d $(RPMDIR)/SRPMS ] || install -d $(RPMDIR)/SRPMS
	rm -rf $(RPMSRCDIR)
	sed -e "s+%FPCVERSION%+$(MAIN_VERSION)+" -e "s+%VERSION_SUFFIX%+$(VERSION_SUFFIX)+" -e "s+%RELEASE%+$(RELEASE)+" $(CVSINSTALL)/fpc.spec > $(RPMSPECFILE)
ifndef NODOCS
	cat $(CVSINSTALL)/fpcdoc.spec >> $(RPMSPECFILE)
endif
	# Install files
	install -d $(RPMSRCDIR)
	$(LINKTREE) fpcsrc/compiler $(RPMSRCDIR)
	$(LINKTREE) fpcsrc/rtl $(RPMSRCDIR)
	$(LINKTREE) fpcsrc/packages $(RPMSRCDIR)
	$(LINKTREE) fpcsrc/utils $(RPMSRCDIR)
ifneq (${LIBGDBDIR},)
	$(LINKTREE) $(LIBGDBDIR) $(RPMSRCDIR)
endif
	$(LINKTREE) demo $(RPMSRCDIR)
#	$(LINKTREE) logs $(RPMSRCDIR)
	$(LINKTREE) fpcsrc/Makefile* $(RPMSRCDIR)
	$(LINKTREE) $(CVSINSTALL)/man $(RPMSRCDIR)
	$(LINKTREE) $(CVSINSTALL)/doc $(RPMSRCDIR)
	$(COPY) $(CVSINSTALL)/smart_strip.sh $(RPMSRCDIR)
	chmod +x $(RPMSRCDIR)/smart_strip.sh
ifndef NODOCS
	$(LINKTREE) fpcdocs $(RPMSRCDIR)
endif
	find $(RPMSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
	find $(RPMSRCDIR) -name '.svn' | xargs -n1 rm -rf
	cd $(RPMSRCDIR) ; tar cfvz $(RPMSOURCEFILE) *
	rm -rf $(RPMSRCDIR)

rpmbuild: checkfpcdir
	$(RPMBUILD) $(RPMDEFINES) --nodeps -ba $(RPMSPECFILE)
	mv `find $(RPMDIR)/RPMS/ -name '*.rpm'` .
	mv `find $(RPMDIR)/SRPMS/ -name '*.rpm'` .

rpmclean:
	rm -rf $(RPMDIR)
	-rmdir $(BUILDDIR)

rpm: checkfpcdir rpmcopy rpmbuild rpmclean

endif   # spec found

endif   # rpm available

endif   # inUnix

##########################################################################
# Android NDK
##########################################################################

ifeq ($(OS_TARGET),android)
ifneq ($(CPU_TARGET),jvm)
ifdef CROSSCOMPILE

ifeq ($(NDK),)
  $(error It is needed to set the Android NDK path using NDK=<path>)
endif

override NDK:=$(subst $(PATHSEP),/,$(NDK))

ifeq ($(wildcard $(NDK)),)
  $(error NDK path does not exist: $(NDK))
endif

NDK_LIB:=$(NDK)/platforms/android-21
ifeq ($(wildcard $(NDK_LIB)/arch-arm64/usr/lib/crtbegin_so.o),)
  $(error Unable to find NDK library files in $(NDK_LIB))
endif

NDKARCH:=$(notdir $(firstword $(wildcard $(NDK)/prebuilt/$(OS_SOURCE)-$(CPU_SOURCE))))

ifeq ($(NDKARCH),)
  NDKARCH:=windows
endif

gettoolchain=$(dir $(firstword $(foreach d, $(wildcard $(NDK)/toolchains/$(1)-*.*), $(wildcard $(d)/prebuilt/$(NDKARCH)/bin/$(2)-ld.bfd$(SRCEXEEXT)))))

ANDROID_AARCH64_BINUTILS:=$(call gettoolchain,aarch64,aarch64-linux-android)
ifeq ($(ANDROID_AARCH64_BINUTILS),)
  WINARCH:=$(PROCESSOR_ARCHITEW6432)
  ifeq ($(WINARCH),)
    WINARCH:=$(PROCESSOR_ARCHITECTURE)
  endif
  ifeq ($(WINARCH),AMD64)
    NDKARCH:=windows-x86_64
    ANDROID_AARCH64_BINUTILS:=$(call gettoolchain,aarch64,aarch64-linux-android)
  endif
  ifeq ($(ANDROID_AARCH64_BINUTILS),)
    ANDROID_AARCH64_BINUTILS:=$(call gettoolchain,arm64,arm64-linux-android)
    ifeq ($(ANDROID_AARCH64_BINUTILS),)
      ANDROID_AARCH64_BINUTILS:=$(dir $(firstword $(wildcard $(addsuffix /aarch64-linux-android-as$(SRCEXEEXT),$(SEARCHPATH)))))
    endif
  endif
endif

ANDROID_ARM_BINUTILS:=$(call gettoolchain,arm-linux-androideabi,arm-linux-androideabi)
ifeq ($(ANDROID_ARM_BINUTILS),)
  ifeq ($(ANDROID_ARM_BINUTILS),)
    ANDROID_ARM_BINUTILS:=$(dir $(firstword $(wildcard $(addsuffix /arm-linux-androideabi-as$(SRCEXEEXT),$(SEARCHPATH)))))
    ifneq ($(ANDROID_ARM_BINUTILS),)
      $(info "ANDROID_ARM_BINUTILS is $(ANDROID_ARM_BINUTILS)")
    endif
  endif
endif

ANDROID_X86_BINUTILS:=$(call gettoolchain,x86,i686-linux-android)
ifeq ($(ANDROID_X86_BINUTILS),)
  ANDROID_X86_BINUTILS:=$(dir $(firstword $(wildcard $(addsuffix /i686-linux-android-as$(SRCEXEEXT),$(SEARCHPATH)))))
endif

ANDROID_X86_64_BINUTILS:=$(call gettoolchain,x86_64,x86_64-linux-android)
ifeq ($(ANDROID_X86_64_BINUTILS),)
  ANDROID_X86_64_BINUTILS:=$(dir $(firstword $(wildcard $(addsuffix /x86_64-linux-android-as$(SRCEXEEXT),$(SEARCHPATH)))))
endif

ANDROID_MIPS_BINUTILS:=$(call gettoolchain,mipsel-linux-android,mipsel-linux-android)
ifeq ($(ANDROID_MIPS_BINUTILS),)
  ANDROID_MIPS_BINUTILS:=$(dir $(firstword $(wildcard $(addsuffix /mipsel-linux-android-as$(SRCEXEEXT),$(SEARCHPATH)))))
endif

unexport BUILDFULLNATIVE

ifeq ($(CPU_TARGET),arm)
  ifeq ($(ANDROID_ARM_BINUTILS),)
    $(error Unable to find binutils for arm-android)
  endif
  CROSSBINDIR=$(ANDROID_ARM_BINUTILS)
  override LIBDIR+=$(NDK_LIB)/arch-arm/usr/lib
endif

ifeq ($(CPU_TARGET),aarch64)
  ifeq ($(ANDROID_AARCH64_BINUTILS),)
    $(error Unable to find binutils for aarch64-android)
  endif
  CROSSBINDIR=$(ANDROID_AARCH64_BINUTILS)
  override LIBDIR+=$(NDK_LIB)/arch-arm64/usr/lib
endif

ifeq ($(CPU_TARGET),i386)
  ifeq ($(ANDROID_X86_BINUTILS),)
    $(error Unable to find binutils for i386-android)
  endif
  CROSSBINDIR=$(ANDROID_X86_BINUTILS)
  override LIBDIR+=$(NDK_LIB)/arch-x86/usr/lib
endif

ifeq ($(CPU_TARGET),x86_64)
  ifeq ($(ANDROID_X86_64_BINUTILS),)
    $(error Unable to find binutils for x86_64-android)
  endif
  CROSSBINDIR=$(ANDROID_X86_64_BINUTILS)
  override LIBDIR+=$(NDK_LIB)/arch-x86_64/usr/lib64
endif

ifeq ($(CPU_TARGET),mipsel)
  ifeq ($(ANDROID_MIPS_BINUTILS),)
    $(error Unable to find binutils for mipsel-android)
  endif
  CROSSBINDIR=$(ANDROID_MIPS_BINUTILS)
  override LIBDIR+=$(NDK_LIB)/arch-mips/usr/lib
endif

export CROSSBINDIR
export BINUTILSPREFIX
export LIBDIR

endif
endif
endif

##########################################################################
# Inno setup
##########################################################################

ifndef ISCCPROG
ISCCPROG=$(subst $(PATHSEP),/,$(ProgramFiles))/inno setup 5/iscc.exe
endif # ISCCPROG

ifndef inUnix
USEINNOWRAPPER=1
endif
INNODIR=$(BUILDDIR)/inno
INNOWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpcinno$(SRCBATCHEXT))
INNOCMD_CDINNO:=cd $(subst /,$(ZIPPATHSEP),$(INNODIR))
INNOCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
INNOCMD_ISCC:="$(ISCCPROG)" "$(subst /,$(PATHSEP),$(INNODIR)/fpc.iss)"
FPCISSSUBST=-d BUILDDIR=$(subst /,$(PATHSEP),$(INNODIR))
ifdef NODOCS
FPCISSSUBST+=-d DisableDocs=;
endif

innocheck:
ifndef NODOCS
# Check for doc-pdf.zip
ifeq ($(wildcard doc-pdf.zip),)
	@$(ECHO) "No documentation available. Please copy the file doc-pdf.zip to this directory."
	@exit 1
endif
endif
ifeq ($(LOOKFORLIBGDBDIR),1)
# Check for libgdb
ifeq ($(wildcard fpcsrc/libgdb/win32/libgdb.a),)
ifeq ($(wildcard fpcsrc/libgdb/win32/i386/libgdb.a),)
	@$(ECHO) "Libgdb not available. Please get and unzip libgdb-*.i386-win32.zip in fpcsrc/."
	@exit 1
endif
endif
endif

innobuild: innocheck build
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
	$(COPYTREE) demo $(INNODIR)
	$(COPYTREE) install/unicode $(INNODIR)
ifndef NODOCS
	unzip -d $(INNODIR) doc-pdf.zip
endif
	$(MAKE) install INSTALL_PREFIX=$(INNODIR)
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcmkcfg -t install/fpc.ist -o $(INNODIR)/fpc.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	$(INNOCMD_ISCC)
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_TARGET).exe

innocebuild: innocheck buildce
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
	$(COPYTREE) demo $(INNODIR)
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=wince CPU_TARGET=arm
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcmkcfg -t install/fpcce.ist -o $(INNODIR)/fpcce.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	"$(ISCCPROG)" $(INNODIR)/fpcce.iss
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_SOURCE).cross.$(FULL_TARGET).exe

innox64build: innocheck buildx64
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
	$(COPYTREE) demo $(INNODIR)
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=win64 CPU_TARGET=x86_64
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcmkcfg -t install/fpcx64.ist -o $(INNODIR)/fpcx64.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	"$(ISCCPROG)" $(INNODIR)/fpcx64.iss
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_SOURCE).cross.$(FULL_TARGET).exe
		
innojvmbuild: innocheck buildjvm
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
# currently, jvm supports only buildbase, so we have to use installbase here		
	$(MAKE) installbase INSTALL_PREFIX=$(INNODIR) OS_TARGET=java CPU_TARGET=jvm
	$(MAKE) installbase INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=jvm
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcmkcfg -t install/fpcjvm.ist -o $(INNODIR)/fpcjvm.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	"$(ISCCPROG)" $(INNODIR)/fpcjvm.iss
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_SOURCE).cross.$(CPU_TARGET).exe

buildmsdos_subarch_mm: fpcsrc/build-stamp.cross-msdos
	$(MAKE) -C fpcsrc/rtl clean install OS_TARGET=msdos FPC=ppc8086 CPU_TARGET=i8086 OPT="-CX -XXs" BINUTILSPREFIX= CROSSOPT="$(OPT) -CX -XXs -Wm$(MEMORY_MODEL) -Cp$(SUBARCH)"
	$(MAKE) -C fpcsrc/packages clean install OS_TARGET=msdos FPC=ppc8086 CPU_TARGET=i8086 OPT="-CX -XXs" BINUTILSPREFIX= CROSSOPT="$(OPT) -CX -XXs -Wm$(MEMORY_MODEL) -Cp$(SUBARCH)" FPCFPMAKE=$(BASEDIR)/fpcsrc/compiler/ppc
	$(MOVE) $(INSTALL_BASEDIR)/units/msdos $(INSTALL_BASEDIR)/units/msdos_/$(SUBARCH)-$(MEMORY_MODEL)

buildmsdos_subarch:
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=tiny
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=small
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=medium
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=compact
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=large
ifeq ($(findstring 3.0.,$(FPC_VERSION)),)
	$(MAKE) buildmsdos_subarch_mm MEMORY_MODEL=huge
endif

build_msdos:
	$(DELTREE) $(INSTALL_BASEDIR)/units/msdos_
	$(MKDIR) $(INSTALL_BASEDIR)/units/msdos_
	$(MAKE) buildmsdos_subarch SUBARCH=8086
	$(MAKE) buildmsdos_subarch SUBARCH=80186
	$(MAKE) buildmsdos_subarch SUBARCH=80286
	$(MAKE) buildmsdos_subarch SUBARCH=80386
	$(MOVE) $(INSTALL_BASEDIR)/units/msdos_ $(INSTALL_BASEDIR)/units/msdos

buildmsdos_rtl_subarch_mm:
	$(MAKE) -C fpcsrc/rtl/msdos info clean all FPC=ppc8086 CPU_TARGET=i8086 OS_TARGET=msdos OPT="-CX -XXs" BINUTILSPREFIX= CROSSOPT="$(OPT) -CX -XXs -Wm$(MEMORY_MODEL) -Cp$(SUBARCH)"
	$(MAKE) -C fpcsrc/rtl/msdos install FPC=ppc8086 CPU_TARGET=i8086 OS_TARGET=msdos CROSSINSTALL=1 OPT="-CX -XXs" BINUTILSPREFIX= CROSSOPT="$(OPT) -CX -XXs -Wm$(MEMORY_MODEL) -Cp$(SUBARCH)"
	$(MOVE) $(INSTALL_BASEDIR)/units/msdos $(INSTALL_BASEDIR)/units/msdos_/$(SUBARCH)-$(MEMORY_MODEL)

buildmsdos_rtl_subarch:
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=tiny CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=small CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=medium CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=compact CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=large CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
ifeq ($(findstring 3.0.,$(FPC_VERSION)),)
	$(MAKE) buildmsdos_rtl_subarch_mm MEMORY_MODEL=huge CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
endif

buildmsdos_rtl: fpcsrc/build-stamp.cross-msdos
	$(DELTREE) $(INSTALL_BASEDIR)/units/msdos_
	$(MKDIR) $(INSTALL_BASEDIR)/units/msdos_
	$(MAKE) buildmsdos_rtl_subarch SUBARCH=8086 CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch SUBARCH=80186 CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch SUBARCH=80286 CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MAKE) buildmsdos_rtl_subarch SUBARCH=80386 CPU_TARGET=i8086 OS_TARGET=msdos FPC=ppc8086
	$(MOVE) $(INSTALL_BASEDIR)/units/msdos_ $(INSTALL_BASEDIR)/units/msdos

innomsdosbuild: innocheck
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
	$(COPYTREE) demo $(INNODIR)
	$(MKDIR) $(INNODIR)/units/msdos_
	$(MAKE) buildmsdos_subarch SUBARCH=8086 OS_SOURCE=win32 CPU_SOURCE=i386 INSTALL_PREFIX=$(INNODIR)
	$(MAKE) buildmsdos_subarch SUBARCH=80186 OS_SOURCE=win32 CPU_SOURCE=i386 INSTALL_PREFIX=$(INNODIR)
	$(MAKE) buildmsdos_subarch SUBARCH=80286 OS_SOURCE=win32 CPU_SOURCE=i386 INSTALL_PREFIX=$(INNODIR)
	$(MOVE) $(INNODIR)/units/msdos_ $(INNODIR)/units/msdos
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcsubst -i install/fpcmsdos.ist -o $(INNODIR)/fpcmsdos.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	"$(ISCCPROG)" $(INNODIR)/fpcmsdos.iss
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_SOURCE).cross.$(FULL_TARGET).exe

innoandroidbuild:
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)
	$(MKDIR) $(INNODIR)
# arm
	$(MAKE) -C fpcsrc rtl_clean packages_clean OS_TARGET=android CPU_TARGET=arm
	$(MAKE) build OS_TARGET=android CPU_TARGET=arm CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=arm
	$(MOVE) $(INNODIR)/units/arm-android $(INNODIR)/units/armv5t-android
	$(MOVE) $(INNODIR)/fpmkinst/arm-android $(INNODIR)/fpmkinst/armv5t-android
	$(DEL) fpcsrc/build-stamp.arm-android
# arm-v7a
	$(MAKE) -C fpcsrc rtl_clean packages_clean OS_TARGET=android CPU_TARGET=arm
	$(MAKE) build OS_TARGET=android CPU_TARGET=arm CROSSOPT="-Cparmv7a -Cfvfpv3_d16" CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=arm
	$(MOVE) $(INNODIR)/units/arm-android $(INNODIR)/units/armv7a-android
	$(MOVE) $(INNODIR)/fpmkinst/arm-android $(INNODIR)/fpmkinst/armv7a-android
	$(DEL) fpcsrc/build-stamp.arm-android
# aarch64
	$(MAKE) build OS_TARGET=android CPU_TARGET=aarch64 CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=aarch64
# i386
	$(MAKE) build OS_TARGET=android CPU_TARGET=i386 CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=i386
# x86_64
	$(MAKE) build OS_TARGET=android CPU_TARGET=x86_64 CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=x86_64
# mipsel
	$(MAKE) build OS_TARGET=android CPU_TARGET=mipsel CROSSINSTALL=1
	$(MAKE) crossinstall INSTALL_PREFIX=$(INNODIR) OS_TARGET=android CPU_TARGET=mipsel
	rmcvsdir$(EXEEXT) $(INNODIR)
	fpcmkcfg -t install/fpcandroid.ist -o $(INNODIR)/fpcandroid.iss $(FPCISSSUBST) -d FPCVERSION=$(PACKAGE_VERSION)
	"$(ISCCPROG)" $(INNODIR)/fpcandroid.iss
	$(MOVE) $(INNODIR)/Output/setup.exe fpc-$(PACKAGE_VERSION).$(FULL_SOURCE).cross.android.exe

innoclean:
	rmcvsdir$(EXEEXT) $(INNODIR)
	$(DELTREE) $(INNODIR)

innoce : checkfpcdir
	$(MAKE) OS_TARGET=wince CPU_TARGET=arm innocebuild NOGDB=1
	$(MAKE) innoclean	

innox64 : checkfpcdir
	$(MAKE) OS_TARGET=win64 CPU_TARGET=x86_64 innox64build NOGDB=1
	$(MAKE) innoclean	

innojvm : checkfpcdir
	$(MAKE) OS_TARGET=java CPU_TARGET=jvm innojvmbuild NOGDB=1
	$(MAKE) innoclean	

innomsdos : checkfpcdir
	$(MAKE) OS_TARGET=msdos CPU_TARGET=i8086 innomsdosbuild NOGDB=1 CROSSBINDIR=$(BASEDIR)/install/crossbinmsdos
	$(MAKE) innoclean	

innoandroid : checkfpcdir
	$(MAKE) innoandroidbuild NOGDB=1
	$(MAKE) innoclean

inno: checkfpcdir innobuild innoclean