Browse Source

- removed freelabel()
* added undefined label detection in internal assembler, this prevents
a lot of ld crashes and wrong .o files
* .o files aren't written anymore if errors have occured
* inlining of assembler labels is now correct

peter 26 years ago
parent
commit
7583de7a4f

+ 869 - 2
compiler/Makefile

@@ -1,14 +1,137 @@
 #
 #
-# Makefile generated by fpcmake v0.99.13 on 1999-12-21 16:56
+# Makefile generated by fpcmake v0.99.13 on 1999-12-22 01:44
 #
 #
 
 
 defaultrule: all
 defaultrule: all
 
 
 #####################################################################
 #####################################################################
-# Autodetect OS (Linux or D
+# Autodetect OS (Linux or Dos or Windows NT)
+# define inlinux when running under linux
+# define inWinNT when running under WinNT
+#####################################################################
+
+# We need only / in the path
+override PATH:=$(subst \,/,$(PATH))
+
+# Search for PWD and determine also if we are under linux
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+ifeq ($(PWD),)
+nopwd:
+	@echo You need the GNU utils package to use this Makefile!
+	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
+	@exit
+else
+inlinux=1
+endif
+else
+PWD:=$(firstword $(PWD))
+endif
+
+# Detect NT - NT sets OS to Windows_NT
+ifndef inlinux
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+endif
+endif
+
+# Detect OS/2 - OS/2 has OS2_SHELL defined
+ifndef inlinux
+ifndef inWinNT
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+endif
 
 
+# The extension of executables
+ifdef inlinux
+EXEEXT=
+else
+EXEEXT=.exe
+endif
 
 
+# The path which is search separated by spaces
+ifdef inlinux
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
 
 
+#####################################################################
+# FPC version/target Detection
+#####################################################################
+
+# What compiler to use ?
+ifndef FPC
+# Compatibility with old makefiles
+ifdef PP
+export FPC=$(PP)
+else
+ifdef inOS2
+export FPC=ppos2$(EXEEXT)
+else
+export FPC=ppc386$(EXEEXT)
+endif
+endif
+endif
+
+# Target OS
+ifndef OS_TARGET
+export OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+
+# Source OS
+ifndef OS_SOURCE
+export OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+
+# Target CPU
+ifndef CPU_TARGET
+export CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+
+# Source CPU
+ifndef CPU_SOURCE
+export CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+
+# FPC version
+ifndef FPC_VERSION
+export FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+
+#####################################################################
+# Default Settings
+#####################################################################
+
+# Release ? Then force OPT and don't use extra opts via commandline
+ifndef REDIRFILE
+REDIRFILE=log
+endif
+
+ifdef RELEASE
+override OPT:=-Xs -OG2p3 -n
+endif
+
+# Verbose settings (warning,note,info)
+ifdef VERBOSE
+override OPT+=-vwni
+endif
+
+ifdef REDIR
+ifndef inlinux
+override FPC=redir -eo $(FPC)
+endif
+# set the verbosity to max
+override OPT+=-va
+override REDIR:= >> $(REDIRFILE)
+endif
+
+#####################################################################
+# User Settings
+#####################################################################
 
 
 
 
 # Pre Settings
 # Pre Settings
@@ -120,26 +243,483 @@ override LOCALOPT+=$(LOCALDEF)
 
 
 override FPCOPT+=$(LOCALOPT)
 override FPCOPT+=$(LOCALOPT)
 
 
+#####################################################################
+# Default Directories
+#####################################################################
+
+# Base dir
+ifdef PWD
+BASEDIR:=$(shell $(PWD))
+else
+BASEDIR=.
+endif
+
+# this can be set to 'rtl' when the RTL units are installed
+ifndef UNITPREFIX
+UNITPREFIX=units
+endif
+
+# set the prefix directory where to install everything
+ifndef PREFIXINSTALLDIR
+ifdef inlinux
+export PREFIXINSTALLDIR=/usr
+else
+export PREFIXINSTALLDIR=/pp
+endif
+endif
+
+# create fcldir,rtldir,unitdir
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifneq ($(FPCDIR),.)
+override RTLDIR=$(FPCDIR)/rtl/$(OS_TARGET)
+override FCLDIR=$(FPCDIR)/fcl/$(OS_TARGET)
+override UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
+endif
+endif
+
+#####################################################################
+# Install Directories
+#####################################################################
+
+# set the base directory where to install everything
+ifndef BASEINSTALLDIR
+ifdef inlinux
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
+else
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)
+endif
+endif
+
+# set the directory where to install the binaries
+ifndef BININSTALLDIR
+ifdef inlinux
+BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
+else
+BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
+endif
+endif
+
+# set the directory where to install the units.
+ifndef UNITINSTALLDIR
+UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET)
+endif
+
+# Where to install shared libraries
+ifndef LIBINSTALLDIR
+ifdef inlinux
+LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
+else
+LIBINSTALLDIR=$(UNITINSTALLDIR)
+endif
+endif
+
+# Where the source files will be stored
+ifndef SOURCEINSTALLDIR
+ifdef inlinux
+SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
+else
+SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
+endif
+endif
+
+# Where the doc files will be stored
+ifndef DOCINSTALLDIR
+ifdef inlinux
+DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION)
+else
+DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
+endif
+endif
+
+# Where the some extra (data)files will be stored
+ifndef EXTRAINSTALLDIR
+EXTRAINSTALLDIR=$(BASEINSTALLDIR)
+endif
+
+
+#####################################################################
+# Compiler Command Line
+#####################################################################
+
+# Load commandline OPTDEF and add FPC_CPU define
+override FPCOPTDEF:=-d$(CPU_TARGET)
+
+# Load commandline OPT and add target and unit dir to be sure
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+
+ifdef NEEDOPT
+override FPCOPT+=$(NEEDOPT)
+endif
+
+ifdef RTLDIR
+override FPCOPT+=-Fu$(RTLDIR)
+endif
+
+ifdef UNITSDIR
+override FPCOPT+=-Fu$(UNITSDIR)
+endif
+
+# Target dirs
+ifdef TARGETDIR
+override FPCOPT+=-FE$(TARGETDIR)
+endif
+
+# Smartlinking
+ifdef SMARTLINK
+override FPCOPT+=-CX
+endif
+
+# Debug
+ifdef DEBUG
+override FPCOPT+=-g
+endif
+
+# Add commandline options
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+
+# Add defines from FPCOPTDEF to FPCOPT
+ifdef FPCOPTDEF
+override FPCOPT+=$(FPCOPTDEF)
+endif
+
+# Error file ?
+ifdef ERRORFILE
+override FPCOPT+=-Fr$(ERRORFILE)
+endif
+
+# Was a config file specified ?
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+
+# For win32 the options are passed using the environment variable FPCEXTCMD
+ifeq ($(OS_SOURCE),win32)
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+
+# Compiler commandline
+override COMPILER:=$(FPC) $(FPCOPT)
+
+#####################################################################
+# Shell tools
+#####################################################################
+
+# To copy pograms
+ifndef COPY
+export COPY:=cp -fp
+endif
+
+# Copy a whole tree
+ifndef COPYTREE
+export COPYTREE:=cp -rfp
+endif
+
+# To move pograms
+ifndef MOVE
+export MOVE:=mv -f
+endif
+
+# Check delete program
+ifndef DEL
+export DEL:=rm -f
+endif
+
+# Check deltree program
+ifndef DELTREE
+export DELTREE:=rm -rf
+endif
+
+# To install files
+ifndef INSTALL
+ifdef inlinux
+export INSTALL:=install -m 644
+else
+export INSTALL:=$(COPY)
+endif
+endif
+
+# To install programs
+ifndef INSTALLEXE
+ifdef inlinux
+export INSTALLEXE:=install -m 755
+else
+export INSTALLEXE:=$(COPY)
+endif
+endif
+
+# To make a directory.
+ifndef MKDIR
+ifdef inlinux
+export MKDIR:=install -m 755 -d
+else
+export MKDIR:=ginstall -m 755 -d
+endif
+endif
+
+#####################################################################
+# Default Tools
+#####################################################################
+
+# assembler, redefine it if cross compiling
+ifndef AS
+AS=as
+endif
+
+# linker, but probably not used
+ifndef LD
+LD=ld
+endif
+
+# ppas.bat / ppas.sh
+ifdef inlinux
+PPAS=ppas.sh
+else
+ifdef inOS2
+PPAS=ppas.cmd
+else
+PPAS=ppas.bat
+endif
+endif
 
 
+# also call ppas if with command option -s
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+EXECPPAS:=@$(PPAS)
+endif
 
 
+# ldconfig to rebuild .so cache
+ifdef inlinux
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
 
 
+# echo
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+export ECHO:=echo
+else
+export ECHO:=$(firstword $(ECHO))
+endif
+endif
 
 
+# ppdep
+ifndef PPDEP
+PPDEP:=$(strip $(wildcard $(addsuffix /ppdep$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPDEP),)
+PPDEP=
+else
+export PPDEP:=$(firstword $(PPDEP))
+endif
+endif
 
 
+# ppumove
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+export PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
 
 
+# ppufiles
+ifndef PPUFILES
+PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUFILES),)
+PPUFILES=
+else
+export PPUFILES:=$(firstword $(PPUFILES))
+endif
+endif
 
 
+# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
+# upx uses that one itself (PFV)
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+export UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
 
 
+# gdate/date
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+export DATE:=$(firstword $(DATE))
+endif
+else
+export DATE:=$(firstword $(DATE))
+endif
+endif
 
 
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
 
 
+# ZipProg, you can't use Zip as the var name (PFV)
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+export ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
+endif
+endif
 
 
+ifndef ZIPEXT
+ZIPEXT=.zip
+endif
 
 
+# cmp
+ifndef CMP
+CMP:=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(CMP),)
+CMP=
+else
+export CMP:=$(firstword $(CMP))
+endif
+endif
 
 
+# diff
+ifndef DIFF
+DIFF:=$(strip $(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(DIFF),)
+DIFF=
+else
+export DIFF:=$(firstword $(DIFF))
+endif
+endif
 
 
+#####################################################################
+# Default extensions
+#####################################################################
 
 
+# Default needed extensions (Go32v2,Linux)
+LOADEREXT=.as
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+PACKAGESUFFIX=
+FPCMADE=fpcmade
+
+# Go32v1
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+PACKAGESUFFIX=v1
+FPCMADE=fpcmade.v1
+endif
 
 
+# Go32v2
+ifeq ($(OS_TARGET),go32v2)
+PACKAGESUFFIX=go32
+FPCMADE=fpcmade.dos
+endif
 
 
+# Linux
+ifeq ($(OS_TARGET),linux)
+PACKAGESUFFIX=linux
+FPCMADE=fpcmade.lnx
+endif
 
 
+# Win32
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+PACKAGESUFFIX=win32
+FPCMADE=fpcmade.w32
+endif
+
+# OS/2
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+PACKAGESUFFIX=os2
+FPCMADE=fpcmade.os2
+endif
+
+# library prefix
+LIBPREFIX=lib
+ifeq ($(OS_TARGET),go32v2)
+LIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v1)
+LIBPREFIX=
+endif
 
 
+# determine which .pas extension is used
+ifndef PASEXT
+ifdef EXEOBJECTS
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
+else
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
+endif
+ifeq ($(TESTPAS),)
+PASEXT=.pp
+else
+PASEXT=.pas
+endif
+endif
 
 
+#####################################################################
+# Standard rules
+#####################################################################
 
 
 debug: fpc_debug
 debug: fpc_debug
 
 
@@ -161,6 +741,9 @@ info: fpc_info
 
 
 .PHONY:  debug smart shared showinstall sourceinstall zipinstall zipinstalladd cleanall info
 .PHONY:  debug smart shared showinstall sourceinstall zipinstall zipinstalladd cleanall info
 
 
+#####################################################################
+# Package depends
+#####################################################################
 
 
 ifneq ($(wildcard $(RTLDIR)),)
 ifneq ($(wildcard $(RTLDIR)),)
 ifeq ($(wildcard $(RTLDIR)/$(FPCMADE)),)
 ifeq ($(wildcard $(RTLDIR)/$(FPCMADE)),)
@@ -172,16 +755,300 @@ endif
 
 
 .PHONY:  rtl_package
 .PHONY:  rtl_package
 
 
