From 8fe7ea95a343a35dc286bd9a13d257d285e9c4e1 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 18 Nov 2006 18:11:20 +0000 Subject: Initial checkin. Merged fpGUI, fpGFX and fpIMG from the OpenSoft sever. --- examples/img/Makefile | 1313 +++++++++++++++++++++++++++++++++++ examples/img/Makefile.fpc | 6 + examples/img/disp_bmp/Makefile | 1306 ++++++++++++++++++++++++++++++++++ examples/img/disp_bmp/Makefile.fpc | 14 + examples/img/disp_bmp/disp_bmp.pas | 90 +++ examples/img/disp_bmp/test.bmp | Bin 0 -> 196662 bytes examples/img/disp_bmp/test2.bmp | Bin 0 -> 8254 bytes examples/img/disp_bmp/test4.bmp | Bin 0 -> 32886 bytes examples/img/disp_bmp/test8.bmp | Bin 0 -> 66614 bytes examples/img/masktest/Makefile | 1347 ++++++++++++++++++++++++++++++++++++ examples/img/masktest/Makefile.fpc | 14 + examples/img/masktest/image2.bmp | Bin 0 -> 4542 bytes examples/img/masktest/image24.bmp | Bin 0 -> 96054 bytes examples/img/masktest/image4.bmp | Bin 0 -> 16118 bytes examples/img/masktest/image8.bmp | Bin 0 -> 32566 bytes examples/img/masktest/mask.bmp | Bin 0 -> 4542 bytes examples/img/masktest/masktest.pas | 150 ++++ 17 files changed, 4240 insertions(+) create mode 100644 examples/img/Makefile create mode 100644 examples/img/Makefile.fpc create mode 100644 examples/img/disp_bmp/Makefile create mode 100644 examples/img/disp_bmp/Makefile.fpc create mode 100644 examples/img/disp_bmp/disp_bmp.pas create mode 100644 examples/img/disp_bmp/test.bmp create mode 100644 examples/img/disp_bmp/test2.bmp create mode 100644 examples/img/disp_bmp/test4.bmp create mode 100644 examples/img/disp_bmp/test8.bmp create mode 100644 examples/img/masktest/Makefile create mode 100644 examples/img/masktest/Makefile.fpc create mode 100644 examples/img/masktest/image2.bmp create mode 100644 examples/img/masktest/image24.bmp create mode 100644 examples/img/masktest/image4.bmp create mode 100644 examples/img/masktest/image8.bmp create mode 100644 examples/img/masktest/mask.bmp create mode 100644 examples/img/masktest/masktest.pas (limited to 'examples/img') diff --git a/examples/img/Makefile b/examples/img/Makefile new file mode 100644 index 00000000..e799dc0f --- /dev/null +++ b/examples/img/Makefile @@ -0,0 +1,1313 @@ +# +# Makefile generated by fpcmake v1.00 [2001/01/01] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT or OS/2) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +# define inOS2 when running under OS/2 +##################################################################### + +# 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 +inUnix=1 +PWD:=$(firstword $(PWD)) +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The extension of batch files / scripts +ifdef inUnix +BATCHEXT=.sh +else +ifdef inOS2 +BATCHEXT=.cmd +else +BATCHEXT=.bat +endif +endif + +# Path Separator, the subst trick is necessary for the \ that can't exists +# at the end of a line +ifdef inUnix +PATHSEP=/ +else +PATHSEP=$(subst /,\,/) +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +endif +endif + +##################################################################### +# User Settings +##################################################################### + + +# Targets + +override DIROBJECTS+=$(wildcard disp_bmp masktest) + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + + +# Directories + + +# Packages + + +# Libraries + + +# Info + +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$(SRCEXEEXT),$(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 inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +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 +PPAS=ppas$(BATCHEXT) + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(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$(SRCEXEEXT),$(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$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(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 +EXEEXT=.exe +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) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +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 + + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +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 UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +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 + +# User dirs should be first, so they are looked at first +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 + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +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 FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all $(addsuffix _all,$(DIROBJECTS)) + +debug: fpc_debug $(addsuffix _debug,$(DIROBJECTS)) + +smart: fpc_smart $(addsuffix _smart,$(DIROBJECTS)) + +shared: fpc_shared $(addsuffix _shared,$(DIROBJECTS)) + +showinstall: fpc_showinstall $(addsuffix _showinstall,$(DIROBJECTS)) + +install: fpc_install $(addsuffix _install,$(DIROBJECTS)) + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean $(addsuffix _clean,$(DIROBJECTS)) + +distclean: fpc_distclean $(addsuffix _distclean,$(DIROBJECTS)) + +cleanall: fpc_cleanall $(addsuffix _cleanall,$(DIROBJECTS)) + +require: $(addsuffix _require,$(DIROBJECTS)) + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall require info + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +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 +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(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 ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# 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 +ifeq ($(OS_TARGET),os2) +PACKAGESUFFIX=emx +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +# Use a wrapper script by default for OS/2 +ifdef inOS2 +USEZIPWRAPPER=1 +endif + +# Create commands to create the zip/tar file +ZIPWRAPPER=$(DESTZIPDIR)/fpczip$(BATCHEXT) +ZIPCMD_CDPACK:=cd $(subst /,$(PATHSEP),$(PACKDIR)) +ZIPCMD_CDBASE:=cd $(subst /,$(PATHSEP),$(BASEDIR)) +ifdef USETAR +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) +ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) * +else +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) +ZIPCMD_ZIP:=$(subst /,$(PATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) * +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) + $(DEL) $(ZIPDESTFILE) +ifdef USEZIPWRAPPER +ifneq ($(ECHO),echo) + $(ECHO) "$(ZIPCMD_CDPACK)" > $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_ZIP)" >> $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_CDBASE)" >> $(ZIPWRAPPER) +else + $(ECHO) $(ZIPCMD_CDPACK) > $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_ZIP) >> $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER) +endif +ifdef inUnix + /bin/sh $(ZIPWRAPPER) +else + $(ZIPWRAPPER) +endif + $(DEL) $(ZIPWRAPPER) +else + $(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(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 +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Directories +##################################################################### + +OBJECTDIRDISP_BMP=1 +OBJECTDIRMASKTEST=1 + +# Dir disp_bmp + +ifdef OBJECTDIRDISP_BMP +.PHONY: disp_bmp_all disp_bmp_debug disp_bmp_examples disp_bmp_test disp_bmp_smart disp_bmp_shared disp_bmp_showinstall disp_bmp_install disp_bmp_sourceinstall disp_bmp_exampleinstall disp_bmp_zipinstall disp_bmp_zipsourceinstall disp_bmp_zipexampleinstall disp_bmp_clean disp_bmp_distclean disp_bmp_cleanall disp_bmp_require disp_bmp_info + +disp_bmp_all: + $(MAKE) -C disp_bmp all + +disp_bmp_debug: + $(MAKE) -C disp_bmp debug + +disp_bmp_examples: + $(MAKE) -C disp_bmp examples + +disp_bmp_test: + $(MAKE) -C disp_bmp test + +disp_bmp_smart: + $(MAKE) -C disp_bmp smart + +disp_bmp_shared: + $(MAKE) -C disp_bmp shared + +disp_bmp_showinstall: + $(MAKE) -C disp_bmp showinstall + +disp_bmp_install: + $(MAKE) -C disp_bmp install + +disp_bmp_sourceinstall: + $(MAKE) -C disp_bmp sourceinstall + +disp_bmp_exampleinstall: + $(MAKE) -C disp_bmp exampleinstall + +disp_bmp_zipinstall: + $(MAKE) -C disp_bmp zipinstall + +disp_bmp_zipsourceinstall: + $(MAKE) -C disp_bmp zipsourceinstall + +disp_bmp_zipexampleinstall: + $(MAKE) -C disp_bmp zipexampleinstall + +disp_bmp_clean: + $(MAKE) -C disp_bmp clean + +disp_bmp_distclean: + $(MAKE) -C disp_bmp distclean + +disp_bmp_cleanall: + $(MAKE) -C disp_bmp cleanall + +disp_bmp_require: + $(MAKE) -C disp_bmp require + +disp_bmp_info: + $(MAKE) -C disp_bmp info +endif + +# Dir masktest + +ifdef OBJECTDIRMASKTEST +.PHONY: masktest_all masktest_debug masktest_examples masktest_test masktest_smart masktest_shared masktest_showinstall masktest_install masktest_sourceinstall masktest_exampleinstall masktest_zipinstall masktest_zipsourceinstall masktest_zipexampleinstall masktest_clean masktest_distclean masktest_cleanall masktest_require masktest_info + +masktest_all: + $(MAKE) -C masktest all + +masktest_debug: + $(MAKE) -C masktest debug + +masktest_examples: + $(MAKE) -C masktest examples + +masktest_test: + $(MAKE) -C masktest test + +masktest_smart: + $(MAKE) -C masktest smart + +masktest_shared: + $(MAKE) -C masktest shared + +masktest_showinstall: + $(MAKE) -C masktest showinstall + +masktest_install: + $(MAKE) -C masktest install + +masktest_sourceinstall: + $(MAKE) -C masktest sourceinstall + +masktest_exampleinstall: + $(MAKE) -C masktest exampleinstall + +masktest_zipinstall: + $(MAKE) -C masktest zipinstall + +masktest_zipsourceinstall: + $(MAKE) -C masktest zipsourceinstall + +masktest_zipexampleinstall: + $(MAKE) -C masktest zipexampleinstall + +masktest_clean: + $(MAKE) -C masktest clean + +masktest_distclean: + $(MAKE) -C masktest distclean + +masktest_cleanall: + $(MAKE) -C masktest cleanall + +masktest_require: + $(MAKE) -C masktest require + +masktest_info: + $(MAKE) -C masktest info +endif + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/img/Makefile.fpc b/examples/img/Makefile.fpc new file mode 100644 index 00000000..9eb71ba2 --- /dev/null +++ b/examples/img/Makefile.fpc @@ -0,0 +1,6 @@ +# +# Makefile.fpc for fpImg examples +# + +[targets] +dirs=disp_bmp masktest diff --git a/examples/img/disp_bmp/Makefile b/examples/img/disp_bmp/Makefile new file mode 100644 index 00000000..688f1238 --- /dev/null +++ b/examples/img/disp_bmp/Makefile @@ -0,0 +1,1306 @@ +# +# Makefile generated by fpcmake v1.00 [2000/12/19] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT or OS/2) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +# define inOS2 when running under OS/2 +##################################################################### + +# 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 +inUnix=1 +PWD:=$(firstword $(PWD)) +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Default FPCDIR +ifeq ($(FPCDIR),wrong) +override FPCDIR=../../../../fpc +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +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 EXEOBJECTS+=disp_bmp + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + +override NEEDUNITDIR=../../src + +# Packages + +override PACKAGES+=rtl fcl fpgfx + +# Libraries + + +# Info + +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$(SRCEXEEXT),$(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 inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +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 inUnix +PPAS=ppas.sh +else +ifdef inOS2 +PPAS=ppas.cmd +else +PPAS=ppas.bat +endif +endif + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(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$(SRCEXEEXT),$(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$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(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 +EXEEXT=.exe +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) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +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 +PACKAGEFCL=1 +PACKAGEFPGFX=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 PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +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 UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +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 + +# User dirs should be first, so they are looked at first +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 + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +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 FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +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 +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(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 ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# 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 +ifeq ($(OS_TARGET),os2) +PACKAGESUFFIX=emx +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) +ifdef USETAR + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) + cd $(PACKDIR) ; $(TARPROG) cf$(TAROPT) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR) +else + $(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) + cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(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 +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/img/disp_bmp/Makefile.fpc b/examples/img/disp_bmp/Makefile.fpc new file mode 100644 index 00000000..a4b5ccbb --- /dev/null +++ b/examples/img/disp_bmp/Makefile.fpc @@ -0,0 +1,14 @@ +# +# Makefile.fpc for fpImg example "disp_bmp" +# + +[targets] +programs=disp_bmp + +[require] +options=-S2h +packages=fcl fpgfx + +[dirs] +fpcdir=../../../../fpc +unitdir=../../src diff --git a/examples/img/disp_bmp/disp_bmp.pas b/examples/img/disp_bmp/disp_bmp.pas new file mode 100644 index 00000000..a33bf9be --- /dev/null +++ b/examples/img/disp_bmp/disp_bmp.pas @@ -0,0 +1,90 @@ +{ + $Id: disp_bmp.pp,v 1.6 2001/02/14 23:08:59 sg Exp $ + + fpImg - Free Pascal Imaging Library + Copyright (C) 2000 - 2001 by + Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org + + Example: Display BMP file + + See the file COPYING, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +} + + +program Disp_BMP; + +uses Classes, GFXBase, GFXImpl, fpImg, BMPReader; + +type + TMainWindow = class + procedure Paint(Sender: TObject; const Rect: TRect); + private + Display: TDefDisplay; + Window: TGfxWindow; + Image: TGfxImage; + public + constructor Create(ADisplay: TDefDisplay); + destructor Destroy; override; + end; + +constructor TMainWindow.Create(ADisplay: TDefDisplay); +begin + inherited Create; + Display := ADisplay; + Image := CreateImageFromFile(Display.DefaultScreen, TBMPReader, ParamStr(1)); + Window := ADisplay.DefaultScreen.CreateWindow; + Window.Title := 'fpImg Bitmap Test'; + Window.OnPaint := @Paint; + Window.SetFixedClientSize(Size(Image.Width, Image.Height)); + Window.Show; +end; + +destructor TMainWindow.Destroy; +begin + Image.Free; + inherited Destroy; +end; + +procedure TMainWindow.Paint(Sender: TObject; const Rect: TRect); +begin + Window.Canvas.SetColor(colRed); + Window.Canvas.FillRect(Rect); + Window.Canvas.SetColor(colYellow); + Window.Canvas.DrawImage(Image, Point(0, 0)); +end; + +var + Display: TDefDisplay; + MainWindow: TMainWindow; +begin + if ParamCount <> 1 then + begin + WriteLn(StdErr, 'Please give the name of a BMP file as argument'); + Halt(2); + end; + + Display := TDefDisplay.Create; + MainWindow := TMainWindow.Create(Display); + Display.Run; + MainWindow.Free; + Display.Free; +end. + + +{ + $Log: disp_bmp.pp,v $ + Revision 1.6 2001/02/14 23:08:59 sg + * Adapted to changes in fpGFX interface + + Revision 1.5 2001/02/09 20:49:03 sg + * Adapted to recent improvements in fpGFX interfaces + + Revision 1.4 2001/01/11 23:21:53 sg + *** empty log message *** + +} diff --git a/examples/img/disp_bmp/test.bmp b/examples/img/disp_bmp/test.bmp new file mode 100644 index 00000000..bda7377d Binary files /dev/null and b/examples/img/disp_bmp/test.bmp differ diff --git a/examples/img/disp_bmp/test2.bmp b/examples/img/disp_bmp/test2.bmp new file mode 100644 index 00000000..13d6323e Binary files /dev/null and b/examples/img/disp_bmp/test2.bmp differ diff --git a/examples/img/disp_bmp/test4.bmp b/examples/img/disp_bmp/test4.bmp new file mode 100644 index 00000000..4fd4a9db Binary files /dev/null and b/examples/img/disp_bmp/test4.bmp differ diff --git a/examples/img/disp_bmp/test8.bmp b/examples/img/disp_bmp/test8.bmp new file mode 100644 index 00000000..47fc32e6 Binary files /dev/null and b/examples/img/disp_bmp/test8.bmp differ diff --git a/examples/img/masktest/Makefile b/examples/img/masktest/Makefile new file mode 100644 index 00000000..4ce21577 --- /dev/null +++ b/examples/img/masktest/Makefile @@ -0,0 +1,1347 @@ +# +# Makefile generated by fpcmake v1.00 [2001/01/01] +# + +defaultrule: all + +##################################################################### +# Autodetect OS (Linux or Dos or Windows NT or OS/2) +# define inUnix when running under Unix (Linux,FreeBSD) +# define inWinNT when running under WinNT +# define inOS2 when running under OS/2 +##################################################################### + +# 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 +inUnix=1 +PWD:=$(firstword $(PWD)) +endif +else +PWD:=$(firstword $(PWD)) +endif + +# Detect NT - NT sets OS to Windows_NT +# Detect OS/2 - OS/2 has OS2_SHELL defined +ifndef inUnix +ifeq ($(OS),Windows_NT) +inWinNT=1 +else +ifdef OS2_SHELL +inOS2=1 +endif +endif +endif + +# The extension of executables +ifdef inUnix +SRCEXEEXT= +else +SRCEXEEXT=.exe +endif + +# The extension of batch files / scripts +ifdef inUnix +BATCHEXT=.sh +else +ifdef inOS2 +BATCHEXT=.cmd +else +BATCHEXT=.bat +endif +endif + +# Path Separator, the subst trick is necessary for the \ that can't exists +# at the end of a line +ifdef inUnix +PATHSEP=/ +else +PATHSEP=$(subst /,\,/) +endif + +# The path which is searched separated by spaces +ifdef inUnix +SEARCHPATH=$(subst :, ,$(PATH)) +else +SEARCHPATH=$(subst ;, ,$(PATH)) +endif + +# Base dir +ifdef PWD +BASEDIR:=$(shell $(PWD)) +else +BASEDIR=. +endif + +##################################################################### +# FPC version/target Detection +##################################################################### + +# What compiler to use ? +ifndef FPC +# Compatibility with old makefiles +ifdef PP +FPC=$(PP) +else +FPC=ppc386 +endif +endif +override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) +override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) + +# Target OS +ifndef OS_TARGET +OS_TARGET:=$(shell $(FPC) -iTO) +endif + +# Source OS +ifndef OS_SOURCE +OS_SOURCE:=$(shell $(FPC) -iSO) +endif + +# Target CPU +ifndef CPU_TARGET +CPU_TARGET:=$(shell $(FPC) -iTP) +endif + +# Source CPU +ifndef CPU_SOURCE +CPU_SOURCE:=$(shell $(FPC) -iSP) +endif + +# FPC version +ifndef FPC_VERSION +FPC_VERSION:=$(shell $(FPC) -iV) +endif + +export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION + +##################################################################### +# FPCDIR Setting +##################################################################### + +# Test FPCDIR to look if the RTL dir exists +ifdef FPCDIR +override FPCDIR:=$(subst \,/,$(FPCDIR)) +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +else +override FPCDIR=wrong +endif + +# Default FPCDIR +ifeq ($(FPCDIR),wrong) +override FPCDIR=../../../../fpc +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=wrong +endif +endif +endif + +# Detect FPCDIR +ifeq ($(FPCDIR),wrong) +ifdef inUnix +override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) +endif +else +override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH)))))) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR:=$(FPCDIR)/.. +ifeq ($(wildcard $(FPCDIR)/rtl),) +ifeq ($(wildcard $(FPCDIR)/units),) +override FPCDIR=c:/pp +endif +endif +endif +endif +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 EXEOBJECTS+=masktest + +# Clean + + +# Install + +ZIPTARGET=install + +# Defaults + +override NEEDOPT=-S2h + +# Directories + +override NEEDUNITDIR=../../src + +# Packages + +override PACKAGES+=rtl fcl fpgfx + +# Libraries + + +# Info + +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$(SRCEXEEXT),$(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 inUnix +INSTALL:=install -c -m 644 +else +INSTALL:=$(COPY) +endif +endif + +# To install programs +ifndef INSTALLEXE +ifdef inUnix +INSTALLEXE:=install -c -m 755 +else +INSTALLEXE:=$(COPY) +endif +endif + +# To make a directory. +ifndef MKDIR +ifdef inUnix +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 +PPAS=ppas$(BATCHEXT) + +# ldconfig to rebuild .so cache +ifdef inUnix +LDCONFIG=ldconfig +else +LDCONFIG= +endif + +# ppumove +ifndef PPUMOVE +PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(PPUMOVE),) +PPUMOVE= +else +PPUMOVE:=$(firstword $(PPUMOVE)) +endif +endif +export PPUMOVE + +# ppufiles +ifndef PPUFILES +PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(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$(SRCEXEEXT),$(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$(SRCEXEEXT),$(SEARCHPATH)))) +ifeq ($(ZIPPROG),) +ZIPPROG= +else +ZIPPROG:=$(firstword $(ZIPPROG)) +endif +endif +export ZIPPROG + +ZIPOPT=-9 +ZIPEXT=.zip + +# Tar +ifndef TARPROG +TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(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 +EXEEXT=.exe +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) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.lnx +endif + +# Linux +ifeq ($(OS_TARGET),freebsd) +EXEEXT= +HASSHAREDLIB=1 +FPCMADE=fpcmade.freebsd +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 +PACKAGEFCL=1 +PACKAGEFPGFX=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 PACKAGEFCL +ifneq ($(wildcard $(FPCDIR)/fcl),) +ifneq ($(wildcard $(FPCDIR)/fcl/$(OS_TARGET)),) +PACKAGEDIR_FCL=$(FPCDIR)/fcl/$(OS_TARGET) +else +PACKAGEDIR_FCL=$(FPCDIR)/fcl +endif +ifeq ($(wildcard $(PACKAGEDIR_FCL)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fcl +package_fcl: + $(MAKE) -C $(PACKAGEDIR_FCL) all +endif +UNITDIR_FCL=$(PACKAGEDIR_FCL) +else +PACKAGEDIR_FCL= +ifneq ($(wildcard $(UNITSDIR)/fcl),) +ifneq ($(wildcard $(UNITSDIR)/fcl/$(OS_TARGET)),) +UNITDIR_FCL=$(UNITSDIR)/fcl/$(OS_TARGET) +else +UNITDIR_FCL=$(UNITSDIR)/fcl +endif +else +UNITDIR_FCL= +endif +endif +ifdef UNITDIR_FCL +override NEEDUNITDIR+=$(UNITDIR_FCL) +endif +endif +ifdef PACKAGEFPGFX +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx),) +ifneq ($(wildcard $(PACKAGESDIR)/fpgfx/$(OS_TARGET)),) +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx/$(OS_TARGET) +else +PACKAGEDIR_FPGFX=$(PACKAGESDIR)/fpgfx +endif +ifeq ($(wildcard $(PACKAGEDIR_FPGFX)/$(FPCMADE)),) +override COMPILEPACKAGES+=package_fpgfx +package_fpgfx: + $(MAKE) -C $(PACKAGEDIR_FPGFX) all +endif +UNITDIR_FPGFX=$(PACKAGEDIR_FPGFX) +else +PACKAGEDIR_FPGFX= +ifneq ($(wildcard $(UNITSDIR)/fpgfx),) +ifneq ($(wildcard $(UNITSDIR)/fpgfx/$(OS_TARGET)),) +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx/$(OS_TARGET) +else +UNITDIR_FPGFX=$(UNITSDIR)/fpgfx +endif +else +UNITDIR_FPGFX= +endif +endif +ifdef UNITDIR_FPGFX +override NEEDUNITDIR+=$(UNITDIR_FPGFX) +endif +endif + + +##################################################################### +# Default Directories +##################################################################### + +# Linux and freebsd use unix dirs with /usr/bin, /usr/lib +# When zipping use the target as default, when normal install then +# use the source os as default +ifdef ZIPNAME +# Zipinstall +ifeq ($(OS_TARGET),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_TARGET),freebsd) +UNIXINSTALLDIR=1 +endif +else +# Normal install +ifeq ($(OS_SOURCE),linux) +UNIXINSTALLDIR=1 +endif +ifeq ($(OS_SOURCE),freebsd) +UNIXINSTALLDIR=1 +endif +endif + +# set the prefix directory where to install everything +ifndef PREFIXINSTALLDIR +ifdef UNIXINSTALLDIR +PREFIXINSTALLDIR=/usr +else +PREFIXINSTALLDIR=/pp +endif +endif +export PREFIXINSTALLDIR + +# Where to place the resulting zip files +ifndef DESTZIPDIR +DESTZIPDIR:=$(BASEDIR) +endif +export DESTZIPDIR + +##################################################################### +# Install Directories +##################################################################### + +# set the base directory where to install everything +ifndef BASEINSTALLDIR +ifdef UNIXINSTALLDIR +BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION) +else +BASEINSTALLDIR=$(PREFIXINSTALLDIR) +endif +endif + +# set the directory where to install the binaries +ifndef BININSTALLDIR +ifdef UNIXINSTALLDIR +BININSTALLDIR=$(PREFIXINSTALLDIR)/bin +else +BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET) +endif +endif + +# set the directory where to install the units. +ifndef UNITINSTALLDIR +UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET) +ifdef UNITSUBDIR +UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR) +endif +endif + +# Where to install shared libraries +ifndef LIBINSTALLDIR +ifdef UNIXINSTALLDIR +LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib +else +LIBINSTALLDIR=$(UNITINSTALLDIR) +endif +endif + +# Where the source files will be stored +ifndef SOURCEINSTALLDIR +ifdef UNIXINSTALLDIR +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 UNIXINSTALLDIR +DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION) +else +DOCINSTALLDIR=$(BASEINSTALLDIR)/doc +endif +endif + +# Where to install the examples, under linux we use the doc dir +# because the copytree command will create a subdir itself +ifndef EXAMPLEINSTALLDIR +ifdef UNIXINSTALLDIR +EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples +else +EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples +endif +ifdef EXAMPLESUBDIR +EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR) +endif +endif + +# Where the some extra (data)files will be stored +ifndef DATAINSTALLDIR +DATAINSTALLDIR=$(BASEINSTALLDIR) +endif + +##################################################################### +# Redirection +##################################################################### + +ifndef REDIRFILE +REDIRFILE=log +endif + +ifdef REDIR +ifndef inUnix +override FPC=redir -eo $(FPC) +endif +# set the verbosity to max +override FPCOPT+=-va +override REDIR:= >> $(REDIRFILE) +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 + +# User dirs should be first, so they are looked at first +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 + +# Smartlinking +ifdef LINKSMART +override FPCOPT+=-XX +endif + +# Smartlinking creation +ifdef CREATESMART +override FPCOPT+=-CX +endif + +# Debug +ifdef DEBUG +override FPCOPT+=-gl -dDEBUG +endif + +# Release mode (strip, optimize and don't load ppc386.cfg) +# 0.99.12b has a bug in the optimizer so don't use it by default +ifdef RELEASE +ifeq ($(FPC_VERSION),0.99.12) +override FPCOPT+=-Xs -OGp3 -n +else +override FPCOPT+=-Xs -OG2p3 -n +endif +endif + +# Strip +ifdef STRIP +override FPCOPT+=-Xs +endif + +# Optimizer +ifdef OPTIMIZE +override FPCOPT+=-OG2p3 +endif + +# Verbose settings (warning,note,info) +ifdef VERBOSE +override FPCOPT+=-vwni +endif + +ifdef NEEDOPT +override FPCOPT+=$(NEEDOPT) +endif + +ifdef NEEDUNITDIR +override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR)) +endif + +ifdef UNITSDIR +override FPCOPT+=-Fu$(UNITSDIR) +endif + +# Target dirs and the prefix to use for clean/install +ifdef TARGETDIR +override FPCOPT+=-FE$(TARGETDIR) +ifeq ($(TARGETDIR),.) +override TARGETDIRPREFIX= +else +override TARGETDIRPREFIX=$(TARGETDIR)/ +endif +endif +ifdef UNITTARGETDIR +override FPCOPT+=-FU$(UNITTARGETDIR) +ifeq ($(UNITTARGETDIR),.) +override UNITTARGETDIRPREFIX= +else +override UNITTARGETDIRPREFIX=$(TARGETDIR)/ +endif +else +ifdef TARGETDIR +override UNITTARGETDIR=$(TARGETDIR) +override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX) +endif +endif + +# Add commandline options last so they can override +ifdef OPT +override FPCOPT+=$(OPT) +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 FPCEXTCMD +ifeq ($(OS_SOURCE),win32) +override FPCEXTCMD:=$(FPCOPT) +override FPCOPT:=!FPCEXTCMD +export FPCEXTCMD +endif + +# Compiler commandline +override COMPILER:=$(FPC) $(FPCOPT) + +# also call ppas if with command option -s +# but only if the OS_SOURCE and OS_TARGE are equal +ifeq (,$(findstring -s ,$(COMPILER))) +EXECPPAS= +else +ifeq ($(OS_SOURCE),$(OS_TARGET)) +EXECPPAS:=@$(PPAS) +endif +endif + +##################################################################### +# Standard rules +##################################################################### + +all: fpc_all + +debug: fpc_debug + +smart: fpc_smart + +shared: fpc_shared + +showinstall: fpc_showinstall + +install: fpc_install + +sourceinstall: fpc_sourceinstall + +exampleinstall: fpc_exampleinstall + +zipinstall: fpc_zipinstall + +zipsourceinstall: fpc_zipsourceinstall + +zipexampleinstall: fpc_zipexampleinstall + +clean: fpc_clean + +distclean: fpc_distclean + +cleanall: fpc_cleanall + +info: fpc_info + +.PHONY: all debug smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info + +##################################################################### +# Exes +##################################################################### + +.PHONY: fpc_exes + +ifdef EXEOBJECTS +override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS)) +override EXEOFILES:=$(addsuffix $(OEXT),$(EXEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXEOBJECTS))) + +override ALLTARGET+=fpc_exes +override INSTALLEXEFILES+=$(EXEFILES) +override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES) + +endif + +fpc_exes: $(EXEFILES) + +##################################################################### +# General compile rules +##################################################################### + +.PHONY: fpc_packages fpc_all fpc_debug + +$(FPCMADE): $(ALLTARGET) + @$(ECHO) Compiled > $(FPCMADE) + +fpc_packages: $(COMPILEPACKAGES) + +fpc_all: fpc_packages $(FPCMADE) + +fpc_debug: + $(MAKE) all DEBUG=1 + +# Search paths for .ppu if targetdir is set +ifdef UNITTARGETDIR +vpath %$(PPUEXT) $(UNITTARGETDIR) +endif + +# General compile rules, available for both possible PASEXT + +.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp + +%$(PPUEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(PPUEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pp + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +%$(EXEEXT): %.pas + $(COMPILER) $< $(REDIR) + $(EXECPPAS) + +##################################################################### +# Library +##################################################################### + +.PHONY: fpc_smart fpc_shared + +ifdef LIBVERSION +LIBFULLNAME=$(LIBNAME).$(LIBVERSION) +else +LIBFULLNAME=$(LIBNAME) +endif + +# Default sharedlib units are all unit objects +ifndef SHAREDLIBUNITOBJECTS +SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS) +endif + +fpc_smart: + $(MAKE) all LINKSMART=1 CREATESMART=1 + +fpc_shared: all +ifdef HASSHAREDLIB +ifndef LIBNAME + @$(ECHO) "LIBNAME not set" +else + $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME) +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 +override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) +ifdef PPUFILES +INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)) +else +INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))) +endif +override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)) +endif + +ifdef INSTALLEXEFILES +override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) +endif + +fpc_showinstall: $(SHOWINSTALLTARGET) +ifdef INSTALLEXEFILES + @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES)) +endif +ifdef INSTALLPPUFILES + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)) +ifneq ($(INSTALLPPULINKFILES),) + @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES)) +endif +ifneq ($(wildcard $(LIBFULLNAME)),) + @$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME) +ifdef HASSHAREDLIB + @$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(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 ($(wildcard $(LIBFULLNAME)),) + $(MKDIR) $(LIBINSTALLDIR) + $(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR) +ifdef inUnix + ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME) +endif +endif +endif +ifdef EXTRAINSTALLFILES + $(MKDIR) $(DATAINSTALLDIR) + $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR) +endif + +##################################################################### +# SourceInstall rules +##################################################################### + +.PHONY: fpc_sourceinstall + +ifndef SOURCETOPDIR +SOURCETOPDIR=$(BASEDIR) +endif + +fpc_sourceinstall: clean + $(MKDIR) $(SOURCEINSTALLDIR) + $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR) + +##################################################################### +# exampleinstall rules +##################################################################### + +.PHONY: fpc_exampleinstall + +fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS)) +ifdef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) + $(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR) +endif +ifdef EXAMPLEDIROBJECTS +ifndef EXAMPLESOURCEFILES + $(MKDIR) $(EXAMPLEINSTALLDIR) +endif + $(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR) +endif + +##################################################################### +# 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 +ifeq ($(OS_TARGET),os2) +PACKAGESUFFIX=emx +endif +endif + +# Temporary path to pack a file +ifndef PACKDIR +ifndef inUnix +PACKDIR=$(BASEDIR)/pack_tmp +else +PACKDIR=/tmp/fpc-pack +endif +endif + +# Maybe create default zipname from packagename +ifndef ZIPNAME +ifdef PACKAGENAME +ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX) +endif +endif + +# Use tar by default under linux +ifndef USEZIP +ifdef inUnix +USETAR=1 +endif +endif + +# Use a wrapper script by default for OS/2 +ifdef inOS2 +USEZIPWRAPPER=1 +endif + +# Create commands to create the zip/tar file +ZIPWRAPPER=$(DESTZIPDIR)/fpczip$(BATCHEXT) +ZIPCMD_CDPACK:=cd $(subst /,$(PATHSEP),$(PACKDIR)) +ZIPCMD_CDBASE:=cd $(subst /,$(PATHSEP),$(BASEDIR)) +ifdef USETAR +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) +ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) * +else +ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) +ZIPCMD_ZIP:=$(subst /,$(PATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) * +endif + +fpc_zipinstall: +ifndef ZIPNAME + @$(ECHO) "Please specify ZIPNAME!" + @exit 1 +else + $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR) + $(DEL) $(ZIPDESTFILE) +ifdef USEZIPWRAPPER +ifneq ($(ECHO),echo) + $(ECHO) "$(ZIPCMD_CDPACK)" > $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_ZIP)" >> $(ZIPWRAPPER) + $(ECHO) "$(ZIPCMD_CDBASE)" >> $(ZIPWRAPPER) +else + $(ECHO) $(ZIPCMD_CDPACK) > $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_ZIP) >> $(ZIPWRAPPER) + $(ECHO) $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER) +endif +ifdef inUnix + /bin/sh $(ZIPWRAPPER) +else + $(ZIPWRAPPER) +endif + $(DEL) $(ZIPWRAPPER) +else + $(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE) +endif + $(DELTREE) $(PACKDIR) +endif + +.PHONY: fpc_zipsourceinstall + +fpc_zipsourceinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src + +.PHONY: fpc_zipexampleinstall + +fpc_zipexampleinstall: + $(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm + +##################################################################### +# Clean rules +##################################################################### + +.PHONY: fpc_clean fpc_cleanall fpc_distclean + +ifdef EXEFILES +override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES)) +endif + +ifdef EXTRACLEANUNITS +override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)) +endif + +ifdef CLEANPPUFILES +override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES)) +# Get the .o and .a files created for the units +ifdef PPUFILES +CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES)) +else +CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))) +endif +override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)) +endif + +fpc_clean: $(CLEANTARGET) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif +ifdef CLEANPPUFILES + -$(DEL) $(CLEANPPUFILES) +endif +ifneq ($(CLEANPPULINKFILES),) + -$(DEL) $(CLEANPPULINKFILES) +endif +ifdef CLEANRSTFILES + -$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES)) +endif +ifdef EXTRACLEANFILES + -$(DEL) $(EXTRACLEANFILES) +endif +ifdef LIBNAME + -$(DEL) $(LIBNAME) $(LIBFULLNAME) +endif + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE) + +fpc_distclean: fpc_clean + +# Also run clean first if targetdir is set. Unittargetdir is always +# set if targetdir or unittargetdir is specified +ifdef UNITTARGETDIR +TARGETDIRCLEAN=fpc_clean +endif + +fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN) +ifdef CLEANEXEFILES + -$(DEL) $(CLEANEXEFILES) +endif + -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT) + -$(DELTREE) *$(SMARTEXT) + -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(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 +ifdef PACKAGEPREFIX + @$(ECHO) PackagePrefix........ $(PACKAGEPREFIX) +endif +ifdef PACKAGENAME + @$(ECHO) PackageName.......... $(PACKAGENAME) +endif + @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX) + @$(ECHO) + @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR) + @$(ECHO) BinInstallDir........ $(BININSTALLDIR) + @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR) + @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR) + @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR) + @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR) + @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR) + @$(ECHO) + @$(ECHO) DestZipDir........... $(DESTZIPDIR) + @$(ECHO) ZipName.............. $(ZIPNAME) + @$(ECHO) + +##################################################################### +# Local Makefile +##################################################################### + +ifneq ($(wildcard fpcmake.loc),) +include fpcmake.loc +endif + diff --git a/examples/img/masktest/Makefile.fpc b/examples/img/masktest/Makefile.fpc new file mode 100644 index 00000000..5151e7a3 --- /dev/null +++ b/examples/img/masktest/Makefile.fpc @@ -0,0 +1,14 @@ +# +# Makefile.fpc for fpImg example "masktest" +# + +[targets] +programs=masktest + +[require] +options=-S2h +packages=fcl fpgfx + +[dirs] +fpcdir=../../../../fpc +unitdir=../../src diff --git a/examples/img/masktest/image2.bmp b/examples/img/masktest/image2.bmp new file mode 100644 index 00000000..8e08ff44 Binary files /dev/null and b/examples/img/masktest/image2.bmp differ diff --git a/examples/img/masktest/image24.bmp b/examples/img/masktest/image24.bmp new file mode 100644 index 00000000..8c4f248d Binary files /dev/null and b/examples/img/masktest/image24.bmp differ diff --git a/examples/img/masktest/image4.bmp b/examples/img/masktest/image4.bmp new file mode 100644 index 00000000..c57697ba Binary files /dev/null and b/examples/img/masktest/image4.bmp differ diff --git a/examples/img/masktest/image8.bmp b/examples/img/masktest/image8.bmp new file mode 100644 index 00000000..85d08b9f Binary files /dev/null and b/examples/img/masktest/image8.bmp differ diff --git a/examples/img/masktest/mask.bmp b/examples/img/masktest/mask.bmp new file mode 100644 index 00000000..7cc016e5 Binary files /dev/null and b/examples/img/masktest/mask.bmp differ diff --git a/examples/img/masktest/masktest.pas b/examples/img/masktest/masktest.pas new file mode 100644 index 00000000..2539bf07 --- /dev/null +++ b/examples/img/masktest/masktest.pas @@ -0,0 +1,150 @@ +{ + $Id: masktest.pp,v 1.3 2001/02/14 23:08:59 sg Exp $ + + fpImg - Free Pascal Imaging Library + Copyright (C) 2000 - 2001 by + Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org + + Example: Display BMP file with monochrome mask + + See the file COPYING, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +} + + +program MaskTest; + +uses Classes, GFXBase, GFXImpl, fpImg, BMPReader; + +type + TMainWindow = class + procedure Paint(Sender: TObject; const ARect: TRect); + private + Display: TDefDisplay; + Window: TGfxWindow; + Image2, Image4, Image8, Image24, Mask: TGfxImage; + Image2Canvas, Image4Canvas, Image8Canvas, + Image24Canvas, MaskCanvas: TGfxCanvas; + public + constructor Create(ADisplay: TDefDisplay); + destructor Destroy; override; + end; + +constructor TMainWindow.Create(ADisplay: TDefDisplay); +begin + inherited Create; + Display := ADisplay; + + // Load and prepare the images + Image2 := CreateImageFromFile(Display.DefaultScreen, TBMPReader, 'image2.bmp'); + Image2Canvas := + Display.DefaultScreen.CreateBitmap(Image2.Width, Image2.Height); + Image2Canvas.DrawImage(Image2, Point(0, 0)); + + Image4 := CreateImageFromFile(Display.DefaultScreen, TBMPReader, 'image4.bmp'); + Image4Canvas := + Display.DefaultScreen.CreateBitmap(Image4.Width, Image4.Height); + Image4Canvas.DrawImage(Image4, Point(0, 0)); + + Image8 := CreateImageFromFile(Display.DefaultScreen, TBMPReader, 'image8.bmp'); + Image8Canvas := + Display.DefaultScreen.CreateBitmap(Image8.Width, Image8.Height); + Image8Canvas.DrawImage(Image8, Point(0, 0)); + + Image24 := CreateImageFromFile(Display.DefaultScreen, TBMPReader, 'image24.bmp'); + Image24Canvas := + Display.DefaultScreen.CreateBitmap(Image24.Width, Image24.Height); + Image24Canvas.DrawImage(Image24, Point(0, 0)); + + // Load and prepare the image mask + Mask := CreateImageFromFile(Display.DefaultScreen, TBMPReader, 'mask.bmp'); + MaskCanvas := Display.DefaultScreen.CreateMonoBitmap(Mask.Width, Mask.Height); + MaskCanvas.DrawImage(Mask, Point(0, 0)); + + Window := ADisplay.DefaultScreen.CreateWindow; + Window.Title := 'fpImg Blitting Mask Test'; + Window.OnPaint := @Paint; + Window.SetClientSize(Size(Image2.Width * 2 + 64, Image2.Height * 2 + 64)); + Window.Show; +end; + +destructor TMainWindow.Destroy; +begin + MaskCanvas.Free; + Mask.Free; + Image24Canvas.Free; + Image24.Free; + Image8Canvas.Free; + Image8.Free; + Image4Canvas.Free; + Image4.Free; + Image2Canvas.Free; + Image2.Free; + inherited Destroy; +end; + +procedure TMainWindow.Paint(Sender: TObject; const ARect: TRect); +var + Color: TGfxColor; + r: TRect; + i, x1, y1, x2, y2: Integer; +begin + Color.Red := 0; + Color.Green := 0; + Color.Alpha := 0; + r.Left := ARect.Left; + r.Right := ARect.Right; + for i := ARect.Top to ARect.Bottom - 1 do + begin + Color.Blue := $ffff - (i * $ffff) div Window.Height; + Color.Red := Color.Blue shr 1; + Window.Canvas.SetColor(Color); + r.Top := i; + r.Bottom := i + 1; + Window.Canvas.FillRect(r); + end; + + x1 := Window.ClientWidth div 4 - Image2.Width div 2; + y1 := Window.ClientHeight div 4 - Image2.Height div 2; + x2 := x1 + Window.ClientWidth div 2; + y2 := y1 + Window.ClientHeight div 2; + + Window.Canvas.MaskedCopy(Image2Canvas, MaskCanvas, Point(x1, y1)); + Window.Canvas.TextOut(Point(x1, y1 + Image2.Height), 'monochrome'); + Window.Canvas.MaskedCopy(Image4Canvas, MaskCanvas, Point(x2, y1)); + Window.Canvas.TextOut(Point(x2, y1 + Image2.Height), '4bpp palettized'); + Window.Canvas.MaskedCopy(Image8Canvas, MaskCanvas, Point(x1, y2)); + Window.Canvas.TextOut(Point(x1, y2 + Image2.Height), '8bpp palettized'); + Window.Canvas.MaskedCopy(Image24Canvas, MaskCanvas, Point(x2, y2)); + Window.Canvas.TextOut(Point(x2, y2 + Image2.Height), '24bpp true color'); +end; + +var + Display: TDefDisplay; + MainWindow: TMainWindow; +begin +WriteLn('Version: ' + {$I %date%} + ' ' + {$I %time%}); + Display := TDefDisplay.Create; + MainWindow := TMainWindow.Create(Display); + Display.Run; + MainWindow.Free; + Display.Free; +end. + + +{ + $Log: masktest.pp,v $ + Revision 1.3 2001/02/14 23:08:59 sg + * Adapted to changes in fpGFX interface + + Revision 1.2 2001/02/09 20:49:03 sg + * Adapted to recent improvements in fpGFX interfaces + + Revision 1.1 2001/01/11 23:21:53 sg + *** empty log message *** + +} -- cgit v1.2.3-70-g09d2