diff --git a/fcl/inc/process.pp b/fcl/inc/process.pp new file mode 100644 index 0000000000..aab23fe52c --- /dev/null +++ b/fcl/inc/process.pp @@ -0,0 +1,380 @@ +unit Process; + +{$mode delphi} +{$H+} + +interface + +Uses Classes,Pipes,Windows; + +Type + TProcessOptions = (poExecuteOnCreate,poRunSuspended,poUsePipes, + poNoConsole,poStderrToOutPut,poWaitOnExit); + + TCreateOptions = Set of TPRocessOptions; + + TProcess = Class (TObject) + Private + FAccess : Cardinal; + FApplicationName : string; + FChildErrorStream : TOutPutPipeStream; + FChildInputSTream : TInputPipeStream; + FChildOutPutStream : TOutPutPipeStream; + FConsoleTitle : String; + FCreateOptions : TCreateOptions; + FCreationFlags : Cardinal; + FCommandLine : String; + FCurrentDirectory : String; + FDeskTop : String; + FEnvironment : Pointer; + FExitCode : Cardinal; + FHandle : THandle; + FInherithandles : LongBool; + FParentErrorStream : TInputPipeStream; + FParentInputSTream : TInputPipeStream; + FParentOutputStream : TOutPutPipeStream; + FPrepared : Boolean; + FProcessAttributes : PSecurityAttributes; + FProcessInformation : TProcessInformation; + FRunning : Boolean; + FStartupInfo : TStartupInfo; + FThreadAttributes : PSecurityAttributes; + Procedure FreeStreams; + Function GetExitStatus : Integer; + Function GetHandle : THandle; + Function GetProcessAttributes : TSecurityAttributes; + Function GetRunning : Boolean; + Function GetThreadAttributes : TSecurityAttributes; + Function GetWindowRect : TRect; + Procedure SetFillAttribute (Value : Cardinal); + Procedure SetProcessAttributes (Value : TSecurityAttributes); + Procedure SetShowWindow (Value : Word); + Procedure SetThreadAttributes (Value : TSecurityAttributes); + Procedure SetWindowColumns (Value : Cardinal); + Procedure SetWindowHeight (Value : Cardinal); + Procedure SetWindowLeft (Value : Cardinal); + Procedure SetWindowRect (Value : TRect); + Procedure SetWindowRows (Value : Cardinal); + Procedure SetWindowTop (Value : Cardinal); + Procedure SetWindowWidth (Value : Cardinal); + Public + Constructor Create (Const ACommandline : String; + Options : TCreateOptions); + Destructor Destroy; override; + Procedure Execute; virtual; + Function Resume : Integer; virtual; + Function Suspend : Integer; virtual; + Function Terminate (AExitCode : Integer): Boolean; virtual; + Function WaitOnExit : DWord; + + Property ApplicationName : String Read FApplicationname + Write FApplicationname; + Property CommandLine : String Read FCommandLine; + Property ConsoleTitle : String Read FConsoleTitle Write FConsoleTitle; + Property CurrentDirectory : String Read FCurrentDirectory + Write FCurrentDirectory; + Property CreateOptions : TCreateOptions Read FCreateOptions; + Property CreationFlags : Cardinal Read FCreationFlags Write FCreationFlags; + Property DeskTop : String Read FDeskTop Write FDeskTop; + Property Environment : Pointer Read FEnvironment Write FEnvironment; + Property ExitStatus : Integer Read GetExitStatus; + Property FillAttribute : Cardinal Read FStartupInfo.dwFillAttribute + Write SetFillAttribute; + Property Handle : THandle Read FProcessInformation.hProcess; + Property Input : TOutPutPipeStream Read FParentOutPutStream; + Property InheritHandles : LongBool Read FInheritHandles; + Property OutPut : TInputPipeStream Read FParentInputStream; + Property ProcessAttributes : TSecurityAttributes + Read GetProcessAttributes + Write SetProcessAttributes; + Property ProcessInformation : TProcessInformation + Read FPRocessInformation; + Property Running : Boolean Read GetRunning; + Property ShowWindow : Word Read FStartupInfo.wShowWindow + Write SetShowWindow; + Property StartupInfo : TStartupInfo Read FStartupInfo; + Property StdErr : TinputPipeStream Read FParentErrorStream; + Property ThreadAttributes : TSecurityAttributes + Read GetThreadAttributes + Write SetThreadAttributes; + Property ThreadHandle : THandle Read FprocessInformation.hThread; + Property WindowColumns : Cardinal Read FStartupInfo.dwXCountchars + Write SetWindowColumns; + Property WindowHeight : Cardinal Read FStartupInfo.dwYsize + Write SetWindowHeight; + Property WindowLeft : Cardinal Read FStartupInfo.dwx + Write SetWindowLeft; + Property WindowRows : Cardinal Read FStartupInfo.dwYcountChars + Write SetWindowRows; + Property WindowTop : Cardinal Read FStartupInfo.dwy + Write SetWindowTop ; + Property WindowWidth : Cardinal Read FStartupInfo.dwXsize + Write SetWindowWidth; + Property WindowRect : Trect Read GetWindowRect + Write SetWindowRect; + + end; + +implementation + +Constructor TProcess.Create (Const ACommandline : String; + Options : TCreateOptions); +begin + Inherited create; + FCreateOptions:=Options; + FCommandLine:=ACommandLine; + FAccess:=PROCESS_ALL_ACCESS; + FStartupInfo.cb:=SizeOf(TStartupInfo); + FInheritHandles:=True; + If poExecuteOnCreate in FCreateOptions then + execute; +end; + +Destructor TProcess.Destroy; + +begin + If assigned (FProcessAttributes) then Dispose (FPRocessAttributes); + If assigned (FThreadAttributes) then Dispose (FThreadAttributes); + FreeStreams; +end; + +Procedure TProcess.FreeStreams; + +begin + FParentErrorStream.Free; + FParentInputSTream.Free; + FParentOutputStream.Free; + FChildErrorStream.free; + FChildInputSTream.Free; + FChildOutPutStream.Free; +end; + +Function TProcess.GetExitStatus : Integer; + +begin + If FRunning then + GetExitCodeProcess(Handle,@FExitCode); + Result:=FExitCode; +end; + +Function TProcess.GetHandle : THandle; + +begin + IF FHandle=0 Then + FHandle:=OpenProcess (FAccess,True,FProcessInformation.dwProcessId); + Result:=FHandle +end; + +Function TProcess.GetProcessAttributes : TSecurityAttributes; + +Var P : PSecurityAttributes; + +begin + IF not Assigned(FProcessAttributes) then + begin + // Provide empty dummy value; + New(p); + Fillchar(p^,Sizeof(TSecurityAttributes),0); + Result:=p^; + end + else + REsult:=FProcessAttributes^; +end; + +Function TProcess.GetRunning : Boolean; + +begin + IF FRunning then + Frunning:=GetExitStatus=Still_Active; + Result:=FRunning; +end; + +Function TProcess.GetThreadAttributes : TSecurityAttributes; + +Var P : PSecurityAttributes; + +begin + IF not Assigned(FThreadAttributes) then + begin + // Provide empty dummy value; + New(p); + Fillchar(p^,Sizeof(TSecurityAttributes),0); + Result:=p^; + end + else + Result:=FThreadAttributes^; +end; + +Procedure TProcess.SetProcessAttributes (Value : TSecurityAttributes); + +begin + If not Assigned (FProcessAttributes) then + New(FProcessAttributes); + FPRocessAttributes^:=VAlue; +end; + +Procedure TProcess.SetThreadAttributes (Value : TSecurityAttributes); + +begin + If not Assigned (FThreadAttributes) then + New(FThreadAttributes); + FThreadAttributes^:=VAlue; +end; + +Procedure TProcess.Execute; + +Var PName,PDir : PChar; + +begin + if poNoConsole in FCReateOptions then + FCreationFlags:=FCreationFlags or Detached_Process; + If poRunSuspended in FCreateOptions Then + FCreationFlags:=FCreationFlags or Create_Suspended; + If poUsePipes in FCreateOptions then + begin + FreeStreams; +{ // This construct was supported on Win32 only. The new call takes this as a default. + CreatePipeStreams (FChildInputSTream,FParentOutPutStream,@piInheritablePipe,1024); + CreatePipeStreams (FParentInputStream,FChildOutPutStream,@piInheritablePipe,1024); +} + CreatePipeStreams (FChildInputSTream,FParentOutPutStream); + CreatePipeStreams (FParentInputStream,FChildOutPutStream); + if poStdErrToOutPut in FCreateOptions then +{ + CreatePipeStreams (FParentErrorStream,FChildErrorStream,@piInheritablePipe,1024) +} + CreatePipeStreams (FParentErrorStream,FChildErrorStream) + else + begin + FChildErrorStream:=FChildOutPutStream; + FParentErrorStream:=FParentInputStream; + end; + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseStdHandles; + FStartupInfo.hStdInput:=FChildInputStream.Handle; + FStartupInfo.hStdOutput:=FChildOutPutStream.Handle; + FStartupInfo.hStdError:=FChildErrorStream.Handle; + end; + If FApplicationName<>'' then PName:=Pchar(FApplicationName) else PName:=Nil; + If FCurrentDirectory<>'' then PName:=Pchar(FCurrentDirectory) else PDir:=Nil; + CreateProcess (Pname,PChar(FCommandLine),FProcessAttributes,FThreadAttributes, + FInheritHandles,FCreationFlags,FEnvironment,PDir,@FStartupInfo, + @fProcessInformation); + FRunning:=True; + if (poWaitOnExit in FCreateOptions) and + not (poRunSuspended in FCreateOptions) then + WaitOnExit; +end; + +Function TProcess.WaitOnExit : Dword; + +begin + Result:=WaitForSingleObject (FprocessInformation.hProcess,Infinite); + If Result<>Wait_Failed then + GetExitStatus; + FRunning:=False; +end; + +Function TProcess.Suspend : Longint; + +begin + Result:=SuspendThread(ThreadHandle); +end; + +Function TProcess.Resume : LongInt; + +begin + Result:=ResumeThread(ThreadHandle); +end; + +Function TProcess.Terminate(AExitCode : Integer) : Boolean; + +begin + Result:=False; + If ExitStatus=Still_active then + Result:=TerminateProcess(Handle,AexitCode); +end; + +Procedure TProcess.SetFillAttribute (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseFillAttribute; + FStartupInfo.dwFillAttribute:=Value; +end; + +Procedure TProcess.SetShowWindow (Value : Word); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseShowWindow; + FStartupInfo.dwXCountChars:=Value; +end; + +Procedure TProcess.SetWindowColumns (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseCountChars; + FStartupInfo.dwXCountChars:=Value; +end; + + +Procedure TProcess.SetWindowHeight (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UsePosition; + FStartupInfo.dwYsize:=Value; +end; + +Procedure TProcess.SetWindowLeft (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseSize; + FStartupInfo.dwx:=Value; +end; + +Procedure TProcess.SetWindowTop (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseSize; + FStartupInfo.dwy:=Value; +end; + +Procedure TProcess.SetWindowWidth (Value : Cardinal); +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UsePosition; + FStartupInfo.dwxsize:=Value; +end; + +Function TProcess.GetWindowRect : TRect; +begin + With Result do + With FStartupInfo do + begin + Left:=dwx; + Right:=dwx+dwxSize; + Top:=dwy; + Bottom:=dwy+dwysize; + end; +end; + +Procedure TProcess.SetWindowRect (Value : Trect); +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseSize; + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UsePosition; + With Value do + With FStartupInfo do + begin + dwx:=Left; + dwxSize:=Right-Left; + dwy:=Top; + dwySize:=Bottom-top; + end; +end; + + +Procedure TProcess.SetWindowRows (Value : Cardinal); + +begin + FStartupInfo.dwFlags:=FStartupInfo.dwFlags or Startf_UseCountChars; + FStartupInfo.dwYCountChars:=Value; +end; + +end. diff --git a/fcl/inc/process.txt b/fcl/inc/process.txt new file mode 100644 index 0000000000..42491012ad --- /dev/null +++ b/fcl/inc/process.txt @@ -0,0 +1,280 @@ +This file describes the TProcess object. + +The TProcess object provides an easy way to start and manipulate +the running of other programs (processes) by your application. +On top of that, it allows you to redirect the program's input, output +and standard error to streams that are readable/writeable by your +program. + +It is a descendent class of TObject, but this is easily changeable to +TComponent, should you desire to do so. None of the properties will +conflict with the existing properties of TComponent. + +Furthermore it is written in such a way that it is easily extensible, +although most of the properties that a Process has, are accessible and +can be controlled with this object. + +In what follows, is a description of the object's methods and properties. + +The following two types control the creation of the TProcess Object. +See The constructor description for a description on what they do. + +TProcessOptions = (poExecuteOnCreate,poRunSuspended,poUsePipes, + poNoConsole,poStderrToOutPut,poWaitOnExit); +TCreateOptions = Set of TPRocessOptions; + + + +Constructor Create (Const ACommandline : String; + Options : TCreateOptions); + +This creates an TPRocess object. + +ACommandline is the commandline to execute, including any options +you wish to pass to the program. If you don't specify an explicit path +Windows will look for your program in the Windows directory and in the +path. + +Options control the behaviour of the object. It can be a set of the +following constants: + +poExecuteOnCreate + If you include this option, the constructor will immediatly + call the Execute method, using default settings for all parameters. + This has the effect that the program is run at once. + +poRunSuspended + If you include this option, the Execute method will start the + program in a suspended state, and the program will start running + only after you have called the Resume method. + +poUsePipes + If you include this option, the Execute method will redirect the + standard input,output and error descriptors to 3 pipes, which you + can read from or write to. + (see Input,OutPut and Error properties) + It makes little sense to use ths for GUI applications (i.e. non- + console applications) + +poNoConsole + If you include this option, the application will not display a + console, untill it explicitly needs one or requests one using the + AllocConsole method. This is very convenient in combination with the + poUsePipes option, allowing you to run an application without getting + the Console window, and being able to read it's output at once. + +poStderrToOutPut + If This option is included, then the error desciptor is redirected to + the standard output director, i.e. all output goes to the standard + output. + +poWaitOnExit + If you specify this option, then the Execute method will wait for the + executed program to finish, before returning. + This option will be ignored if you also specified ExecuteOnCreate and + CreateSuspended. + + +Destructor Destroy; virtual; + + Destroys the TProcess Object. Be careful NOT to close a TProcess + object when you use pipes, and the application is still running. + you may kill it. + +Procedure Execute; virtual; + This actually runs the application. It will return immediatly, unless + you specified the poWaitOnExit option when creating the object. + +Function Resume : Integer; virtual; + Resume lowers the suspend count of the application. + it returns the new suspend count of the application. As long as the + suspend count is larger than 0, the application will not run. + If the suspend count reaches 0, the application will continue + running. + +Function Suspend : Integer; virtual; + Increases the suspend count of the application, and returns the + new suspend count of the application. + +Function Terminate (AExitCode : Integer): Boolean; virtual; + Terminate terminates the main thread of the application, giving it + exitcode 'AExitCode' + It returns True on succes, False on failure. + +Function WaitOnExit : Integer; + This function returns immediatly if the application is not running, + and waits for the application to finish if it was still running. + +Property ApplicationName : String; + Sets the name of the application. + +Property CommandLine : String; + Read-Only + contains the commandline of the application, as set by the create + method of TProcess. + +Property ConsoleTitle : String; + For console applications only : + Sets the title that appears in the title bar of the Console window. + +Property CreateOptions : TCreateOptions; + Read-Only + Contains the options as set by the Create method of TProcess. + +Property CreationFlags : Cardinal; + This contains the creation flags that are passed to the CreateProcess + call. These flags are modified by the Execute call to reflect any + settings tat you may have made. + +Property CurrentDirectory : String; + When set, the process wil start in the directory that you have set + for it. + +Property DeskTop : String; + NT only: + Contains the name of the desktop or window station that the process + will be run on. See STARTUPINFO in the win32 programmers manual. + +Property Environment : Pointer; + A pointer to a null-terminated list of environment variable pointers. + Each pair is of the form 'Name=Value'. + If this is nil, the environment of your application is used. + +Property ExitStatus : Integer; + Read-Only + This returns the exit status of the application, or STILL_ACTIVE + (defined in Windows.pas) if the application is still running. + +Property FillAttribute : Integer; + For console processes only. + Sets the fill color for the console window. + +Property Handle : THandle; + Read-Only; + Returns the handle of the process, which can be used to pass on to + calls that require a handle of a process. + Onl valid if the process is running. + + +Property Input : TOutPutPipeStream; + Read-Only + Returns the Input handle of the process. + Anything you write to this stream, will appear on the applications + input file descriptor. + Only valid if you used poUsePipes when you created the TProcess + object. + +Property InheritHandles : LongBool; + If you set this to true, each inheritable handle of your application + is inherited by the new application. + +Property OutPut : TInputPipeStream; + Read-Only + Returns the Output handle of the process. Anything the process writes + to its standard output can be read from this stream. + Only valid if you used poUsePipes when you created the TProcess + object. + +Property ProcessAttributes : TSecurityAttributes; + +Property ProcessInformation : TProcessInformation; + Read-Only + Gives access to the ProcessInformation returned by Windows + upon executing the program. This contains + hProcess : Process Handle (See Handle property) + hThread : Process' main thread handle (See ThreadHandle property) + dwProcessId : Process ID. (as seen in the task manager) + dwThreadId : Process' main thread ID + +Property Running : Boolean; + Read-Only + Retruns True if the application is still running, False otherwise. + If the application is suspended or not doesn't affect the result. + +Property ShowWindow : Word; + You can set the applications ShowWindow attribute here. + +Property StartupInfo : TStartupInfo; + Read-Only + Gives access to the TStartupInfo that will be passed to the + application in the CreateProcess Call. You can manipulate its various + members through the properties of the TProcess object. + +Property StdErr : TinputPipeStream; + Read-Only + Returns the Output handle of the process. Anything the process writes + to its error output can be read from this stream. + Only valid if you used poUsePipes when you created the TProcess + object. + If you specified poStderrToOutput then this is the same as the + 'Output' stream. + +Property ThreadAttributes : TSecurityAttributes; + Contains the security attributes that will be passed to the process' + main thread. By default, no security attributes are passed. + +Property ThreadHandle : THandle; + Read-Only + Returns the Handle of the process' main thread. + +Property WindowColumns : Integer; + For console applications: + This will set the number of screen columns that the console window + will have. + If you don't set this property nor the WindowRows property, Windows will + choose default values. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowHeight : Integer; + Set the height of the application's main window. + If you don't specify this, nor WindowWidth, Windows will choose + the height and Width of the applications window. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowLeft : Integer; + Set the applications main window position, in pixels from the left + side of the screen. + If you don't specify this, nor WindowTop, Windows will choose + the Left and Top of the applications window. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowRows : Integer; + For console applications: + This will set the number of screen rows (lines) that the console window + will have. + If you don't set this property nor the WindowColumns property, Windows will + choose default values. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowTop : Integer; + Set the applications main window position, in pixels from the Top + side of the screen. + If you don't specify this, nor WindowLeft, Windows will choose + the Left and Top of the applications window. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowWidth : Integer; + Set the Width of the application's main window. + If you don't specify this, nor WindowWidth, Windows will choose + the height and Width of the applications window. + You can only set this PRIOR to calling the execute method, after + the application was executed, or while it is running, the setting + will be ignored until you run it again. + +Property WindowRect : Trect; + This sets the bounding rectangle of the application's main window. + It allows to set the WindowTop, WindowLeft, WindowHeight, WindowWidth + properties in 1 call. + + + diff --git a/fcl/win32/Makefile b/fcl/win32/Makefile index 98bc96ac0b..3250d1a7a7 100644 --- a/fcl/win32/Makefile +++ b/fcl/win32/Makefile @@ -1,5 +1,5 @@ # -# Makefile generated by fpcmake v0.99.13 [2000/01/18] +# Makefile generated by fpcmake v0.99.13 on 2000/01/24 13:04 # defaultrule: all @@ -52,20 +52,13 @@ else EXEEXT=.exe endif -# The path which is searched separated by spaces +# The path which is search separated by spaces ifdef inlinux SEARCHPATH=$(subst :, ,$(PATH)) else SEARCHPATH=$(subst ;, ,$(PATH)) endif -# Base dir -ifdef PWD -BASEDIR:=$(shell $(PWD)) -else -BASEDIR=. -endif - ##################################################################### # Default target ##################################################################### @@ -80,48 +73,75 @@ override OS_TARGET:=win32 ifndef FPC # Compatibility with old makefiles ifdef PP -FPC=$(PP) +export FPC=$(PP) else ifdef inOS2 -FPC=ppos2$(EXEEXT) +export FPC=ppos2$(EXEEXT) else -FPC=ppc386$(EXEEXT) +export FPC=ppc386$(EXEEXT) endif endif endif -override FPC:=$(subst \,/,$(FPC)) # Target OS ifndef OS_TARGET -OS_TARGET:=$(shell $(FPC) -iTO) +export OS_TARGET:=$(shell $(FPC) -iTO) endif # Source OS ifndef OS_SOURCE -OS_SOURCE:=$(shell $(FPC) -iSO) +export OS_SOURCE:=$(shell $(FPC) -iSO) endif # Target CPU ifndef CPU_TARGET -CPU_TARGET:=$(shell $(FPC) -iTP) +export CPU_TARGET:=$(shell $(FPC) -iTP) endif # Source CPU ifndef CPU_SOURCE -CPU_SOURCE:=$(shell $(FPC) -iSP) +export CPU_SOURCE:=$(shell $(FPC) -iSP) endif # FPC version ifndef FPC_VERSION -FPC_VERSION:=$(shell $(FPC) -iV) +export FPC_VERSION:=$(shell $(FPC) -iV) endif -export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION +##################################################################### +# 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 ##################################################################### -# Pre Settings +# User Settings ##################################################################### + +# Pre Settings + # Include files INC=../inc XML=../xml @@ -132,77 +152,33 @@ SHEDIT=../shedit include $(INC)/Makefile.inc include $(XML)/Makefile.inc include $(SHEDIT)/Makefile.inc -##################################################################### -# FPCDIR Setting -##################################################################### - -# Test FPCDIR to look if the RTL dir exists -ifdef FPCDIR -override FPCDIR:=$(subst \,/,$(FPCDIR)) -ifeq ($(wildcard $(FPCDIR)/rtl),) -override FPCDIR=wrong -endif -else -override FPCDIR=wrong -endif - -# Default FPCDIR -ifeq ($(FPCDIR),wrong) -override FPCDIR=../.. -ifeq ($(wildcard $(FPCDIR)/rtl),) -override FPCDIR=wrong -endif -endif - -# Detect FPCDIR -ifeq ($(FPCDIR),wrong) -ifdef inlinux -override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) -else -override FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH)))))) -endif -endif - -ifndef PACKAGESDIR -PACKAGESDIR=$(FPCDIR)/packages -endif -ifndef TOOLKITSDIR -TOOLKITSDIR= -endif -ifndef COMPONENTSDIR -COMPONENTSDIR= -endif - -# Create units dir -ifneq ($(FPCDIR),.) -UNITSDIR=$(FPCDIR)/units/$(OS_TARGET) -endif - -##################################################################### -# User Settings -##################################################################### - # Targets -override UNITOBJECTS+=classes $(INCUNITS) $(XMLUNITS) $(SHEDITUNITS) +override UNITOBJECTS+=classes $(INCUNITS) $(XMLUNITS) $(SHEDITUNITS) process # Clean # Install -UNITSUBDIR=fcl -PACKAGENAME=fcl ZIPTARGET=install # Defaults -override NEEDOPT=-S2 # Directories vpath %$(PASEXT) $(INC) $(XML) $(SHEDIT) +ifndef FPCDIR +FPCDIR=../.. +endif +ifndef PACKAGEDIR +PACKAGEDIR=$(FPCDIR)/packages +endif +ifndef COMPONENTDIR +COMPONENTDIR=$(FPCDIR)/components +endif override NEEDINCDIR=$(INC) ifndef TARGETDIR TARGETDIR=. @@ -210,7 +186,6 @@ endif # Packages -override PACKAGES+=rtl paszlib # Libraries @@ -220,373 +195,40 @@ LIBNAME=fpfcl INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall -##################################################################### -# Shell tools -##################################################################### - -# echo -ifndef ECHO -ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(ECHO),) -ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(ECHO),) -ECHO:=echo -ECHOE:=echo -else -ECHO:=$(firstword $(ECHO)) -ECHOE=$(ECHO) -E -endif -else -ECHO:=$(firstword $(ECHO)) -ECHOE=$(ECHO) -E -endif -endif - -# To copy pograms -ifndef COPY -COPY:=cp -fp -endif - -# Copy a whole tree -ifndef COPYTREE -COPYTREE:=cp -rfp -endif - -# To move pograms -ifndef MOVE -MOVE:=mv -f -endif - -# Check delete program -ifndef DEL -DEL:=rm -f -endif - -# Check deltree program -ifndef DELTREE -DELTREE:=rm -rf -endif - -# To install files -ifndef INSTALL -ifdef inlinux -INSTALL:=install -m 644 -else -INSTALL:=$(COPY) -endif -endif - -# To install programs -ifndef INSTALLEXE -ifdef inlinux -INSTALLEXE:=install -m 755 -else -INSTALLEXE:=$(COPY) -endif -endif - -# To make a directory. -ifndef MKDIR -ifdef inlinux -MKDIR:=install -m 755 -d -else -MKDIR:=ginstall -m 755 -d -endif -endif - -export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR - -##################################################################### -# 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 - -# ldconfig to rebuild .so cache -ifdef inlinux -LDCONFIG=ldconfig -else -LDCONFIG= -endif - -# ppumove -ifndef PPUMOVE -PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(PPUMOVE),) -PPUMOVE= -else -PPUMOVE:=$(firstword $(PPUMOVE)) -endif -endif -export PPUMOVE - -# ppufiles -ifndef PPUFILES -PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(PPUFILES),) -PPUFILES= -else -PPUFILES:=$(firstword $(PPUFILES)) -endif -endif -export PPUFILES - -# 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 -UPXPROG:=$(firstword $(UPXPROG)) -endif -else -UPXPROG= -endif -endif -export UPXPROG - -# ZipProg, you can't use Zip as the var name (PFV) -ifndef ZIPPROG -ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(ZIPPROG),) -ZIPPROG= -else -ZIPPROG:=$(firstword $(ZIPPROG)) -endif -endif -export ZIPPROG - -ZIPOPT=-9 -ZIPEXT=.zip - -# Tar -ifndef TARPROG -TARPROG:=$(strip $(wildcard $(addsuffix /tar$(EXEEXT),$(SEARCHPATH)))) -ifeq ($(TARPROG),) -TARPROG= -else -TARPROG:=$(firstword $(TARPROG)) -endif -endif -export TARPROG - -ifeq ($(USETAR),bz2) -TAROPT=vI -TAREXT=.tar.bz2 -else -TAROPT=vz -TAREXT=.tar.gz -endif - -##################################################################### -# Default extensions -##################################################################### - -# Default needed extensions (Go32v2,Linux) -LOADEREXT=.as -PPLEXT=.ppl -PPUEXT=.ppu -OEXT=.o -ASMEXT=.s -SMARTEXT=.sl -STATICLIBEXT=.a -SHAREDLIBEXT=.so -RSTEXT=.rst -FPCMADE=fpcmade - -# Go32v1 -ifeq ($(OS_TARGET),go32v1) -PPUEXT=.pp1 -OEXT=.o1 -ASMEXT=.s1 -SMARTEXT=.sl1 -STATICLIBEXT=.a1 -SHAREDLIBEXT=.so1 -FPCMADE=fpcmade.v1 -endif - -# Go32v2 -ifeq ($(OS_TARGET),go32v2) -FPCMADE=fpcmade.dos -endif - -# Linux -ifeq ($(OS_TARGET),linux) -FPCMADE=fpcmade.lnx -endif - -# Win32 -ifeq ($(OS_TARGET),win32) -PPUEXT=.ppw -OEXT=.ow -ASMEXT=.sw -SMARTEXT=.slw -STATICLIBEXT=.aw -SHAREDLIBEXT=.dll -FPCMADE=fpcmade.w32 -endif - -# OS/2 -ifeq ($(OS_TARGET),os2) -PPUEXT=.ppo -ASMEXT=.so2 -OEXT=.oo2 -SMARTEXT=.so -STATICLIBEXT=.ao2 -SHAREDLIBEXT=.dll -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 - - -# Check if the dirs really exists, else turn it off -ifeq ($(wildcard $(UNITSDIR)),) -UNITSDIR= -endif -ifeq ($(wildcard $(TOOLKITSDIR)),) -TOOLKITSDIR= -endif -ifeq ($(wildcard $(PACKAGESDIR)),) -PACKAGESDIR= -endif -ifeq ($(wildcard $(COMPONENTSDIR)),) -COMPONENTSDIR= -endif - - -# PACKAGESDIR packages - -PACKAGERTL=1 -PACKAGEPASZLIB=1 - -ifdef PACKAGERTL -ifneq ($(wildcard $(FPCDIR)/rtl),) -ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),) -PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET) -else -PACKAGEDIR_RTL=$(FPCDIR)/rtl -endif -ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),) -override COMPILEPACKAGES+=package_rtl -package_rtl: - $(MAKE) -C $(PACKAGEDIR_RTL) all -endif -UNITDIR_RTL=$(PACKAGEDIR_RTL) -else -PACKAGEDIR_RTL= -ifneq ($(wildcard $(UNITSDIR)/rtl),) -ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),) -UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET) -else -UNITDIR_RTL=$(UNITSDIR)/rtl -endif -else -UNITDIR_RTL= -endif -endif -ifdef UNITDIR_RTL -override NEEDUNITDIR+=$(UNITDIR_RTL) -endif -endif -ifdef PACKAGEPASZLIB -ifneq ($(wildcard $(PACKAGESDIR)/paszlib),) -ifneq ($(wildcard $(PACKAGESDIR)/paszlib/$(OS_TARGET)),) -PACKAGEDIR_PASZLIB=$(PACKAGESDIR)/paszlib/$(OS_TARGET) -else -PACKAGEDIR_PASZLIB=$(PACKAGESDIR)/paszlib -endif -ifeq ($(wildcard $(PACKAGEDIR_PASZLIB)/$(FPCMADE)),) -override COMPILEPACKAGES+=package_paszlib -package_paszlib: - $(MAKE) -C $(PACKAGEDIR_PASZLIB) all -endif -UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB) -else -PACKAGEDIR_PASZLIB= -ifneq ($(wildcard $(UNITSDIR)/paszlib),) -ifneq ($(wildcard $(UNITSDIR)/paszlib/$(OS_TARGET)),) -UNITDIR_PASZLIB=$(UNITSDIR)/paszlib/$(OS_TARGET) -else -UNITDIR_PASZLIB=$(UNITSDIR)/paszlib -endif -else -UNITDIR_PASZLIB= -endif -endif -ifdef UNITDIR_PASZLIB -override NEEDUNITDIR+=$(UNITDIR_PASZLIB) -endif -endif - - ##################################################################### # 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 -PREFIXINSTALLDIR=/usr +export PREFIXINSTALLDIR=/usr else -PREFIXINSTALLDIR=/pp +export PREFIXINSTALLDIR=/pp endif endif -export PREFIXINSTALLDIR -# Where to place the resulting zip files -ifndef DESTZIPDIR -DESTZIPDIR:=$(BASEDIR) +# 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 -export DESTZIPDIR ##################################################################### # Install Directories @@ -612,10 +254,7 @@ endif # set the directory where to install the units. ifndef UNITINSTALLDIR -UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) -ifdef UNITSUBDIR -UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) -endif +UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET) endif # Where to install shared libraries @@ -634,41 +273,20 @@ SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION) else SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source endif -ifdef SOURCESUBDIR -SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR) -endif endif # Where the doc files will be stored ifndef DOCINSTALLDIR ifdef inlinux -DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION) else DOCINSTALLDIR=$(BASEINSTALLDIR)/doc endif endif # Where the some extra (data)files will be stored -ifndef DATAINSTALLDIR -DATAINSTALLDIR=$(BASEINSTALLDIR) -endif - -##################################################################### -# Redirection -##################################################################### - -# Release ? Then force OPT and don't use extra opts via commandline -ifndef REDIRFILE -REDIRFILE=log -endif - -ifdef REDIR -ifndef inlinux -override FPC=redir -eo $(FPC) -endif -# set the verbosity to max -override FPCOPT+=-va -override REDIR:= >> $(REDIRFILE) +ifndef EXTRAINSTALLDIR +EXTRAINSTALLDIR=$(BASEINSTALLDIR) endif @@ -684,12 +302,8 @@ ifneq ($(OS_TARGET),$(OS_SOURCE)) override FPCOPT+=-T$(OS_TARGET) endif -ifdef NEEDOPT -override FPCOPT+=$(NEEDOPT) -endif - -ifdef NEEDUNITDIR -override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +ifdef RTLDIR +override FPCOPT+=-Fu$(RTLDIR) endif ifdef UNITSDIR @@ -713,17 +327,7 @@ endif # Debug ifdef DEBUG -override FPCOPT+=-g -dDEBUG -endif - -# Release mode (strip, optimize and don't load ppc386.cfg) -ifdef RELEASE -override FPCOPT+=-Xs -OG2p3 -n -endif - -# Verbose settings (warning,note,info) -ifdef VERBOSE -override FPCOPT+=-vwni +override FPCOPT+=-g endif # Add commandline options @@ -758,7 +362,7 @@ ifdef CFGFILE override FPCOPT+=@$(CFGFILE) endif -# For win32 the options are passed using the environment FPCEXTCMD +# For win32 the options are passed using the environment variable FPCEXTCMD ifeq ($(OS_SOURCE),win32) override FPCEXTCMD:=$(FPCOPT) override FPCOPT:=!FPCEXTCMD @@ -768,6 +372,92 @@ 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 +##################################################################### + +# file used to check if a package is compiled +ifndef FPCMAKED +FPCMAKED=fpcmaked +endif + +# 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= @@ -775,6 +465,190 @@ 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 + +##################################################################### +# Default extensions +##################################################################### + +# Default needed extensions (Go32v2,Linux) +LOADEREXT=.as +PPLEXT=.ppl +PPUEXT=.ppu +OEXT=.o +ASMEXT=.s +SMARTEXT=.sl +STATICLIBEXT=.a +SHAREDLIBEXT=.so +PACKAGESUFFIX= + +# Go32v1 +ifeq ($(OS_TARGET),go32v1) +PPUEXT=.pp1 +OEXT=.o1 +ASMEXT=.s1 +SMARTEXT=.sl1 +STATICLIBEXT=.a1 +SHAREDLIBEXT=.so1 +PACKAGESUFFIX=v1 +endif + +# Go32v2 +ifeq ($(OS_TARGET),go32v2) +PACKAGESUFFIX=go32 +endif + +# Linux +ifeq ($(OS_TARGET),linux) +PACKAGESUFFIX=linux +endif + +# Win32 +ifeq ($(OS_TARGET),win32) +PPUEXT=.ppw +OEXT=.ow +ASMEXT=.sw +SMARTEXT=.slw +STATICLIBEXT=.aw +SHAREDLIBEXT=.dll +PACKAGESUFFIX=win32 +endif + +# OS/2 +ifeq ($(OS_TARGET),os2) +PPUEXT=.ppo +ASMEXT=.so2 +OEXT=.oo2 +SMARTEXT=.so +STATICLIBEXT=.ao2 +SHAREDLIBEXT=.dll +PACKAGESUFFIX=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 ##################################################################### @@ -795,7 +669,7 @@ sourceinstall: fpc_sourceinstall zipinstall: fpc_zipinstall -zipsourceinstall: fpc_zipsourceinstall +zipinstalladd: fpc_zipinstalladd clean: fpc_clean @@ -803,7 +677,21 @@ cleanall: fpc_cleanall info: fpc_info -.PHONY: all debug smart shared showinstall install sourceinstall zipinstall zipsourceinstall clean cleanall info +.PHONY: all debug smart shared showinstall install sourceinstall zipinstall zipinstalladd clean cleanall info + +##################################################################### +# Package depends +##################################################################### + +ifneq ($(wildcard $(RTLDIR)),) +ifeq ($(wildcard $(RTLDIR)/$(FPCMAKED)),) +override COMPILEPACKAGES+=rtl +rtl_package: + $(MAKE) -C $(RTLDIR) all +endif +endif + +.PHONY: rtl_package ##################################################################### # Units @@ -823,14 +711,14 @@ fpc_units: $(UNITPPUFILES) # General compile rules ##################################################################### -.PHONY: fpc_packages fpc_all fpc_debug +.PHONY: fpc_all fpc_debug -$(FPCMADE): $(ALLTARGET) - @$(ECHO) Compiled > $(FPCMADE) +$(FPCMAKED): + @$(ECHO) Compiled > $(FPCMAKED) -fpc_packages: $(COMPILEPACKAGES) - -fpc_all: fpc_packages $(FPCMADE) +fpc_all: $(addsuffix _package,$(COMPILEPACKAGES)) \ + $(addsuffix _component,$(COMPILECOMPONENTS)) \ + $(ALLTARGET) $(FPCMAKED) fpc_debug: $(MAKE) all DEBUG=1 @@ -872,12 +760,12 @@ fpc_smart: fpc_shared: all ifdef inlinux ifndef LIBNAME - @$(ECHO) "LIBNAME not set" + @$(ECHO) LIBNAME not set else $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME) endif else - @$(ECHO) "Shared Libraries not supported" + @$(ECHO) Shared Libraries not supported endif ##################################################################### @@ -899,25 +787,25 @@ else INSTALLPPULINKFILES:=$(shell $(PPUFILES) $(INSTALLPPUFILES)) endif else -INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES))) +INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) endif endif fpc_showinstall: $(SHOWINSTALLTARGET) ifdef INSTALLEXEFILES - @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) + @$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) endif ifdef INSTALLPPUFILES - @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) + @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) ifneq ($(INSTALLPPULINKFILES),) - @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) + @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) endif ifneq ($(INSTALLPPULIBFILES),) - @$(ECHO) -e $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES)) + @$(ECHO) $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES)) endif endif ifdef EXTRAINSTALLFILES - @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES)) + @$(ECHO) $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFILES)) endif fpc_install: $(INSTALLTARGET) @@ -942,84 +830,79 @@ ifneq ($(INSTALLPPULIBFILES),) endif endif ifdef EXTRAINSTALLFILES - $(MKDIR) $(DATAINSTALLDIR) - $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) + $(MKDIR) $(EXTRAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR) endif ##################################################################### -# SourceInstall rules +# Source install rules ##################################################################### .PHONY: fpc_sourceinstall -ifndef SOURCETOPDIR -SOURCETOPDIR=$(BASEDIR) -endif - fpc_sourceinstall: clean $(MKDIR) $(SOURCEINSTALLDIR) - $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(BASEDIR) $(SOURCEINSTALLDIR) ##################################################################### # Zip ##################################################################### -.PHONY: fpc_zipinstall - -# Create suffix to add -ifndef PACKAGESUFFIX -PACKAGESUFFIX=$(OS_TARGET) -ifeq ($(OS_TARGET),go32v2) -PACKAGESUFFIX=go32 -endif -ifeq ($(OS_TARGET),win32) -PACKAGESUFFIX=w32 -endif -endif +.PHONY: fpc_zipinstall fpc_zipinstalladd # Temporary path to pack a file ifndef PACKDIR ifndef inlinux -PACKDIR=$(BASEDIR)/pack_tmp +PACKDIR=pack_tmp else PACKDIR=/tmp/fpc-pack endif endif -# Maybe create default zipname from packagename -ifndef ZIPNAME -ifdef PACKAGENAME -ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +# 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 -# Use tar by default under linux -ifndef USEZIP -ifdef inlinux -USETAR=1 -endif -endif - -fpc_zipinstall: +# Note: This will not remove the zipfile first +fpc_zipinstalladd: ifndef ZIPNAME - @$(ECHO) "Please specify ZIPNAME!" - @exit 1 + @$(ECHO) Please specify ZIPNAME! + @exit else $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) -ifdef USETAR - $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) - cd $(PACKDIR) ; $(TARPROG) c$(TAROPT) --file $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +ifdef inlinux + gzip -d $(DESTZIPDIR)/$(ZIPNAME).tar.gz + cd $(PACKDIR) ; tar rv --file $(DESTZIPDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR) + gzip $(DESTZIPDIR)/$(ZIPNAME).tar else - $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) - cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) + cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR) endif $(DELTREE) $(PACKDIR) endif -.PHONY: fpc_zipsourceinstall - -fpc_zipsourceinstall: - $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src +# 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 @@ -1035,7 +918,7 @@ ifdef CLEANPPUFILES ifdef PPUFILES CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) else -CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES))) +CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) endif endif @@ -1049,21 +932,18 @@ endif ifneq ($(CLEANPPULINKFILES),) -$(DEL) $(CLEANPPULINKFILES) endif -ifdef CLEANRSTFILES - -$(DEL) $(CLEANRSTFILES) -endif ifdef EXTRACLEANFILES -$(DEL) $(EXTRACLEANFILES) endif - -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) $(FPCMAKED) $(PPAS) link.res $(REDIRFILE) fpc_cleanall: $(CLEANTARGET) ifdef CLEANEXEFILES -$(DEL) $(CLEANEXEFILES) endif - -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) -$(DELTREE) *$(SMARTEXT) - -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + -$(DEL) $(FPCMAKED) $(PPAS) link.res $(REDIRFILE) ##################################################################### # Info rules @@ -1106,12 +986,6 @@ fpc_infoinstall: @$(ECHO) ifdef DATE @$(ECHO) DateStr.............. $(DATESTR) -endif -ifdef PACKAGEPREFIX - @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) -endif -ifdef PACKAGENAME - @$(ECHO) PackageName.......... $(PACKAGENAME) endif @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) @$(ECHO) @@ -1121,19 +995,8 @@ endif @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) - @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) ExtraInstallDir...... $(EXTRAINSTALLDIR) @$(ECHO) - @$(ECHO) DestZipDir........... $(DESTZIPDIR) - @$(ECHO) ZipName.............. $(ZIPNAME) - @$(ECHO) - -##################################################################### -# Local Makefile -##################################################################### - -ifneq ($(wildcard fpcmake.loc),) -include fpcmake.loc -endif ##################################################################### # Users rules diff --git a/fcl/win32/Makefile.fpc b/fcl/win32/Makefile.fpc index d69afbe32c..024db9abd3 100644 --- a/fcl/win32/Makefile.fpc +++ b/fcl/win32/Makefile.fpc @@ -3,7 +3,7 @@ # [targets] -units=classes $(INCUNITS) $(XMLUNITS) $(SHEDITUNITS) +units=classes $(INCUNITS) $(XMLUNITS) $(SHEDITUNITS) process [defaults] defaulttarget=win32