mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 07:43:04 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			400 lines
		
	
	
		
			9.4 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			400 lines
		
	
	
		
			9.4 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
#
 | 
						|
#   Makefile.fpc for Free Pascal Source Tree
 | 
						|
#
 | 
						|
 | 
						|
[package]
 | 
						|
name=fpc
 | 
						|
version=2.7.1
 | 
						|
 | 
						|
[target]
 | 
						|
dirs=compiler rtl utils packages ide installer
 | 
						|
 | 
						|
[require]
 | 
						|
nortl=y
 | 
						|
 | 
						|
[install]
 | 
						|
fpcpackage=y
 | 
						|
 | 
						|
[default]
 | 
						|
fpcdir=.
 | 
						|
rule=help
 | 
						|
 | 
						|
[prerules]
 | 
						|
REQUIREDVERSION=2.6.4
 | 
						|
REQUIREDVERSION2=2.6.2
 | 
						|
 | 
						|
 | 
						|
# 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
 | 
						|
ifeq ($(CPU_TARGET),armeb)
 | 
						|
PPSUF=arm
 | 
						|
endif
 | 
						|
ifeq ($(CPU_TARGET),jvm)
 | 
						|
PPSUF=jvm
 | 
						|
endif
 | 
						|
ifeq ($(CPU_TARGET),mips)
 | 
						|
PPSUF=mips
 | 
						|
endif
 | 
						|
ifeq ($(CPU_TARGET),mipsel)
 | 
						|
PPSUF=mipsel
 | 
						|
endif
 | 
						|
ifeq ($(CPU_TARGET),i8086)
 | 
						|
PPSUF=8086
 | 
						|
endif
 | 
						|
ifeq ($(CPU_TARGET),avr)
 | 
						|
PPSUF=avr
 | 
						|
endif
 | 
						|
 | 
						|
# cross compilers uses full cpu_target, not just ppc-suffix
 | 
						|
# (except if the target cannot run a native compiler)
 | 
						|
ifdef CROSSCOMPILE
 | 
						|
ifneq ($(CPU_TARGET),jvm)
 | 
						|
PPPRE=ppcross
 | 
						|
else
 | 
						|
PPPRE=ppc
 | 
						|
endif
 | 
						|
else
 | 
						|
PPPRE=ppc
 | 
						|
endif
 | 
						|
 | 
						|
PPNEW=$(BASEDIR)/compiler/$(PPPRE)$(PPSUF)$(SRCEXEEXT)
 | 
						|
endif
 | 
						|
 | 
						|
# Use FPCFPMAKENEW to explicitly specify FPCFPMAKE.
 | 
						|
# Otherwise fpmkunit build will use wrong (starting) compiler
 | 
						|
# if there has been no compiler binary available in the compiler
 | 
						|
# dir before running make.
 | 
						|
ifndef FPCFPMAKENEW
 | 
						|
ifdef CROSSCOMPILE
 | 
						|
FPCFPMAKENEW=$(BASEDIR)/compiler/ppc$(SRCEXEEXT)
 | 
						|
else
 | 
						|
FPCFPMAKENEW=$(PPNEW)
 | 
						|
endif
 | 
						|
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 darwin
 | 
						|
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
 | 
						|
 | 
						|
# Always use newly created fpcmake
 | 
						|
ifndef FPCMAKENEW
 | 
						|
ifdef CROSSCOMPILE
 | 
						|
# Use bootstrapped fpcmake when cross-compiling
 | 
						|
FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(SRCEXEEXT)
 | 
						|
else
 | 
						|
# Use normal fpcmake
 | 
						|
FPCMAKENEW=$(BASEDIR)/utils/fpcm/bin/$(SOURCESUFFIX)/fpcmake$(SRCEXEEXT)
 | 
						|
endif
 | 
						|
endif
 | 
						|
 | 
						|
# Build/install options
 | 
						|
ifneq ($(OPT),)
 | 
						|
OPTNEW+=$(OPT)
 | 
						|
endif
 | 
						|
CLEANOPTS=FPC=$(PPNEW)
 | 
						|
BUILDOPTS=FPC=$(PPNEW) FPCFPMAKE=$(FPCFPMAKENEW) RELEASE=1 'OPT=$(OPTNEW)'
 | 
						|
INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
 | 
						|
 | 
						|
# 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),)
 | 
						|
IDETARGETS=go32v2 win32 win64 linux freebsd os2 emx beos haiku
 | 
						|
ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
 | 
						|
IDE=1
 | 
						|
endif
 | 
						|
endif
 | 
						|
endif
 | 
						|
 | 
						|
# CPU targets for which we only build the compiler/rtl
 | 
						|
BuildOnlyBaseCPUs=jvm
 | 
						|
 | 
						|
ifneq ($(wildcard utils),)
 | 
						|
NOUTILSTARGETS=embedded gba $(BuildOnlyBaseCPUs)
 | 
						|
ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
 | 
						|
ifdef BUILDFULLNATIVE
 | 
						|
UTILS=1
 | 
						|
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
 | 
						|
 | 
						|
 | 
						|