+#####################################################################
+# General compile rules
+#####################################################################
+
+.PHONY: fpc_all fpc_debug
 
 
+$(FPCMADE):
+	@$(ECHO) Compiled > $(FPCMADE)
 
 
+fpc_all: $(addsuffix _package,$(COMPILEPACKAGES)) \
+	 $(addsuffix _component,$(COMPILECOMPONENTS)) \
+	 $(ALLTARGET) $(FPCMADE)
 
 
+fpc_debug:
+	$(MAKE) all DEBUG=1
 
 
+# General compile rules, available for both possible PASEXT
 
 
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
 
 
+%$(PPUEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
 
 
+%$(PPUEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
 
 
+%$(EXEEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
 
 
+%$(EXEEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
 
 
+#####################################################################
+# Library
+#####################################################################
+
+.PHONY: fpc_smart fpc_shared
+
+# Default sharedlib units are all unit objects
+ifndef SHAREDLIBUNITOBJECTS
+SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
+endif
+
+fpc_smart:
+	$(MAKE) all SMARTLINK=1
+
+fpc_shared: all
+ifdef inlinux
+ifndef LIBNAME
+	@$(ECHO) LIBNAME not set
+else
+	$(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+
+#####################################################################
+# Install rules
+#####################################################################
+
+.PHONY: fpc_showinstall fpc_install
+
+ifdef EXTRAINSTALLUNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
+endif
+
+ifdef INSTALLPPUFILES
+ifdef PPUFILES
+ifdef inlinux
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES))
+INSTALLPPULIBFILES:=$(shell $(PPUFILES) -L $(INSTALLPPUFILES))
+else
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) $(INSTALLPPUFILES))
+endif
+else
+INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)))
+endif
+endif
+
+fpc_showinstall: $(SHOWINSTALLTARGET)
+ifdef INSTALLEXEFILES
+	@$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
+endif
+ifdef INSTALLPPUFILES
+	@$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
+ifneq ($(INSTALLPPULINKFILES),)
+	@$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	@$(ECHO) $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES))
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	@$(ECHO) $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFILES))
+endif
+
+fpc_install: $(INSTALLTARGET)
+# Create UnitInstallFiles
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(BININSTALLDIR)
+# Compress the exes if upx is defined
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	$(MKDIR) $(LIBINSTALLDIR)
+	$(INSTALL) $(INSTALLPPULIBFILES) $(LIBINSTALLDIR)
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	$(MKDIR) $(EXTRAINSTALLDIR)
+	$(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR)
+endif
+
+#####################################################################
+# Source install rules
+#####################################################################
+
+.PHONY: fpc_sourceinstall
+
+fpc_sourceinstall: clean
+	$(MKDIR) $(SOURCEINSTALLDIR)
+	$(COPYTREE) $(BASEDIR) $(SOURCEINSTALLDIR)
+
+#####################################################################
+# Zip
+#####################################################################
+
+.PHONY: fpc_zipinstall fpc_zipinstalladd
+
+# Temporary path to pack a file
+ifndef PACKDIR
+ifndef inlinux
+PACKDIR=pack_tmp
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+
+# Test dir if none specified
+ifndef DESTZIPDIR
+DESTZIPDIR:=$(BASEDIR)
+endif
+
+# Add .zip/.tar.gz extension
+ifdef ZIPNAME
+ifndef inlinux
+override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
+endif
+endif
+
+# Note: This will not remove the zipfile first
+fpc_zipinstalladd:
+ifndef ZIPNAME
+	@$(ECHO) Please specify ZIPNAME!
+	@exit
+else
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+ifdef inlinux
+	gzip -d $(DESTZIPDIR)/$(ZIPNAME).tar.gz
+	cd $(PACKDIR) ; tar rv --file $(DESTZIPDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
+	gzip $(DESTZIPDIR)/$(ZIPNAME).tar
+else
+	cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+# First remove the zip and then install
+fpc_zipinstall:
+ifndef ZIPNAME
+	@$(ECHO) Please specify ZIPNAME!
+	@exit
+else
+	$(DEL) $(DESTZIPDIR)/$(ZIPNAME)
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+ifdef inlinux
+	cd $(PACKDIR) ; tar cvz --file $(DESTZIPDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
+else
+	cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+#####################################################################
+# Clean rules
+#####################################################################
+
+.PHONY: fpc_clean fpc_cleanall
+
+ifdef EXTRACLEANUNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
+endif
+
+ifdef CLEANPPUFILES
+ifdef PPUFILES
+CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
+else
+CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)))
+endif
+endif
+
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef EXTRACLEANFILES
+	-$(DEL) $(EXTRACLEANFILES)
+endif
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(REDIRFILE)
+
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(REDIRFILE)
+
+#####################################################################
+# Info rules
+#####################################################################
+
+.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \
+	fpc_dirinfo
+
+fpc_info: $(INFOTARGET)
+
+fpc_infocfg:
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC....... $(FPC)
+	@$(ECHO)  Version... $(FPC_VERSION)
+	@$(ECHO)  CPU....... $(CPU_TARGET)
+	@$(ECHO)  Source.... $(OS_SOURCE)
+	@$(ECHO)  Target.... $(OS_TARGET)
+	@$(ECHO)
+
+fpc_infoobjects:
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  LoaderObjects..... $(LOADEROBJECTS)
+	@$(ECHO)  UnitObjects....... $(UNITOBJECTS)
+	@$(ECHO)  ExeObjects........ $(EXEOBJECTS)
+	@$(ECHO)
+	@$(ECHO)  ExtraCleanUnits... $(EXTRACLEANUNITS)
+	@$(ECHO)  ExtraCleanFiles... $(EXTRACLEANFILES)
+	@$(ECHO)
+	@$(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)
+	@$(ECHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)
+	@$(ECHO)
+
+fpc_infoinstall:
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+ifdef DATE
+	@$(ECHO)  DateStr.............. $(DATESTR)
+endif
+	@$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)
+	@$(ECHO)
+	@$(ECHO)  BaseInstallDir....... $(BASEINSTALLDIR)
+	@$(ECHO)  BinInstallDir........ $(BININSTALLDIR)
+	@$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)
+	@$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)
+	@$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)
+	@$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)
+	@$(ECHO)  ExtraInstallDir...... $(EXTRAINSTALLDIR)
+	@$(ECHO)
+
+#####################################################################
+# Users rules
+#####################################################################
 
 
 #####################################################################
 #####################################################################
 # Setup Targets
 # Setup Targets

+ 62 - 39
compiler/aasm.pas

@@ -92,7 +92,8 @@ unit aasm;
        pasmsymbol = ^tasmsymbol;
        pasmsymbol = ^tasmsymbol;
        tasmsymbol = object(tnamedindexobject)
        tasmsymbol = object(tnamedindexobject)
          typ     : TAsmsymtype;
          typ     : TAsmsymtype;