##########################################################################
 | 
						|
# Packaging
 | 
						|
##########################################################################
 | 
						|
 | 
						|
BUILDSTAMP=build-stamp.$(FULL_TARGET)
 | 
						|
 | 
						|
.PHONY: all clean distclean build buildbase install installbase
 | 
						|
.PHONY: installother zipinstallbase zipinstallotherzipinstall
 | 
						|
.PHONY: singlezipinstall versioncheckstartingcompiler
 | 
						|
 | 
						|
versioncheckstartingcompiler: 
 | 
						|
ifndef CROSSCOMPILE
 | 
						|
ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
 | 
						|
ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
 | 
						|
ifndef OVERRIDEVERSIONCHECK
 | 
						|
	$(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION). If you are absolutely sure that the current compiler is built from the exact same version/revision, you can try to use OVERRIDEVERSIONCHECK=1 to override )
 | 
						|
else
 | 
						|
	@$(ECHO) You have overriden the starting compiler versioncheck while using starting compiler version $(FPC_VERSION). This situation is not supported and strange things and errors may happen. Remove OVERRIDEVERSIONCHECK=1 to fix this. 
 | 
						|
endif
 | 
						|
endif
 | 
						|
endif
 | 
						|
endif
 | 
						|
 | 
						|
ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
 | 
						|
all: versioncheckstartingcompiler build
 | 
						|
install: installall
 | 
						|
zipinstall: zipinstallall
 | 
						|
else
 | 
						|
all: versioncheckstartingcompiler buildbase
 | 
						|
install: installbase
 | 
						|
zipinstall: zipinstallbase
 | 
						|
endif
 | 
						|
 | 
						|
clean: $(addsuffix _distclean,$(TARGET_DIRS))
 | 
						|
        -$(DEL) build-stamp.*
 | 
						|
        -$(DEL) base.build-stamp.*
 | 
						|
 | 
						|
distclean: clean
 | 
						|
 | 
						|
build: $(BUILDSTAMP)
 | 
						|
$(BUILDSTAMP):
 | 
						|
# create new compiler
 | 
						|
        $(MAKE) compiler_cycle RELEASE=1
 | 
						|
ifdef CROSSCOMPILE
 | 
						|
# Buld a new native fpcmake when cross-compiling.
 | 
						|
# Fresh native compiler and RTL are ready at this stage.
 | 
						|
        $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
 | 
						|
endif
 | 
						|
# clean
 | 
						|
        $(MAKE) rtl_clean $(CLEANOPTS)
 | 
						|
        $(MAKE) packages_clean $(CLEANOPTS)
 | 
						|
ifdef UTILS
 | 
						|
        $(MAKE) utils_clean $(CLEANOPTS)
 | 
						|
endif
 | 
						|
ifdef IDE
 | 
						|
        $(MAKE) ide_clean $(CLEANOPTS)
 | 
						|
        $(MAKE) installer_clean $(CLEANOPTS)
 | 
						|
endif
 | 
						|
# build everything
 | 
						|
        $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
 | 
						|
        $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
 | 
						|
ifdef UTILS
 | 
						|
        $(MAKE) utils_all $(BUILDOPTS)
 | 
						|
endif
 | 
						|
ifdef IDE
 | 
						|
        $(MAKE) ide_all $(BUILDOPTS)
 | 
						|
        $(MAKE) installer_all $(BUILDOPTS)
 | 
						|
endif
 | 
						|
        $(ECHOREDIR) Build > $(BUILDSTAMP)
 | 
						|
        $(ECHOREDIR) Build > base.$(BUILDSTAMP)
 | 
						|
 | 
						|
buildbase: base.$(BUILDSTAMP)
 | 
						|
base.$(BUILDSTAMP):
 | 
						|
# create new compiler
 | 
						|
        $(MAKE) compiler_cycle RELEASE=1
 | 
						|
ifdef CROSSCOMPILE
 | 
						|
# Buld a new native fpcmake when cross-compiling.
 | 
						|
# Fresh native compiler and RTL are ready at this stage.
 | 
						|
        $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
 | 
						|
endif
 | 
						|
# clean
 | 
						|
        $(MAKE) rtl_clean $(CLEANOPTS)
 | 
						|
# build everything
 | 
						|
        $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
 | 
						|
        $(ECHOREDIR) Build > base.$(BUILDSTAMP)
 | 
						|
 | 
						|
installbase: base.$(BUILDSTAMP)
 | 
						|
# 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 UTILS
 | 
						|
        $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
 | 
						|
endif
 | 
						|
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 UTILS
 | 
						|
        $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
 | 
						|
endif
 | 
						|
ifdef IDE
 | 
						|
        $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
 | 
						|
endif
 | 
						|
 | 
						|
 | 
						|
installall: $(BUILDSTAMP)
 | 
						|
        $(MAKE) installbase $(INSTALLOPTS)
 | 
						|
ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
 | 
						|
        $(MAKE) installother $(INSTALLOPTS)
 | 
						|
endif
 | 
						|
 | 
						|
singlezipinstall: zipinstallall
 | 
						|
zipinstallall: $(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)
 |