-         { this need te incremented with every symbol loading into the
+         proclocal : boolean;
+         { this need to be incremented with every symbol loading into the
            paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
            paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
          refs    : longint;
          refs    : longint;
          { the next fields are filled in the binary writer }
          { the next fields are filled in the binary writer }
@@ -100,10 +101,14 @@ unit aasm;
          section : tsection;
          section : tsection;
          address,
          address,
          size    : longint;
          size    : longint;
+         { alternate symbol which can be used for 'renaming' needed for
+           inlining }
+         altsymbol : pasmsymbol;
          constructor init(const s:string;_typ:TAsmsymtype);
          constructor init(const s:string;_typ:TAsmsymtype);
          procedure reset;
          procedure reset;
          function  is_used:boolean;
          function  is_used:boolean;
          procedure setaddress(sec:tsection;offset,len:longint);
          procedure setaddress(sec:tsection;offset,len:longint);
+         procedure GenerateAltSymbol;
        end;
        end;
 
 
        pasmlabel = ^tasmlabel;
        pasmlabel = ^tasmlabel;
@@ -337,6 +342,7 @@ type
       asmsymbollist : pasmsymbollist;
       asmsymbollist : pasmsymbollist;
 
 
     const
     const
+      nextaltnr   : longint = 1;
       nextlabelnr : longint = 1;
       nextlabelnr : longint = 1;
       countlabelref : boolean = true;
       countlabelref : boolean = true;
 
 
@@ -344,8 +350,6 @@ type
     procedure getlabel(var l : pasmlabel);
     procedure getlabel(var l : pasmlabel);
     { make l as a new label and flag is_data }
     { make l as a new label and flag is_data }
     procedure getdatalabel(var l : pasmlabel);
     procedure getdatalabel(var l : pasmlabel);
-    { free a label }
-    procedure freelabel(var l : pasmlabel);
     {just get a label number }
     {just get a label number }
     procedure getlabelnr(var l : longint);
     procedure getlabelnr(var l : longint);
 
 
@@ -355,7 +359,8 @@ type
     function  renameasmsymbol(const sold, snew : string):pasmsymbol;
     function  renameasmsymbol(const sold, snew : string):pasmsymbol;
 
 
     procedure ResetAsmsymbolList;
     procedure ResetAsmsymbolList;
-
+    procedure ResetAsmSymbolListAltSymbol;
+    procedure CheckAsmSymbolListUndefined;
 
 
 implementation
 implementation
 
 
@@ -813,6 +818,17 @@ uses
         typ:=_typ;
         typ:=_typ;
       end;
       end;
 
 
+    procedure tasmsymbol.GenerateAltSymbol;
+      begin
+        if not assigned(altsymbol) then
+         begin
+           new(altsymbol,init(name+'_'+tostr(nextaltnr),typ));
+           { also copy the amount of references }
+           altsymbol^.refs:=refs;
+           inc(nextaltnr);
+         end;
+      end;
+
     procedure tasmsymbol.reset;
     procedure tasmsymbol.reset;
       begin
       begin
         section:=sec_none;
         section:=sec_none;
@@ -820,6 +836,7 @@ uses
         size:=0;
         size:=0;
         idx:=-1;
         idx:=-1;
         typ:=AS_EXTERNAL;
         typ:=AS_EXTERNAL;
+        proclocal:=false;
         { mainly used to remove unused labels from the codesegment }
         { mainly used to remove unused labels from the codesegment }
         refs:=0;
         refs:=0;
       end;
       end;
@@ -846,6 +863,7 @@ uses
         labelnr:=nextlabelnr;
         labelnr:=nextlabelnr;
         inc(nextlabelnr);
         inc(nextlabelnr);
         inherited init(target_asm.labelprefix+tostr(labelnr),AS_LOCAL);
         inherited init(target_asm.labelprefix+tostr(labelnr),AS_LOCAL);
+        proclocal:=true;
         is_set:=false;
         is_set:=false;
       end;
       end;
 
 
@@ -918,40 +936,9 @@ uses
 
 
     { renames an asmsymbol }
     { renames an asmsymbol }
     function renameasmsymbol(const sold, snew : string):pasmsymbol;
     function renameasmsymbol(const sold, snew : string):pasmsymbol;
-{$ifdef nodictonaryrename}
-      var
-        hpold,hpnew : pasmsymbol;
-      begin
-        hpnew:=pasmsymbol(asmsymbollist^.search(snew));
-        if assigned(hpnew) then
-          internalerror(405405);
-        hpold:=pasmsymbol(asmsymbollist^.search(sold));
-        if not assigned(hpold) then
-          internalerror(405406);
-
-        hpnew:=new(pasmsymbol,init(sold));
-        { replace the old one }
-        { WARNING this heavily depends on the
-          feature that tdictionnary.insert does not delete
-          the tree element that it replaces !! }
-        asmsymbollist^.replace_existing:=true;
-        asmsymbollist^.insert(hpnew);
-        asmsymbollist^.replace_existing:=false;
-        { restore the tree }
-        hpnew^.left:=hpold^.left;
-        hpnew^.right:=hpold^.right;
-        stringdispose(hpold^._name);
-        hpold^._name:=stringdup(snew);
-        hpold^.speedvalue:=getspeedvalue(snew);
-        { now reinsert it at right location !! }
-        asmsymbollist^.insert(hpold);
-        renameasmsymbol:=hpold;
-      end;
-{$else}
       begin
       begin
         renameasmsymbol:=pasmsymbol(asmsymbollist^.rename(sold,snew));
         renameasmsymbol:=pasmsymbol(asmsymbollist^.rename(sold,snew));
       end;
       end;
-{$endif}
 
 
 
 
     procedure ResetAsmSym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
     procedure ResetAsmSym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
@@ -966,6 +953,32 @@ uses
       end;
       end;
 
 
 
 
+    procedure ResetAltSym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
+      begin
+        pasmsymbol(p)^.altsymbol:=nil;
+      end;
+
+
+    procedure ResetAsmSymbolListAltSymbol;
+      begin
+        asmsymbollist^.foreach({$ifndef TP}@{$endif}resetaltsym);
+      end;
+
+
+    procedure checkundefinedasmsym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
+      begin
+        if (pasmsymbol(p)^.refs>0) and
+           (pasmsymbol(p)^.section=Sec_none) and
+           (pasmsymbol(p)^.typ<>AS_EXTERNAL) then
+         Message1(asmw_e_undefined_label,pasmsymbol(p)^.name);
+      end;
+
+    procedure CheckAsmSymbolListUndefined;
+      begin
+        asmsymbollist^.foreach({$ifndef TP}@{$endif}checkundefinedasmsym);
+      end;
+
+
 {*****************************************************************************
 {*****************************************************************************
                               Label Helpers
                               Label Helpers
 *****************************************************************************}
 *****************************************************************************}
@@ -984,12 +997,15 @@ uses
       end;
       end;
 
 
 
 
-    procedure freelabel(var l : pasmlabel);
+    procedure RegenerateLabel(var l : pasmlabel);
       begin
       begin
-        { nothing to do, the dispose of the asmsymbollist will do it }
-        l:=nil;
+        if l^.proclocal then
+         getlabel(pasmlabel(l^.altsymbol))
+        else
+         getdatalabel(pasmlabel(l^.altsymbol));
       end;
       end;
 
 
+
     procedure getlabelnr(var l : longint);
     procedure getlabelnr(var l : longint);
       begin
       begin
          l:=nextlabelnr;
          l:=nextlabelnr;
@@ -1012,7 +1028,14 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.68  1999-11-06 14:34:16  peter
+  Revision 1.69  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.68  1999/11/06 14:34:16  peter
     * truncated log to 20 revs
     * truncated log to 20 revs
 
 
   Revision 1.67  1999/11/05 16:01:45  jonas
   Revision 1.67  1999/11/05 16:01:45  jonas

+ 29 - 4
compiler/ag386bin.pas

@@ -740,7 +740,7 @@ unit ag386bin;
         objectalloc^.setsection(sec_code);
         objectalloc^.setsection(sec_code);
         objectoutput^.defaultsection(sec_code);
         objectoutput^.defaultsection(sec_code);
 
 
-        { Pass 1 }
+      { Pass 1 }
         currpass:=1;
         currpass:=1;
 {$ifdef GDB}
 {$ifdef GDB}
         StartFileLineInfo;
         StartFileLineInfo;
@@ -754,8 +754,13 @@ unit ag386bin;
            hp:=TreePass1(hp);
            hp:=TreePass1(hp);
            MaybeNextList(hp);
            MaybeNextList(hp);
          end;
          end;
+        { check for undefined labels }
+        CheckAsmSymbolListUndefined;
         { set section sizes }
         { set section sizes }
         objectoutput^.setsectionsizes(objectalloc^.secsize);
         objectoutput^.setsectionsizes(objectalloc^.secsize);
+        { leave if errors have occured }
+        if errorcount>0 then
+         exit;
 
 
       { Pass 2 }
       { Pass 2 }
         currpass:=2;
         currpass:=2;
@@ -792,9 +797,14 @@ unit ag386bin;
            StartFileLineInfo;
            StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
            TreePass1(hp);
            TreePass1(hp);
-
-         { set section sizes }
+           { check for undefined labels }
+           CheckAsmSymbolListUndefined;
+           { set section sizes }
            objectoutput^.setsectionsizes(objectalloc^.secsize);
            objectoutput^.setsectionsizes(objectalloc^.secsize);
+           { leave if errors have occured }
+           if errorcount>0 then
+            exit;
+
          { Pass 2 }
          { Pass 2 }
            currpass:=2;
            currpass:=2;
 {$ifdef GDB}
 {$ifdef GDB}
@@ -805,6 +815,9 @@ unit ag386bin;
            if not MaybeNextList(hp) then
            if not MaybeNextList(hp) then
             break;
             break;
 
 
+           { leave if errors have occured }
+           if errorcount>0 then
+            exit;
            { write the current objectfile }
            { write the current objectfile }
            objectoutput^.donewriting;
            objectoutput^.donewriting;
 
 
@@ -879,6 +892,11 @@ unit ag386bin;
         else
         else
           writetree;
           writetree;
 
 
+        { leave if errors have occured }
+        if errorcount>0 then
+         exit;
+
+        { write last objectfile }
         objectoutput^.donewriting;
         objectoutput^.donewriting;
       end;
       end;
 
 
@@ -910,7 +928,14 @@ unit ag386bin;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  1999-12-08 10:39:59  pierre
+  Revision 1.31  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.30  1999/12/08 10:39:59  pierre
     + allow use of unit var in exports of DLL for win32
     + allow use of unit var in exports of DLL for win32
       by using direct export writing by default instead of use of DEFFILE
       by using direct export writing by default instead of use of DEFFILE
       that does not allow assembler labels that do not
       that does not allow assembler labels that do not

+ 20 - 8
compiler/cg386cal.pas

@@ -183,8 +183,6 @@ implementation
                    push_value_para(p^.left,inlined,para_offset,align);
                    push_value_para(p^.left,inlined,para_offset,align);
                 end;
                 end;
            end;
            end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
          { push from right to left }
          { push from right to left }
@@ -1158,19 +1156,24 @@ implementation
            oldprocsym : pprocsym;
            oldprocsym : pprocsym;
            para_size : longint;
            para_size : longint;
            oldprocinfo : pprocinfo;
            oldprocinfo : pprocinfo;
-           { just dummies for genentrycode }
+           oldinlining_procedure,
            nostackframe,make_global : boolean;
            nostackframe,make_global : boolean;
            proc_names : tstringcontainer;
            proc_names : tstringcontainer;
            inlineentrycode,inlineexitcode : paasmoutput;
            inlineentrycode,inlineexitcode : paasmoutput;
            oldexitlabel,oldexit2label,oldquickexitlabel:Pasmlabel;
            oldexitlabel,oldexit2label,oldquickexitlabel:Pasmlabel;
        begin
        begin
+          oldinlining_procedure:=inlining_procedure;
           oldexitlabel:=aktexitlabel;
           oldexitlabel:=aktexitlabel;
           oldexit2label:=aktexit2label;
           oldexit2label:=aktexit2label;
           oldquickexitlabel:=quickexitlabel;
           oldquickexitlabel:=quickexitlabel;
           getlabel(aktexitlabel);
           getlabel(aktexitlabel);
           getlabel(aktexit2label);
           getlabel(aktexit2label);
           oldprocsym:=aktprocsym;
           oldprocsym:=aktprocsym;
-          oldprocinfo:=procinfo;
+          { save old procinfo }
+          getmem(oldprocinfo,sizeof(tprocinfo));
+          move(procinfo^,oldprocinfo^,sizeof(tprocinfo));
+          { we're inlining a procedure }
+          inlining_procedure:=true;
           { set the return value }
           { set the return value }
           aktprocsym:=p^.inlineprocsym;
           aktprocsym:=p^.inlineprocsym;
           procinfo^.returntype:=aktprocsym^.definition^.rettype;
           procinfo^.returntype:=aktprocsym^.definition^.rettype;
@@ -1211,13 +1214,15 @@ implementation
               ungetpersistanttemp(st^.address_fixup);
               ungetpersistanttemp(st^.address_fixup);
               st^.address_fixup:=0;
               st^.address_fixup:=0;
             end;
             end;
+          { restore procinfo }
+          move(oldprocinfo^,procinfo^,sizeof(tprocinfo));
+          freemem(oldprocinfo,sizeof(tprocinfo));
+          { restore }
           aktprocsym:=oldprocsym;
           aktprocsym:=oldprocsym;
-          freelabel(aktexitlabel);
-          freelabel(aktexit2label);
           aktexitlabel:=oldexitlabel;
           aktexitlabel:=oldexitlabel;
           aktexit2label:=oldexit2label;
           aktexit2label:=oldexit2label;
           quickexitlabel:=oldquickexitlabel;
           quickexitlabel:=oldquickexitlabel;
-          procinfo:=oldprocinfo;
+          inlining_procedure:=oldinlining_procedure;
        end;
        end;
 
 
 
 
@@ -1225,7 +1230,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.112  1999-12-13 21:49:54  pierre
+  Revision 1.113  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.112  1999/12/13 21:49:54  pierre
    * bug in extdebugg code for inlined procedures
    * bug in extdebugg code for inlined procedures
 
 
   Revision 1.111  1999/11/30 10:40:42  peter
   Revision 1.111  1999/11/30 10:40:42  peter

+ 8 - 5
compiler/cg386cnv.pas

@@ -1009,8 +1009,6 @@ implementation
             (pfrom^.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (pfrom^.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            begin
            begin
               set_location(pto^.location,pfrom^.location);
               set_location(pto^.location,pfrom^.location);
-              freelabel(truelabel);
-              freelabel(falselabel);
               truelabel:=oldtruelabel;
               truelabel:=oldtruelabel;
               falselabel:=oldfalselabel;
               falselabel:=oldfalselabel;
               exit;
               exit;
@@ -1105,8 +1103,6 @@ implementation
          else
          else
            internalerror(10061);
            internalerror(10061);
          end;
          end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=oldtruelabel;
          truelabel:=oldtruelabel;
          falselabel:=oldfalselabel;
          falselabel:=oldfalselabel;
       end;
       end;
@@ -1490,7 +1486,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.96  1999-12-21 11:49:51  pierre
+  Revision 1.97  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.96  1999/12/21 11:49:51  pierre
    * array of char to short string bug fixed
    * array of char to short string bug fixed
 
 
   Revision 1.95  1999/12/01 12:42:31  peter
   Revision 1.95  1999/12/01 12:42:31  peter

+ 8 - 11
compiler/cg386flw.pas

@@ -97,9 +97,6 @@ implementation
          secondpass(p^.left);
          secondpass(p^.left);
          maketojumpbool(p^.left);
          maketojumpbool(p^.left);
          emitlab(lbreak);
          emitlab(lbreak);
-         freelabel(lloop);
-         freelabel(lcont);
-         freelabel(lbreak);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
 
 
@@ -154,8 +151,6 @@ implementation
            begin
            begin
               emitlab(truelabel);
               emitlab(truelabel);
            end;
            end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
       end;
       end;
@@ -366,9 +361,6 @@ implementation
          if temptovalue then
          if temptovalue then
            ungetiftemp(temp1);
            ungetiftemp(temp1);
 
 
-         freelabel(aktcontinuelabel);
-         freelabel(aktbreaklabel);
-         freelabel(l3);
          aktcontinuelabel:=oldclabel;
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
          aktbreaklabel:=oldblabel;
       end;
       end;
@@ -473,8 +465,6 @@ implementation
                         end;
                         end;
               end;
               end;
 do_jmp:
 do_jmp:
-              freelabel(truelabel);
-              freelabel(falselabel);
               truelabel:=otlabel;
               truelabel:=otlabel;
               falselabel:=oflabel;
               falselabel:=oflabel;
               emitjmp(C_None,aktexit2label);
               emitjmp(C_None,aktexit2label);
@@ -888,7 +878,14 @@ do_jmp:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  1999-12-19 17:02:45  peter
+  Revision 1.64  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.63  1999/12/19 17:02:45  peter
     * support exit,break,continue in try...except
     * support exit,break,continue in try...except
     * support break,continue in try...finally
     * support break,continue in try...finally
 
 

+ 8 - 3
compiler/cg386inl.pas

@@ -903,8 +903,6 @@ implementation
                  { call }
                  { call }
                  emitcall('FPC_ASSERT');
                  emitcall('FPC_ASSERT');
                  emitlab(truelabel);
                  emitlab(truelabel);
-                 freelabel(truelabel);
-                 freelabel(falselabel);
                  truelabel:=otlabel;
                  truelabel:=otlabel;
                  falselabel:=oflabel;
                  falselabel:=oflabel;
               end;
               end;
@@ -1481,7 +1479,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.85  1999-12-20 21:42:35  pierre
+  Revision 1.86  1999-12-22 01:01:46  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.85  1999/12/20 21:42:35  pierre
     + dllversion global variable
     + dllversion global variable
     * FPC_USE_CPREFIX code removed, not necessary anymore
     * FPC_USE_CPREFIX code removed, not necessary anymore
       as we use .edata direct writing by default now.
       as we use .edata direct writing by default now.

+ 8 - 3
compiler/cg386ld.pas

@@ -771,8 +771,6 @@ implementation
 {$EndIf regallocfix}
 {$EndIf regallocfix}
                            end;
                            end;
          end;
          end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
       end;
       end;
@@ -997,7 +995,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.91  1999-11-30 10:40:43  peter
+  Revision 1.92  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.91  1999/11/30 10:40:43  peter
     + ttype, tsymlist
     + ttype, tsymlist
 
 
   Revision 1.90  1999/11/06 14:34:18  peter
   Revision 1.90  1999/11/06 14:34:18  peter

+ 8 - 3
compiler/cg68kcal.pas

@@ -384,8 +384,6 @@ implementation
                                 end;
                                 end;
                 end;
                 end;
            end;
            end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
          { push from right to left }
          { push from right to left }
@@ -1069,7 +1067,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.21  1999-11-06 14:34:18  peter
+  Revision 1.22  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.21  1999/11/06 14:34:18  peter
     * truncated log to 20 revs
     * truncated log to 20 revs
 
 
   Revision 1.20  1999/09/27 23:44:48  peter
   Revision 1.20  1999/09/27 23:44:48  peter

+ 8 - 3
compiler/cg68kcnv.pas

@@ -1102,8 +1102,6 @@ implementation
          else
          else
            internalerror(10061);
            internalerror(10061);
          end;
          end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=oldtruelabel;
          truelabel:=oldtruelabel;
          falselabel:=oldfalselabel;
          falselabel:=oldfalselabel;
      end;
      end;
@@ -1361,7 +1359,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  1999-09-16 23:05:51  florian
+  Revision 1.15  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.14  1999/09/16 23:05:51  florian
     * m68k compiler is again compilable (only gas writer, no assembler reader)
     * m68k compiler is again compilable (only gas writer, no assembler reader)
 
 
   Revision 1.13  1999/08/25 11:59:48  jonas
   Revision 1.13  1999/08/25 11:59:48  jonas

+ 8 - 10
compiler/cg68kflw.pas

@@ -113,8 +113,6 @@ implementation
               truelabel:=otlabel;
               truelabel:=otlabel;
               falselabel:=oflabel;
               falselabel:=oflabel;
            end;
            end;
-         freelabel(l1);
-         freelabel(l2);
          aktcontinuelabel:=oldclabel;
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
          aktbreaklabel:=oldblabel;
       end;
       end;
@@ -160,8 +158,6 @@ implementation
            emitl(A_LABEL,falselabel);
            emitl(A_LABEL,falselabel);
          if not(assigned(p^.right)) then
          if not(assigned(p^.right)) then
            emitl(A_LABEL,truelabel);
            emitl(A_LABEL,truelabel);
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
       end;
       end;
@@ -362,9 +358,6 @@ implementation
          if temptovalue then
          if temptovalue then
            ungetiftemp(temp1);
            ungetiftemp(temp1);
 
 
-         freelabel(aktcontinuelabel);
-         freelabel(aktbreaklabel);
-         freelabel(l3);
          aktcontinuelabel:=oldclabel;
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
          aktbreaklabel:=oldblabel;
       end;
       end;
@@ -487,8 +480,6 @@ implementation
                         end;
                         end;
               end;
               end;
 do_jmp:
 do_jmp:
-              freelabel(truelabel);
-              freelabel(falselabel);
               truelabel:=otlabel;
               truelabel:=otlabel;
               falselabel:=oflabel;
               falselabel:=oflabel;
               emitl(A_JMP,aktexit2label);
               emitl(A_JMP,aktexit2label);
@@ -779,7 +770,14 @@ do_jmp:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  1999-11-09 23:06:44  peter
+  Revision 1.13  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.12  1999/11/09 23:06:44  peter
     * esi_offset -> selfpointer_offset to be newcg compatible
     * esi_offset -> selfpointer_offset to be newcg compatible
     * hcogegen -> cgbase fixes for newcg
     * hcogegen -> cgbase fixes for newcg
 
 

+ 8 - 3
compiler/cg68kld.pas

@@ -388,8 +388,6 @@ implementation
 
 
                            end;
                            end;
          end;
          end;
-         freelabel(truelabel);
-         freelabel(falselabel);
          truelabel:=otlabel;
          truelabel:=otlabel;
          falselabel:=oflabel;
          falselabel:=oflabel;
       end;
       end;
@@ -473,7 +471,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  1999-11-10 00:06:08  pierre
+  Revision 1.11  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.10  1999/11/10 00:06:08  pierre
    * adapted to procinfo as pointer
    * adapted to procinfo as pointer
 
 
   Revision 1.9  1999/09/16 23:05:51  florian
   Revision 1.9  1999/09/16 23:05:51  florian

+ 10 - 2
compiler/cgai386.pas

@@ -3362,7 +3362,8 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
           exprasmlist^.concat(new(paicpu,op_const(A_RET,S_NO,parasize)));
           exprasmlist^.concat(new(paicpu,op_const(A_RET,S_NO,parasize)));
        end;
        end;
 
 
-      exprasmlist^.concat(new(pai_symbol_end,initname(aktprocsym^.definition^.mangledname)));
+      if not inlined then
+        exprasmlist^.concat(new(pai_symbol_end,initname(aktprocsym^.definition^.mangledname)));
 
 
 {$ifdef GDB}
 {$ifdef GDB}
       if (cs_debuginfo in aktmoduleswitches) and not inlined  then
       if (cs_debuginfo in aktmoduleswitches) and not inlined  then
@@ -3446,7 +3447,14 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  1999-12-20 21:42:35  pierre
+  Revision 1.65  1999-12-22 01:01:47  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.64  1999/12/20 21:42:35  pierre
     + dllversion global variable
     + dllversion global variable
     * FPC_USE_CPREFIX code removed, not necessary anymore
     * FPC_USE_CPREFIX code removed, not necessary anymore
       as we use .edata direct writing by default now.
       as we use .edata direct writing by default now.

+ 13 - 22
compiler/cobjects.pas

@@ -1496,13 +1496,11 @@ end;
 
 
 
 
     function tdictionary.insertnode(newnode:Pnamedindexobject;var currnode:Pnamedindexobject):Pnamedindexobject;
     function tdictionary.insertnode(newnode:Pnamedindexobject;var currnode:Pnamedindexobject):Pnamedindexobject;
-      var
-        s1,s2:^string;
       begin
       begin
         if currnode=nil then
         if currnode=nil then
          begin
          begin
            currnode:=newnode;
            currnode:=newnode;
-           insertnode:=currnode;
+           insertnode:=newnode;
          end
          end
         { first check speedvalue, to allow a fast insert }
         { first check speedvalue, to allow a fast insert }
         else
         else
@@ -1513,27 +1511,13 @@ end;
           insertnode:=insertnode(newnode,currnode^.left)
           insertnode:=insertnode(newnode,currnode^.left)
         else
         else
          begin
          begin
-           new(s1);
-           new(s2);
-           s1^:=currnode^._name^;
-           s2^:=newnode^._name^;
-           if s1^>s2^ then
-            begin
-              dispose(s2);
-              dispose(s1);
-              insertnode:=insertnode(newnode,currnode^.right);
-            end
+           if currnode^._name^>newnode^._name^ then
+            insertnode:=insertnode(newnode,currnode^.right)
            else
            else
-            if s1^<s2^ then
-             begin
-               dispose(s2);
-               dispose(s1);
-               insertnode:=insertnode(newnode,currnode^.left);
-             end
+            if currnode^._name^<newnode^._name^ then
+             insertnode:=insertnode(newnode,currnode^.left)
            else
            else
             begin
             begin
-              dispose(s2);
-              dispose(s1);
               if replace_existing and
               if replace_existing and
                  assigned(currnode) then
                  assigned(currnode) then
                 begin
                 begin
@@ -2334,7 +2318,14 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.48  1999-12-06 18:21:03  peter
+  Revision 1.49  1999-12-22 01:01:48  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.48  1999/12/06 18:21:03  peter
     * support !ENVVAR for long commandlines
     * support !ENVVAR for long commandlines
     * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
     * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
       finally supported as installdir.
       finally supported as installdir.

+ 1 - 0
compiler/errore.msg

@@ -1357,6 +1357,7 @@ asmw_e_invalid_effective_address=E_Asm: Invalid effective address
 asmw_e_immediate_or_reference_expected=E_Asm: Immediate or reference expected
 asmw_e_immediate_or_reference_expected=E_Asm: Immediate or reference expected
 asmw_e_value_exceeds_bounds=E_Asm: $1 value exceeds bounds $2
 asmw_e_value_exceeds_bounds=E_Asm: $1 value exceeds bounds $2
 asmw_e_short_jmp_out_of_range=E_Asm: Short jump is out of range $1
 asmw_e_short_jmp_out_of_range=E_Asm: Short jump is out of range $1
+asmw_e_undefined_label=E_Asm: Undefined label $1
 
 
 
 
 #
 #

+ 9 - 1
compiler/globals.pas

@@ -138,6 +138,7 @@ unit globals;
        make_ref : boolean;
        make_ref : boolean;
        resolving_forward : boolean;      { used to add forward reference as second ref }
        resolving_forward : boolean;      { used to add forward reference as second ref }
        use_esp_stackframe : boolean;     { to test for call with ESP as stack frame }
        use_esp_stackframe : boolean;     { to test for call with ESP as stack frame }
+       inlining_procedure : boolean;     { are we inlining a procedure }
 
 
 {$ifdef TP}
 {$ifdef TP}
        use_big      : boolean;
        use_big      : boolean;
@@ -1421,7 +1422,14 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.41  1999-12-20 23:23:28  pierre
+  Revision 1.42  1999-12-22 01:01:48  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.41  1999/12/20 23:23:28  pierre
    + $description $version
    + $description $version
 
 
   Revision 1.40  1999/12/20 21:42:34  pierre
   Revision 1.40  1999/12/20 21:42:34  pierre

+ 1 - 0
compiler/msgidx.inc

@@ -423,6 +423,7 @@ type tmsgconst=(
   asmw_e_immediate_or_reference_expected,
   asmw_e_immediate_or_reference_expected,
   asmw_e_value_exceeds_bounds,
   asmw_e_value_exceeds_bounds,
   asmw_e_short_jmp_out_of_range,
   asmw_e_short_jmp_out_of_range,
+  asmw_e_undefined_label,
   exec_w_source_os_redefined,
   exec_w_source_os_redefined,
   exec_i_assembling_pipe,
   exec_i_assembling_pipe,
   exec_d_cant_create_asmfile,
   exec_d_cant_create_asmfile,

+ 70 - 68
compiler/msgtxt.inc

@@ -446,34 +446,35 @@ const msgtxt : array[0..000107,1..240] of char=(
   'E_Asm: Immediate or reference expected'#000+
   'E_Asm: Immediate or reference expected'#000+
   'E_Asm: $1 value exceeds bounds $2'#000+
   'E_Asm: $1 value exceeds bounds $2'#000+
   'E_Asm: Short jump is out of ran','ge $1'#000+
   'E_Asm: Short jump is out of ran','ge $1'#000+
+  'E_Asm: Undefined label $1'#000+
   'W_Source operating system redefined'#000+
   'W_Source operating system redefined'#000+
   'I_Assembling (pipe) $1'#000+
   'I_Assembling (pipe) $1'#000+
   'E_Can'#039't create assember file $1'#000+
   'E_Can'#039't create assember file $1'#000+
   'W_Assembler $1 not found, switching to external assembling'#000+
   'W_Assembler $1 not found, switching to external assembling'#000+
   'T_Using assembler: $1'#000+
   'T_Using assembler: $1'#000+
-  'W_Error while assembling exitcode $1'#000+
-  'W_Can'#039't call the assemble','r, error $1 switching to external assem'+
-  'bling'#000+
+  'W_Error while assembling exitcode $1',#000+
+  'W_Can'#039't call the assembler, error $1 switching to external assembl'+
+  'ing'#000+
   'I_Assembling $1'#000+
   'I_Assembling $1'#000+
   'I_Assembling smartlink $1'#000+
   'I_Assembling smartlink $1'#000+
   'W_Object $1 not found, Linking may fail !'#000+
   'W_Object $1 not found, Linking may fail !'#000+
   'W_Library $1 not found, Linking may fail !'#000+
   'W_Library $1 not found, Linking may fail !'#000+
   'W_Error while linking'#000+
   'W_Error while linking'#000+
-  'W_Can'#039't call the linker, switching to external',' linking'#000+
+  'W_Can'#039't call the lin','ker, switching to external linking'#000+
   'I_Linking $1'#000+
   'I_Linking $1'#000+
   'W_Util $1 not found, switching to external linking'#000+
   'W_Util $1 not found, switching to external linking'#000+
   'T_Using util $1'#000+
   'T_Using util $1'#000+
   'E_Creation of Executables not supported'#000+
   'E_Creation of Executables not supported'#000+
   'E_Creation of Dynamic/Shared Libraries not supported'#000+
   'E_Creation of Dynamic/Shared Libraries not supported'#000+
   'I_Closing script $1'#000+
   'I_Closing script $1'#000+
-  'W_resource compiler not found, switchi','ng to external mode'#000+
+  'W_resource c','ompiler not found, switching to external mode'#000+
   'I_Compiling resource $1'#000+
   'I_Compiling resource $1'#000+
   'F_Can'#039't post process executable $1'#000+
   'F_Can'#039't post process executable $1'#000+
   'F_Can'#039't open executable $1'#000+
   'F_Can'#039't open executable $1'#000+
   'X_Size of Code: $1 bytes'#000+
   'X_Size of Code: $1 bytes'#000+
   'X_Size of initialized data: $1 bytes'#000+
   'X_Size of initialized data: $1 bytes'#000+
   'X_Size of uninitialized data: $1 bytes'#000+
   'X_Size of uninitialized data: $1 bytes'#000+
-  'X_Stack space reserved: $1 bytes'#000,
+  'X_Stack',' space reserved: $1 bytes'#000+
   'X_Stack space commited: $1 bytes'#000+
   'X_Stack space commited: $1 bytes'#000+
   'T_Unitsearch: $1'#000+
   'T_Unitsearch: $1'#000+
   'T_PPU Loading $1'#000+
   'T_PPU Loading $1'#000+
@@ -483,8 +484,8 @@ const msgtxt : array[0..000107,1..240] of char=(
   'U_PPU Time: $1'#000+
   'U_PPU Time: $1'#000+
   'U_PPU File too short'#000+
   'U_PPU File too short'#000+
   'U_PPU Invalid Header (no PPU at the begin)'#000+
   'U_PPU Invalid Header (no PPU at the begin)'#000+
-  'U_PPU Invalid Version $1'#000+
-  'U_PPU is compiled for an',' other processor'#000+
+  'U_PPU Invalid Version $','1'#000+
+  'U_PPU is compiled for an other processor'#000+
   'U_PPU is compiled for an other target'#000+
   'U_PPU is compiled for an other target'#000+
   'U_PPU Source: $1'#000+
   'U_PPU Source: $1'#000+
   'U_Writing $1'#000+
   'U_Writing $1'#000+
@@ -492,103 +493,103 @@ const msgtxt : array[0..000107,1..240] of char=(
   'F_Error reading PPU-File'#000+
   'F_Error reading PPU-File'#000+
   'F_unexpected end of PPU-File'#000+
   'F_unexpected end of PPU-File'#000+
   'F_Invalid PPU-File entry: $1'#000+
   'F_Invalid PPU-File entry: $1'#000+
-  'F_PPU Dbx count problem'#000+
+  'F_PPU Dbx count problem',#000+
   'E_Illegal unit name: $1'#000+
   'E_Illegal unit name: $1'#000+
-  'F','_Too much units'#000+
+  'F_Too much units'#000+
   'F_Circular unit reference between $1 and $2'#000+
   'F_Circular unit reference between $1 and $2'#000+
   'F_Can'#039't compile unit $1, no sources available'#000+
   'F_Can'#039't compile unit $1, no sources available'#000+
   'F_Can'#039't find unit $1'#000+
   'F_Can'#039't find unit $1'#000+
   'W_Unit $1 was not found but $2 exists'#000+
   'W_Unit $1 was not found but $2 exists'#000+
   'F_Unit $1 searched but $2 found'#000+
   'F_Unit $1 searched but $2 found'#000+
-  'W_Compiling the system unit requires the -U','s switch'#000+
+  'W_Compiling the s','ystem unit requires the -Us switch'#000+
   'F_There were $1 errors compiling module, stopping'#000+
   'F_There were $1 errors compiling module, stopping'#000+
   'U_Load from $1 ($2) unit $3'#000+
   'U_Load from $1 ($2) unit $3'#000+
   'U_Recompiling $1, checksum changed for $2'#000+
   'U_Recompiling $1, checksum changed for $2'#000+
   'U_Recompiling $1, source found only'#000+
   'U_Recompiling $1, source found only'#000+
-  'U_Recompiling unit, static lib is older than ppufile'#000+
-  'U_Recompiling unit, sh','ared lib is older than ppufile'#000+
+  'U_Recompiling unit, static lib is older than ppuf','ile'#000+
+  'U_Recompiling unit, shared lib is older than ppufile'#000+
   'U_Recompiling unit, obj and asm are older than ppufile'#000+
   'U_Recompiling unit, obj and asm are older than ppufile'#000+
   'U_Recompiling unit, obj is older than asm'#000+
   'U_Recompiling unit, obj is older than asm'#000+
   'U_Parsing interface of $1'#000+
   'U_Parsing interface of $1'#000+
   'U_Parsing implementation of $1'#000+
   'U_Parsing implementation of $1'#000+
   'U_Second load for unit $1'#000+
   'U_Second load for unit $1'#000+
-  'U_PPU Check file $1 time $2'#000+
-  '$','1 [options] <inputfile> [options]'#000+
+  'U_P','PU Check file $1 time $2'#000+
+  '$1 [options] <inputfile> [options]'#000+
   'W_Only one source file supported'#000+
   'W_Only one source file supported'#000+
   'W_DEF file can be created only for OS/2'#000+
   'W_DEF file can be created only for OS/2'#000+
   'E_nested response files are not supported'#000+
   'E_nested response files are not supported'#000+
   'F_No source file name in command line'#000+
   'F_No source file name in command line'#000+
   'E_Illegal parameter: $1'#000+
   'E_Illegal parameter: $1'#000+
-  'H_-? writes help pages'#000+
-  'F_Too ','many config files nested'#000+
+  'H_-','? writes help pages'#000+
+  'F_Too many config files nested'#000+
   'F_Unable to open file $1'#000+
   'F_Unable to open file $1'#000+
   'N_Reading further options from $1'#000+
   'N_Reading further options from $1'#000+
   'W_Target is already set to: $1'#000+
   'W_Target is already set to: $1'#000+
   'W_Shared libs not supported on DOS platform, reverting to static'#000+
   'W_Shared libs not supported on DOS platform, reverting to static'#000+
   'F_too many IF(N)DEFs'#000+
   'F_too many IF(N)DEFs'#000+
-  'F_too many ENDIFs'#000+
-  'F_open conditional at',' the end of the file'#000+
+  'F_too many EN','DIFs'#000+
+  'F_open conditional at the end of the file'#000+
   'W_Debug information generation is not supported by this executable'#000+
   'W_Debug information generation is not supported by this executable'#000+
   'H_Try recompiling with -dGDB'#000+
   'H_Try recompiling with -dGDB'#000+
   'E_You are using the obsolete switch $1'#000+
   'E_You are using the obsolete switch $1'#000+
   'E_You are using the obsolete switch $1, please use $2'#000+
   'E_You are using the obsolete switch $1, please use $2'#000+
-  'N_Switching assembler to defau','lt source writing assembler'#000+
+  'N_Sw','itching assembler to default source writing assembler'#000+
   'Free Pascal Compiler version $FPCVER [$FPCDATE] for $FPCTARGET'#000+
   'Free Pascal Compiler version $FPCVER [$FPCDATE] for $FPCTARGET'#000+
   'Copyright (c) 1993-1999 by Florian Klaempfl'#000+
   'Copyright (c) 1993-1999 by Florian Klaempfl'#000+
   'Free Pascal Compiler version $FPCVER'#000+
   'Free Pascal Compiler version $FPCVER'#000+
   #000+
   #000+
   'Compiler Date  : $FPCDATE'#000+
   'Compiler Date  : $FPCDATE'#000+
-  'Compiler Target: $FPCTARGET'#000+
+  'Compiler Target',': $FPCTARGET'#000+
   #000+
   #000+
-  'This program',' comes under the GNU General Public Licence'#000+
+  'This program comes under the GNU General Public Licence'#000+
   'For more information read COPYING.FPC'#000+
   'For more information read COPYING.FPC'#000+
   #000+
   #000+
   'Report bugs,suggestions etc to:'#000+
   'Report bugs,suggestions etc to:'#000+
   '                 [email protected]'#000+
   '                 [email protected]'#000+
-  '**0*_put + after a boolean switch option to enable it, - to disable it'+
-  #000+
-  '**1','a_the compiler doesn'#039't delete the generated assembler file'#000+
+  '**0*_put + after a boolean switch option to enab','le it, - to disable '+
+  'it'#000+
+  '**1a_the compiler doesn'#039't delete the generated assembler file'#000+
   '**2al_list sourcecode lines in assembler file'#000+
   '**2al_list sourcecode lines in assembler file'#000+
   '**2ar_list register allocation/release info in assembler file'#000+
   '**2ar_list register allocation/release info in assembler file'#000+
-  '**2at_list temp allocation/release info in assembler file'#000+
-  '**1b_generate b','rowser info'#000+
+  '**2at_list temp allocation/release info in asse','mbler file'#000+
+  '**1b_generate browser info'#000+
   '**2bl_generate local symbol info'#000+
   '**2bl_generate local symbol info'#000+
   '**1B_build all modules'#000+
   '**1B_build all modules'#000+
   '**1C<x>_code generation options:'#000+
   '**1C<x>_code generation options:'#000+
   '3*2CD_create dynamic library'#000+
   '3*2CD_create dynamic library'#000+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#000+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#000+
   '**2Ci_IO-checking'#000+
   '**2Ci_IO-checking'#000+
-  '**2Cn_omit linking stage'#000+
-  '**2Co_check ove','rflow of integer operations'#000+
+  '**2Cn_omit lin','king stage'#000+
+  '**2Co_check overflow of integer operations'#000+
   '**2Cr_range checking'#000+
   '**2Cr_range checking'#000+
   '**2Cs<n>_set stack size to <n>'#000+
   '**2Cs<n>_set stack size to <n>'#000+
   '**2Ct_stack checking'#000+
   '**2Ct_stack checking'#000+
   '**2CD_create also dynamic library (* doesn'#039't work yet *)'#000+
   '**2CD_create also dynamic library (* doesn'#039't work yet *)'#000+
   '**2CX_create also smartlinked library'#000+
   '**2CX_create also smartlinked library'#000+
-  '**1d<x>_defines the symbol <x>'#000+
-  '*O1D_generate',' a DEF file'#000+
+  '**1d<x>_defines th','e symbol <x>'#000+
+  '*O1D_generate a DEF file'#000+
   '*O2Dd<x>_set description to <x>'#000+
   '*O2Dd<x>_set description to <x>'#000+
   '*O2Dw_PM application'#000+
   '*O2Dw_PM application'#000+
   '**1e<x>_set path to executable'#000+
   '**1e<x>_set path to executable'#000+
   '**1E_same as -Cn'#000+
   '**1E_same as -Cn'#000+
   '**1F<x>_set file names and paths:'#000+
   '**1F<x>_set file names and paths:'#000+
-  '**2FD<x>_sets the directory where to search for compiler utilities'#000+
-  '**2Fe<x>_redirect error ou','tput to <x>'#000+
+  '**2FD<x>_sets the directory where to search for compiler utilities'#000,
+  '**2Fe<x>_redirect error output to <x>'#000+
   '**2FE<x>_set exe/unit output path to <x>'#000+
   '**2FE<x>_set exe/unit output path to <x>'#000+
   '**2Fi<x>_adds <x> to include path'#000+
   '**2Fi<x>_adds <x> to include path'#000+
   '**2Fl<x>_adds <x> to library path'#000+
   '**2Fl<x>_adds <x> to library path'#000+
   '*L2FL<x>_uses <x> as dynamic linker'#000+
   '*L2FL<x>_uses <x> as dynamic linker'#000+
   '**2Fo<x>_adds <x> to object path'#000+
   '**2Fo<x>_adds <x> to object path'#000+
-  '**2Fr<x>_load error message file <x>'#000+
-  '**2Fu<x>_adds',' <x> to unit path'#000+
+  '**2Fr<x>_load error mess','age file <x>'#000+
+  '**2Fu<x>_adds <x> to unit path'#000+
   '**2FU<x>_set unit output path to <x>, overrides -FE'#000+
   '**2FU<x>_set unit output path to <x>, overrides -FE'#000+
   '*g1g<x>_generate debugger information:'#000+
   '*g1g<x>_generate debugger information:'#000+
   '*g2gg_use gsym'#000+
   '*g2gg_use gsym'#000+
   '*g2gd_use dbx'#000+
   '*g2gd_use dbx'#000+
   '*g2gh_use heap trace unit'#000+
   '*g2gh_use heap trace unit'#000+
   '*g2gc_generate checks for pointers'#000+
   '*g2gc_generate checks for pointers'#000+
-  '**1i_information'#000+
-  '**2iD_return compiler da','te'#000+
+  '**1i_informatio','n'#000+
+  '**2iD_return compiler date'#000+
   '**2iV_return compiler version'#000+
   '**2iV_return compiler version'#000+
   '**2iSO_return compiler OS'#000+
   '**2iSO_return compiler OS'#000+
   '**2iSP_return compiler processor'#000+
   '**2iSP_return compiler processor'#000+
@@ -596,85 +597,86 @@ const msgtxt : array[0..000107,1..240] of char=(
   '**2iTP_return target processor'#000+
   '**2iTP_return target processor'#000+
   '**1I<x>_adds <x> to include path'#000+
   '**1I<x>_adds <x> to include path'#000+
   '**1k<x>_Pass <x> to the linker'#000+
   '**1k<x>_Pass <x> to the linker'#000+
-  '**1l_write logo'#000+
-  '**1n_don'#039't re','ad the default config file'#000+
+  '**1','l_write logo'#000+
+  '**1n_don'#039't read the default config file'#000+
   '**1o<x>_change the name of the executable produced to <x>'#000+
   '**1o<x>_change the name of the executable produced to <x>'#000+
   '**1pg_generate profile code for gprof (defines FPC_PROFILE)'#000+
   '**1pg_generate profile code for gprof (defines FPC_PROFILE)'#000+
   '*L1P_use pipes instead of creating temporary assembler files'#000+
   '*L1P_use pipes instead of creating temporary assembler files'#000+
-  '**1S<x>_syntax options:'#000+
-  '**2S2_swit','ch some Delphi 2 extensions on'#000+
+  '**1S<x>_','syntax options:'#000+
+  '**2S2_switch some Delphi 2 extensions on'#000+
   '**2Sc_supports operators like C (*=,+=,/= and -=)'#000+
   '**2Sc_supports operators like C (*=,+=,/= and -=)'#000+
   '**2Sd_tries to be Delphi compatible'#000+
   '**2Sd_tries to be Delphi compatible'#000+
   '**2Se<x>_compiler stops after the <x> errors (default is 1)'#000+
   '**2Se<x>_compiler stops after the <x> errors (default is 1)'#000+
   '**2Sg_allow LABEL and GOTO'#000+
   '**2Sg_allow LABEL and GOTO'#000+
-  '**2Sh_Use ansistrings'#000+
-  '**2Si_support ','C++ styled INLINE'#000+
+  '**2Sh_Use ','ansistrings'#000+
+  '**2Si_support C++ styled INLINE'#000+
   '**2Sm_support macros like C (global)'#000+
   '**2Sm_support macros like C (global)'#000+
   '**2So_tries to be TP/BP 7.0 compatible'#000+
   '**2So_tries to be TP/BP 7.0 compatible'#000+
   '**2Sp_tries to be gpc compatible'#000+
   '**2Sp_tries to be gpc compatible'#000+
   '**2Ss_constructor name must be init (destructor must be done)'#000+
   '**2Ss_constructor name must be init (destructor must be done)'#000+
-  '**2St_allow static keyword in objects'#000+
-  '**1s_don'#039't ca','ll assembler and linker (only with -a)'#000+
+  '**2St_allow static keywor','d in objects'#000+
+  '**1s_don'#039't call assembler and linker (only with -a)'#000+
   '**1u<x>_undefines the symbol <x>'#000+
   '**1u<x>_undefines the symbol <x>'#000+
   '**1U_unit options:'#000+
   '**1U_unit options:'#000+
   '**2Un_don'#039't check the unit name'#000+
   '**2Un_don'#039't check the unit name'#000+
   '**2Us_compile a system unit'#000+
   '**2Us_compile a system unit'#000+
-  '**1v<x>_Be verbose. <x> is a combination of the following letters:'#000+
-  '**2*_e : Show errors (','default)       d : Show debug info'#000+
+  '**1v<x>_Be verbose. <x> is a combination of the following lette','rs:'#000+
+  '**2*_e : Show errors (default)       d : Show debug info'#000+
   '**2*_w : Show warnings               u : Show unit info'#000+
   '**2*_w : Show warnings               u : Show unit info'#000+
   '**2*_n : Show notes                  t : Show tried/used files'#000+
   '**2*_n : Show notes                  t : Show tried/used files'#000+
-  '**2*_h : Show hints                  m : Show defined macros'#000+
-  '**2*_i : Show general inf','o           p : Show compiled procedures'#000+
+  '**2*_h : Show hints                  m : Show defined macros',#000+
+  '**2*_i : Show general info           p : Show compiled procedures'#000+
   '**2*_l : Show linenumbers            c : Show conditionals'#000+
   '**2*_l : Show linenumbers            c : Show conditionals'#000+
   '**2*_a : Show everything             0 : Show nothing (except errors)'#000+
   '**2*_a : Show everything             0 : Show nothing (except errors)'#000+
-  '**2*_b : Show all procedure          r : Rhide/GCC compatibility mode'#000,
+  '**2*_b : Show all procedure          r : Rhi','de/GCC compatibility mod'+
+  'e'#000+
   '**2*_    declarations if an error    x : Executable info (Win32 only)'#000+
   '**2*_    declarations if an error    x : Executable info (Win32 only)'#000+
   '**2*_    occurs'#000+
   '**2*_    occurs'#000+
   '**1X_executable options:'#000+
   '**1X_executable options:'#000+
   '*L2Xc_link with the c library'#000+
   '*L2Xc_link with the c library'#000+
   '**2Xs_strip all symbols from executable'#000+
   '**2Xs_strip all symbols from executable'#000+
-  '**2XD_try to link dynamic          (defines FPC_LINK_DYNAMI','C)'#000+
+  '**2XD_try to link dynamic        ','  (defines FPC_LINK_DYNAMIC)'#000+
   '**2XS_try to link static (default) (defines FPC_LINK_STATIC)'#000+
   '**2XS_try to link static (default) (defines FPC_LINK_STATIC)'#000+
   '**2XX_try to link smart            (defines FPC_LINK_SMART)'#000+
   '**2XX_try to link smart            (defines FPC_LINK_SMART)'#000+
   '**0*_Processor specific options:'#000+
   '**0*_Processor specific options:'#000+
   '3*1A<x>_output format:'#000+
   '3*1A<x>_output format:'#000+
   '3*2Aas_assemble using GNU AS'#000+
   '3*2Aas_assemble using GNU AS'#000+
-  '3*2Aasaout_assemble using GNU A','S for aout (Go32v1)'#000+
+  '3*2Aa','saout_assemble using GNU AS for aout (Go32v1)'#000+
   '3*2Anasmcoff_coff (Go32v2) file using Nasm'#000+
   '3*2Anasmcoff_coff (Go32v2) file using Nasm'#000+
   '3*2Anasmelf_elf32 (Linux) file using Nasm'#000+
   '3*2Anasmelf_elf32 (Linux) file using Nasm'#000+
   '3*2Anasmobj_obj file using Nasm'#000+
   '3*2Anasmobj_obj file using Nasm'#000+
   '3*2Amasm_obj file using Masm (Microsoft)'#000+
   '3*2Amasm_obj file using Masm (Microsoft)'#000+
-  '3*2Atasm_obj file using Tasm (Borland)'#000+
-  '3*2Acoff_coff (Go32v2) ','using internal writer'#000+
+  '3*2Atasm_obj file using Tasm (Borlan','d)'#000+
+  '3*2Acoff_coff (Go32v2) using internal writer'#000+
   '3*2Apecoff_pecoff (Win32) using internal writer'#000+
   '3*2Apecoff_pecoff (Win32) using internal writer'#000+
   '3*1R<x>_assembler reading style:'#000+
   '3*1R<x>_assembler reading style:'#000+
   '3*2Ratt_read AT&T style assembler'#000+
   '3*2Ratt_read AT&T style assembler'#000+
   '3*2Rintel_read Intel style assembler'#000+
   '3*2Rintel_read Intel style assembler'#000+
-  '3*2Rdirect_copy assembler text directly to assembler file'#000+
-  '3*1O<x>_','optimizations:'#000+
+  '3*2Rdirect_copy assembler text directly ','to assembler file'#000+
+  '3*1O<x>_optimizations:'#000+
   '3*2Og_generate smaller code'#000+
   '3*2Og_generate smaller code'#000+
   '3*2OG_generate faster code (default)'#000+
   '3*2OG_generate faster code (default)'#000+
   '3*2Or_keep certain variables in registers (still BUGGY!!!)'#000+
   '3*2Or_keep certain variables in registers (still BUGGY!!!)'#000+
   '3*2Ou_enable uncertain optimizations (see docs)'#000+
   '3*2Ou_enable uncertain optimizations (see docs)'#000+
-  '3*2O1_level 1 optimizations (quick optimizations)'#000+
-  '3*2','O2_level 2 optimizations (-O1 + slower optimizations)'#000+
+  '3*2O1_level 1 optimizations',' (quick optimizations)'#000+
+  '3*2O2_level 2 optimizations (-O1 + slower optimizations)'#000+
   '3*2O3_level 3 optimizations (same as -O2u)'#000+
   '3*2O3_level 3 optimizations (same as -O2u)'#000+
   '3*2Op<x>_target processor:'#000+
   '3*2Op<x>_target processor:'#000+
   '3*3Op1_set target processor to 386/486'#000+
   '3*3Op1_set target processor to 386/486'#000+
-  '3*3Op2_set target processor to Pentium/PentiumMMX (tm)'#000+
-  '3*3Op3_set target proc','essor to PPro/PII/c6x86/K6 (tm)'#000+
+  '3*3Op2_set target processor to Pentium/PentiumMMX (','tm)'#000+
+  '3*3Op3_set target processor to PPro/PII/c6x86/K6 (tm)'#000+
   '3*1T<x>_Target operating system:'#000+
   '3*1T<x>_Target operating system:'#000+
   '3*2TGO32V1_version 1 of DJ Delorie DOS extender'#000+
   '3*2TGO32V1_version 1 of DJ Delorie DOS extender'#000+
   '3*2TGO32V2_version 2 of DJ Delorie DOS extender'#000+
   '3*2TGO32V2_version 2 of DJ Delorie DOS extender'#000+
   '3*2TLINUX_Linux'#000+
   '3*2TLINUX_Linux'#000+
   '3*2TOS2_OS/2 2.x'#000+
   '3*2TOS2_OS/2 2.x'#000+
-  '3*2TWin32_Windows 32 Bit'#000+
-  '3*2WB<x> Set Image ba','se to Hexadecimal <x> value'#000+
+  '3*2TWin32_Windows 32',' Bit'#000+
+  '3*2WB<x> Set Image base to Hexadecimal <x> value'#000+
   '3*2WC Specify console type application'#000+
   '3*2WC Specify console type application'#000+
   '3*2WD Use DEFFILE to export functions of DLL or EXE'#000+
   '3*2WD Use DEFFILE to export functions of DLL or EXE'#000+
   '3*2WG Specify graphic type application'#000+
   '3*2WG Specify graphic type application'#000+
-  '3*2WN Do not generate relocation code (necessary for debugging)'#000+
-  '3*2WR Generate rel','ocation code'#000+
+  '3*2WN Do not generate relocation code (necessary for deb','ugging)'#000+
+  '3*2WR Generate relocation code'#000+
   '6*1A<x>_output format'#000+
   '6*1A<x>_output format'#000+
   '6*2Aas_Unix o-file using GNU AS'#000+
   '6*2Aas_Unix o-file using GNU AS'#000+
   '6*2Agas_GNU Motorola assembler'#000+
   '6*2Agas_GNU Motorola assembler'#000+
@@ -682,14 +684,14 @@ const msgtxt : array[0..000107,1..240] of char=(
   '6*2Amot_Standard Motorola assembler'#000+
   '6*2Amot_Standard Motorola assembler'#000+
   '6*1O_optimizations:'#000+
   '6*1O_optimizations:'#000+
   '6*2Oa_turn on the optimizer'#000+
   '6*2Oa_turn on the optimizer'#000+
-  '6*2Og_generate smaller code'#000+
-  '6','*2OG_generate faster code (default)'#000+
+  '6*2','Og_generate smaller code'#000+
+  '6*2OG_generate faster code (default)'#000+
   '6*2Ox_optimize maximum (still BUGGY!!!)'#000+
   '6*2Ox_optimize maximum (still BUGGY!!!)'#000+
   '6*2O2_set target processor to a MC68020+'#000+
   '6*2O2_set target processor to a MC68020+'#000+
   '6*1R<x>_assembler reading style:'#000+
   '6*1R<x>_assembler reading style:'#000+
   '6*2RMOT_read motorola style assembler'#000+
   '6*2RMOT_read motorola style assembler'#000+
-  '6*1T<x>_Target operating system:'#000+
-  '6*2TAMIGA_Commodore',' Amiga'#000+
+  '6*1T<x>_Target operating s','ystem:'#000+
+  '6*2TAMIGA_Commodore Amiga'#000+
   '6*2TATARI_Atari ST/STe/TT'#000+
   '6*2TATARI_Atari ST/STe/TT'#000+
   '6*2TMACOS_Macintosh m68k'#000+
   '6*2TMACOS_Macintosh m68k'#000+
   '6*2TLINUX_Linux-68k'#000+
   '6*2TLINUX_Linux-68k'#000+

+ 875 - 2
compiler/new/Makefile

@@ -1,14 +1,137 @@
 #
 #
-# Makefile generated by fpcmake v0.99.13 on 1999-12-21 16:56
+# Makefile generated by fpcmake v0.99.13 on 1999-12-22 01:44
 #
 #
 
 
 defaultrule: all
 defaultrule: all
 
 
 #####################################################################
 #####################################################################
-# Autodetect OS (Linux or D
+# Autodetect OS (Linux or Dos or Windows NT)
+# define inlinux when running under linux
+# define inWinNT when running under WinNT
+#####################################################################
+
+# We need only / in the path
+override PATH:=$(subst \,/,$(PATH))
+
+# Search for PWD and determine also if we are under linux
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+ifeq ($(PWD),)
+nopwd:
+	@echo You need the GNU utils package to use this Makefile!
+	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
+	@exit
+else
+inlinux=1
+endif
+else
+PWD:=$(firstword $(PWD))
+endif
+
+# Detect NT - NT sets OS to Windows_NT
+ifndef inlinux
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+endif
+endif
+
+# Detect OS/2 - OS/2 has OS2_SHELL defined
+ifndef inlinux
+ifndef inWinNT
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+endif
+
+# The extension of executables
+ifdef inlinux
+EXEEXT=
+else
+EXEEXT=.exe
+endif
+
+# The path which is search separated by spaces
+ifdef inlinux
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
+
+#####################################################################
+# FPC version/target Detection
+#####################################################################
+
+# What compiler to use ?
+ifndef FPC
+# Compatibility with old makefiles
+ifdef PP
+export FPC=$(PP)
+else
+ifdef inOS2
+export FPC=ppos2$(EXEEXT)
+else
+export FPC=ppc386$(EXEEXT)
+endif
+endif
+endif
+
+# Target OS
+ifndef OS_TARGET
+export OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+
+# Source OS
+ifndef OS_SOURCE
+export OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+
+# Target CPU
+ifndef CPU_TARGET
+export CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+
+# Source CPU
+ifndef CPU_SOURCE
+export CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+
+# FPC version
+ifndef FPC_VERSION
+export FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+
+#####################################################################
+# Default Settings
+#####################################################################
 
 
+# Release ? Then force OPT and don't use extra opts via commandline
+ifndef REDIRFILE
+REDIRFILE=log
+endif
 
 
+ifdef RELEASE
+override OPT:=-Xs -OG2p3 -n
+endif
 
 
+# Verbose settings (warning,note,info)
+ifdef VERBOSE
+override OPT+=-vwni
+endif
+
+ifdef REDIR
+ifndef inlinux
+override FPC=redir -eo $(FPC)
+endif
+# set the verbosity to max
+override OPT+=-va
+override REDIR:= >> $(REDIRFILE)
+endif
+
+#####################################################################
+# User Settings
+#####################################################################
 
 
 
 
 # Pre Settings
 # Pre Settings
@@ -137,29 +260,492 @@ override LOCALOPT+=$(LOCALDEF)
 
 
 override FPCOPT+=$(LOCALOPT)
 override FPCOPT+=$(LOCALOPT)
 
 
+#####################################################################
+# Default Directories
+#####################################################################
 
 
+# Base dir
+ifdef PWD
+BASEDIR:=$(shell $(PWD))
+else
+BASEDIR=.
+endif
 
 
+# this can be set to 'rtl' when the RTL units are installed
+ifndef UNITPREFIX
+UNITPREFIX=units
+endif
 
 
+# set the prefix directory where to install everything
+ifndef PREFIXINSTALLDIR
+ifdef inlinux
+export PREFIXINSTALLDIR=/usr
+else
+export PREFIXINSTALLDIR=/pp
+endif
+endif
 
 
+# create fcldir,rtldir,unitdir
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifneq ($(FPCDIR),.)
+override RTLDIR=$(FPCDIR)/rtl/$(OS_TARGET)
+override FCLDIR=$(FPCDIR)/fcl/$(OS_TARGET)
+override UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
+endif
+endif
 
 
+#####################################################################
+# Install Directories
+#####################################################################
 
 
+# set the base directory where to install everything
+ifndef BASEINSTALLDIR
+ifdef inlinux
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
+else
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)
+endif
+endif
 
 
+# set the directory where to install the binaries
+ifndef BININSTALLDIR
+ifdef inlinux
+BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
+else
+BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
+endif
+endif
 
 
+# set the directory where to install the units.
+ifndef UNITINSTALLDIR
+UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET)
+endif
 
 
+# Where to install shared libraries
+ifndef LIBINSTALLDIR
+ifdef inlinux
+LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
+else
+LIBINSTALLDIR=$(UNITINSTALLDIR)
+endif
+endif
 
 
+# Where the source files will be stored
+ifndef SOURCEINSTALLDIR
+ifdef inlinux
+SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
+else
+SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
+endif
+endif
 
 
+# Where the doc files will be stored
+ifndef DOCINSTALLDIR
+ifdef inlinux
+DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION)
+else
+DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
+endif
+endif
 
 
+# Where the some extra (data)files will be stored
+ifndef EXTRAINSTALLDIR
+EXTRAINSTALLDIR=$(BASEINSTALLDIR)
+endif
+
+
+#####################################################################
+# Compiler Command Line
+#####################################################################
+
+# Load commandline OPTDEF and add FPC_CPU define
+override FPCOPTDEF:=-d$(CPU_TARGET)
 
 
+# Load commandline OPT and add target and unit dir to be sure
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+
+ifdef NEEDOPT
+override FPCOPT+=$(NEEDOPT)
+endif
+
+ifdef RTLDIR
+override FPCOPT+=-Fu$(RTLDIR)
+endif
 
 
+ifdef UNITSDIR
+override FPCOPT+=-Fu$(UNITSDIR)
+endif
 
 
+ifdef NEEDUNITDIR
+override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR))
+endif
 
 
+ifdef NEEDINCDIR
+override FPCOPT+=$(addprefix -Fi,$(NEEDINCDIR))
+endif
 
 
 
 
+# Target dirs
+ifdef TARGETDIR
+override FPCOPT+=-FE$(TARGETDIR)
+endif
 
 
+# Smartlinking
+ifdef SMARTLINK
+override FPCOPT+=-CX
+endif
 
 
+# Debug
+ifdef DEBUG
+override FPCOPT+=-g
+endif
 
 
+# Add commandline options
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
 
 
+# Add defines from FPCOPTDEF to FPCOPT
+ifdef FPCOPTDEF
+override FPCOPT+=$(FPCOPTDEF)
+endif
+
+# Error file ?
+ifdef ERRORFILE
+override FPCOPT+=-Fr$(ERRORFILE)
+endif
+
+# Was a config file specified ?
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+
+# For win32 the options are passed using the environment variable FPCEXTCMD
+ifeq ($(OS_SOURCE),win32)
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+
+# Compiler commandline
+override COMPILER:=$(FPC) $(FPCOPT)
+
+#####################################################################
+# Shell tools
+#####################################################################
+
+# To copy pograms
+ifndef COPY
+export COPY:=cp -fp
+endif
+
+# Copy a whole tree
+ifndef COPYTREE
+export COPYTREE:=cp -rfp
+endif
+
+# To move pograms
+ifndef MOVE
+export MOVE:=mv -f
+endif
+
+# Check delete program
+ifndef DEL
+export DEL:=rm -f
+endif
+
+# Check deltree program
+ifndef DELTREE
+export DELTREE:=rm -rf
+endif
 
 
+# To install files
+ifndef INSTALL
+ifdef inlinux
+export INSTALL:=install -m 644
+else
+export INSTALL:=$(COPY)
+endif
+endif
+
+# To install programs
+ifndef INSTALLEXE
+ifdef inlinux
+export INSTALLEXE:=install -m 755
+else
+export INSTALLEXE:=$(COPY)
+endif
+endif
+
+# To make a directory.
+ifndef MKDIR
+ifdef inlinux
+export MKDIR:=install -m 755 -d
+else
+export MKDIR:=ginstall -m 755 -d
+endif
+endif
+
+#####################################################################
+# Default Tools
+#####################################################################
+
+# assembler, redefine it if cross compiling
+ifndef AS
+AS=as
+endif
+
+# linker, but probably not used
+ifndef LD
+LD=ld
+endif
+
+# ppas.bat / ppas.sh
+ifdef inlinux
+PPAS=ppas.sh
+else
+ifdef inOS2
+PPAS=ppas.cmd
+else
+PPAS=ppas.bat
+endif
+endif
+
+# also call ppas if with command option -s
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+EXECPPAS:=@$(PPAS)
+endif
+
+# ldconfig to rebuild .so cache
+ifdef inlinux
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+
+# echo
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+export ECHO:=echo
+else
+export ECHO:=$(firstword $(ECHO))
+endif
+endif
+
+# ppdep
+ifndef PPDEP
+PPDEP:=$(strip $(wildcard $(addsuffix /ppdep$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPDEP),)
+PPDEP=
+else
+export PPDEP:=$(firstword $(PPDEP))
+endif
+endif
+
+# ppumove
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+export PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+
+# ppufiles
+ifndef PPUFILES
+PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUFILES),)
+PPUFILES=
+else
+export PPUFILES:=$(firstword $(PPUFILES))
+endif
+endif
+
+# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
+# upx uses that one itself (PFV)
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+export UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+
+# gdate/date
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+export DATE:=$(firstword $(DATE))
+endif
+else
+export DATE:=$(firstword $(DATE))
+endif
+endif
+
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+
+# ZipProg, you can't use Zip as the var name (PFV)
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+export ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
+endif
+endif
+
+ifndef ZIPEXT
+ZIPEXT=.zip
+endif
+
+# cmp
+ifndef CMP
+CMP:=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(CMP),)
+CMP=
+else
+export CMP:=$(firstword $(CMP))
+endif
+endif
+
+# diff
+ifndef DIFF
+DIFF:=$(strip $(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(DIFF),)
+DIFF=
+else
+export DIFF:=$(firstword $(DIFF))
+endif
+endif
+
+#####################################################################
+# Default extensions
+#####################################################################
+
+# Default needed extensions (Go32v2,Linux)
+LOADEREXT=.as
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+PACKAGESUFFIX=
+FPCMADE=fpcmade
+
+# Go32v1
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+PACKAGESUFFIX=v1
+FPCMADE=fpcmade.v1
+endif
+
+# Go32v2
+ifeq ($(OS_TARGET),go32v2)
+PACKAGESUFFIX=go32
+FPCMADE=fpcmade.dos
+endif
+
+# Linux
+ifeq ($(OS_TARGET),linux)
+PACKAGESUFFIX=linux
+FPCMADE=fpcmade.lnx
+endif
+
+# Win32
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+PACKAGESUFFIX=win32
+FPCMADE=fpcmade.w32
+endif
+
+# OS/2
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+PACKAGESUFFIX=os2
+FPCMADE=fpcmade.os2
+endif
+
+# library prefix
+LIBPREFIX=lib
+ifeq ($(OS_TARGET),go32v2)
+LIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v1)
+LIBPREFIX=
+endif
+
+# determine which .pas extension is used
+ifndef PASEXT
+ifdef EXEOBJECTS
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
+else
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
+endif
+ifeq ($(TESTPAS),)
+PASEXT=.pp
+else
+PASEXT=.pas
+endif
+endif
+
+#####################################################################
+# Standard rules
+#####################################################################
 
 
 debug: fpc_debug
 debug: fpc_debug
 
 
@@ -181,6 +767,9 @@ info: fpc_info
 
 
 .PHONY:  debug smart shared showinstall sourceinstall zipinstall zipinstalladd cleanall info
 .PHONY:  debug smart shared showinstall sourceinstall zipinstall zipinstalladd cleanall info
 
 
+#####################################################################
+# Package depends
+#####################################################################
 
 
 ifneq ($(wildcard $(RTLDIR)),)
 ifneq ($(wildcard $(RTLDIR)),)
 ifeq ($(wildcard $(RTLDIR)/$(FPCMADE)),)
 ifeq ($(wildcard $(RTLDIR)/$(FPCMADE)),)
@@ -192,16 +781,300 @@ endif
 
 
 .PHONY:  rtl_package
 .PHONY:  rtl_package
 
 
+#####################################################################
+# General compile rules
+#####################################################################
+
+.PHONY: fpc_all fpc_debug
+
+$(FPCMADE):
+	@$(ECHO) Compiled > $(FPCMADE)
+
+fpc_all: $(addsuffix _package,$(COMPILEPACKAGES)) \
+	 $(addsuffix _component,$(COMPILECOMPONENTS)) \
+	 $(ALLTARGET) $(FPCMADE)
+
+fpc_debug:
+	$(MAKE) all DEBUG=1
+
+# General compile rules, available for both possible PASEXT
+
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
+
+%$(PPUEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(PPUEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(EXEEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(EXEEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+#####################################################################
+# Library
+#####################################################################
+
+.PHONY: fpc_smart fpc_shared
 
 
+# Default sharedlib units are all unit objects
+ifndef SHAREDLIBUNITOBJECTS
+SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
+endif
 
 
+fpc_smart:
+	$(MAKE) all SMARTLINK=1
 
 
+fpc_shared: all
+ifdef inlinux
+ifndef LIBNAME
+	@$(ECHO) LIBNAME not set
+else
+	$(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
 
 
+#####################################################################
+# Install rules
+#####################################################################
 
 
+.PHONY: fpc_showinstall fpc_install
 
 
+ifdef EXTRAINSTALLUNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
+endif
 
 
+ifdef INSTALLPPUFILES
+ifdef PPUFILES
+ifdef inlinux
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES))
+INSTALLPPULIBFILES:=$(shell $(PPUFILES) -L $(INSTALLPPUFILES))
+else
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) $(INSTALLPPUFILES))
+endif
+else
+INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)))
+endif
+endif
 
 
+fpc_showinstall: $(SHOWINSTALLTARGET)
+ifdef INSTALLEXEFILES
+	@$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
+endif
+ifdef INSTALLPPUFILES
+	@$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
+ifneq ($(INSTALLPPULINKFILES),)
+	@$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	@$(ECHO) $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES))
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	@$(ECHO) $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFILES))
+endif
 
 
+fpc_install: $(INSTALLTARGET)
+# Create UnitInstallFiles
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(BININSTALLDIR)
+# Compress the exes if upx is defined
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	$(MKDIR) $(LIBINSTALLDIR)
+	$(INSTALL) $(INSTALLPPULIBFILES) $(LIBINSTALLDIR)
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	$(MKDIR) $(EXTRAINSTALLDIR)
+	$(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR)
+endif
+
+#####################################################################
+# Source install rules
+#####################################################################
+
+.PHONY: fpc_sourceinstall
+
+fpc_sourceinstall: clean
+	$(MKDIR) $(SOURCEINSTALLDIR)
+	$(COPYTREE) $(BASEDIR) $(SOURCEINSTALLDIR)
+
+#####################################################################
+# Zip
+#####################################################################
+
+.PHONY: fpc_zipinstall fpc_zipinstalladd
+
+# Temporary path to pack a file
+ifndef PACKDIR
+ifndef inlinux
+PACKDIR=pack_tmp
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
 
 
+# Test dir if none specified
+ifndef DESTZIPDIR
+DESTZIPDIR:=$(BASEDIR)
+endif
+
+# Add .zip/.tar.gz extension
+ifdef ZIPNAME
+ifndef inlinux
+override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
+endif
+endif
+
+# Note: This will not remove the zipfile first
+fpc_zipinstalladd:
+ifndef ZIPNAME
+	@$(ECHO) Please specify ZIPNAME!
+	@exit
+else
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+ifdef inlinux
+	gzip -d $(DESTZIPDIR)/$(ZIPNAME).tar.gz
+	cd $(PACKDIR) ; tar rv --file $(DESTZIPDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
+	gzip $(DESTZIPDIR)/$(ZIPNAME).tar
+else
+	cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+# First remove the zip and then install
+fpc_zipinstall:
+ifndef ZIPNAME
+	@$(ECHO) Please specify ZIPNAME!
+	@exit
+else
+	$(DEL) $(DESTZIPDIR)/$(ZIPNAME)
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+ifdef inlinux
+	cd $(PACKDIR) ; tar cvz --file $(DESTZIPDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
+else
+	cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+#####################################################################
+# Clean rules
+#####################################################################
+
+.PHONY: fpc_clean fpc_cleanall
+
+ifdef EXTRACLEANUNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
+endif
+
+ifdef CLEANPPUFILES
+ifdef PPUFILES
+CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
+else
+CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)))
+endif
+endif
+
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef EXTRACLEANFILES
+	-$(DEL) $(EXTRACLEANFILES)
+endif
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(REDIRFILE)
+
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(REDIRFILE)
+
+#####################################################################
+# Info rules
+#####################################################################
+
+.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \
+	fpc_dirinfo
+
+fpc_info: $(INFOTARGET)
+
+fpc_infocfg:
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC....... $(FPC)
+	@$(ECHO)  Version... $(FPC_VERSION)
+	@$(ECHO)  CPU....... $(CPU_TARGET)
+	@$(ECHO)  Source.... $(OS_SOURCE)
+	@$(ECHO)  Target.... $(OS_TARGET)
+	@$(ECHO)
+
+fpc_infoobjects:
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  LoaderObjects..... $(LOADEROBJECTS)
+	@$(ECHO)  UnitObjects....... $(UNITOBJECTS)
+	@$(ECHO)  ExeObjects........ $(EXEOBJECTS)
+	@$(ECHO)
+	@$(ECHO)  ExtraCleanUnits... $(EXTRACLEANUNITS)
+	@$(ECHO)  ExtraCleanFiles... $(EXTRACLEANFILES)
+	@$(ECHO)
+	@$(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)
+	@$(ECHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)
+	@$(ECHO)
+
+fpc_infoinstall:
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+ifdef DATE
+	@$(ECHO)  DateStr.............. $(DATESTR)
+endif
+	@$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)
+	@$(ECHO)
+	@$(ECHO)  BaseInstallDir....... $(BASEINSTALLDIR)
+	@$(ECHO)  BinInstallDir........ $(BININSTALLDIR)
+	@$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)
+	@$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)
+	@$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)
+	@$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)
+	@$(ECHO)  ExtraInstallDir...... $(EXTRAINSTALLDIR)
+	@$(ECHO)
+
+#####################################################################
+# Users rules
+#####################################################################
 
 
 #####################################################################
 #####################################################################
 # Setup Targets
 # Setup Targets

+ 64 - 28
compiler/pass_2.pas

@@ -120,65 +120,94 @@ implementation
 
 
 
 
     procedure secondasm(var p : ptree);
     procedure secondasm(var p : ptree);
+
+        procedure ReLabel(var p:pasmsymbol);
+        begin
+          if p^.proclocal then
+           begin
+             if not assigned(p^.altsymbol) then
+              p^.GenerateAltSymbol;
+             p:=p^.altsymbol;
+           end;
+        end;
+
       var
       var
         hp,hp2 : pai;
         hp,hp2 : pai;
         localfixup,parafixup,
         localfixup,parafixup,
         i : longint;
         i : longint;
         r : preference;
         r : preference;
+        skipnode : boolean;
       begin
       begin
-         if (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+         if inlining_procedure then
            begin
            begin
              localfixup:=aktprocsym^.definition^.localst^.address_fixup;
              localfixup:=aktprocsym^.definition^.localst^.address_fixup;
              parafixup:=aktprocsym^.definition^.parast^.address_fixup;
              parafixup:=aktprocsym^.definition^.parast^.address_fixup;
-             { first reallocate all local labels }
-             hp:=pai(p^.p_asm^.first);
-             while assigned(hp) do
-              begin
-                if hp^.typ=ait_label then
-                  if Copy(pai_label(hp)^.l^.name,1,length(target_asm.labelprefix))
-                     = target_asm.labelprefix then
-                    begin
-                      getlabel(pai_label(hp)^.l);
-                    end;
-                hp:=pai(hp^.next);
-              end;
+             ResetAsmSymbolListAltSymbol;
              hp:=pai(p^.p_asm^.first);
              hp:=pai(p^.p_asm^.first);
              while assigned(hp) do
              while assigned(hp) do
               begin
               begin
                 hp2:=pai(hp^.getcopy);
                 hp2:=pai(hp^.getcopy);
+                skipnode:=false;
                 case hp2^.typ of
                 case hp2^.typ of
+                  ait_label :
+                     begin
+                       { regenerate the labels by setting altsymbol }
+                       ReLabel(pai_label(hp2)^.l);
+                     end;
+                  ait_const_rva,
+                  ait_const_symbol :
+                     begin
+                       ReLabel(pai_const_symbol(hp2)^.sym);
+                     end;
                   ait_instruction :
                   ait_instruction :
                      begin
                      begin
 {$ifdef i386}
 {$ifdef i386}
                        { fixup the references }
                        { fixup the references }
                        for i:=1 to paicpu(hp2)^.ops do
                        for i:=1 to paicpu(hp2)^.ops do
-                        if paicpu(hp2)^.oper[i-1].typ=top_ref then
-                         begin
-                           r:=paicpu(hp2)^.oper[i-1].ref;
-                           case r^.options of
-                             ref_parafixup :
-                               r^.offsetfixup:=parafixup;
-                             ref_localfixup :
-                               r^.offsetfixup:=localfixup;
-                           end;
+                        case paicpu(hp2)^.oper[i-1].typ of
+                          top_ref :
+                            begin
+                              r:=paicpu(hp2)^.oper[i-1].ref;
+                              case r^.options of
+                                ref_parafixup :
+                                  r^.offsetfixup:=parafixup;
+                                ref_localfixup :
+                                  r^.offsetfixup:=localfixup;
+                              end;
+                              if assigned(r^.symbol) then
+                               ReLabel(r^.symbol);
+                            end;
+                          top_symbol :
+                            begin
+                              ReLabel(paicpu(hp2)^.oper[i-1].sym);
+                            end;
                          end;
                          end;
-                       exprasmlist^.concat(hp2);
 {$endif i386}
 {$endif i386}
                      end;
                      end;
                    ait_marker :
                    ait_marker :
                      begin
                      begin
                      { it's not an assembler block anymore }
                      { it's not an assembler block anymore }
-                       if not(pai_marker(hp2)^.kind in [AsmBlockStart, AsmBlockEnd]) then
-                        exprasmlist^.concat(hp2);
+                       if (pai_marker(hp2)^.kind in [AsmBlockStart, AsmBlockEnd]) then
+                        skipnode:=true;
                      end;
                      end;
                    else
                    else
-                     exprasmlist^.concat(hp2);
                 end;
                 end;
+                if not skipnode then
+                 exprasmlist^.concat(hp2)
+                else
+                 dispose(hp2,done);
                 hp:=pai(hp^.next);
                 hp:=pai(hp^.next);
               end
               end
            end
            end
          else
          else
-           exprasmlist^.concatlist(p^.p_asm);
+           begin
+             { if the routine is an inline routine, then we must hold a copy
+               becuase it can be necessary for inlining later }
+             if (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+               exprasmlist^.concatlistcopy(p^.p_asm)
+             else
+               exprasmlist^.concatlist(p^.p_asm);
+           end;
          if not p^.object_preserved then
          if not p^.object_preserved then
           begin
           begin
 {$ifdef i386}
 {$ifdef i386}
@@ -712,7 +741,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.46  1999-12-19 23:37:18  pierre
+  Revision 1.47  1999-12-22 01:01:52  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.46  1999/12/19 23:37:18  pierre
    * fix for web bug735
    * fix for web bug735
 
 
   Revision 1.45  1999/12/14 09:58:42  florian
   Revision 1.45  1999/12/14 09:58:42  florian

+ 8 - 3
compiler/pstatmnt.pas

@@ -152,7 +152,6 @@ unit pstatmnt;
                      (p^._low = hcaselabel^._high + 1) then
                      (p^._low = hcaselabel^._high + 1) then
                     begin
                     begin
                       p^._low := hcaselabel^._low;
                       p^._low := hcaselabel^._low;
-                      freelabel(hcaselabel^._at);
                       dispose(hcaselabel);
                       dispose(hcaselabel);
                     end
                     end
                   else
                   else
@@ -164,7 +163,6 @@ unit pstatmnt;
                        (p^._high+1 = hcaselabel^._low) then
                        (p^._high+1 = hcaselabel^._low) then
                       begin
                       begin
                         p^._high := hcaselabel^._high;
                         p^._high := hcaselabel^._high;
-                        freelabel(hcaselabel^._at);
                         dispose(hcaselabel);
                         dispose(hcaselabel);
                       end
                       end
                     else
                     else
@@ -1328,7 +1326,14 @@ unit pstatmnt;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.116  1999-12-14 09:58:42  florian
+  Revision 1.117  1999-12-22 01:01:52  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.116  1999/12/14 09:58:42  florian
     + compiler checks now if a goto leaves an exception block
     + compiler checks now if a goto leaves an exception block
 
 
   Revision 1.115  1999/12/01 22:43:17  peter
   Revision 1.115  1999/12/01 22:43:17  peter

+ 8 - 9
compiler/psub.pas

@@ -1639,14 +1639,6 @@ begin
 
 
    { restore filepos, the switches are already set }
    { restore filepos, the switches are already set }
    aktfilepos:=savepos;
    aktfilepos:=savepos;
-   { free labels }
-   freelabel(aktexitlabel);
-   freelabel(aktexit2label);
-   if (aktprocsym^.definition^.proctypeoption=potype_constructor) then
-     begin
-       freelabel(faillabel);
-       freelabel(quickexitlabel);
-     end;
    { restore labels }
    { restore labels }
    aktexitlabel:=oldexitlabel;
    aktexitlabel:=oldexitlabel;
    aktexit2label:=oldexit2label;
    aktexit2label:=oldexit2label;
@@ -1941,7 +1933,14 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.38  1999-12-06 18:17:09  peter
+  Revision 1.39  1999-12-22 01:01:52  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.38  1999/12/06 18:17:09  peter
     * newcg compiler compiles again
     * newcg compiler compiles again
 
 
   Revision 1.37  1999/11/30 10:40:48  peter
   Revision 1.37  1999/11/30 10:40:48  peter

+ 8 - 4
compiler/tree.pas

@@ -481,9 +481,6 @@ unit tree;
            deletecaselabels(p^.greater);
            deletecaselabels(p^.greater);
          if assigned(p^.less) then
          if assigned(p^.less) then
            deletecaselabels(p^.less);
            deletecaselabels(p^.less);
-         freelabel(p^._at);
-         if p^.firstlabel then
-          freelabel(p^.statement);
          dispose(p);
          dispose(p);
       end;
       end;
 
 
@@ -1898,7 +1895,14 @@ unit tree;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.105  1999-12-14 09:58:42  florian
+  Revision 1.106  1999-12-22 01:01:52  peter
+    - removed freelabel()
+    * added undefined label detection in internal assembler, this prevents
+      a lot of ld crashes and wrong .o files
+    * .o files aren't written anymore if errors have occured
+    * inlining of assembler labels is now correct
+
+  Revision 1.105  1999/12/14 09:58:42  florian
     + compiler checks now if a goto leaves an exception block
     + compiler checks now if a goto leaves an exception block
 
 
   Revision 1.104  1999/11/30 10:40:59  peter
   Revision 1.104  1999/11/30 10:40:59  peter