#
# Makefile generated by fpcmake v0.99.15 [2000/07/02]
#

defaultrule: all

#####################################################################
# Autodetect OS (Linux or Dos or Windows NT)
# define inlinux when running under linux
# define inWinNT when running under WinNT
#####################################################################

# We need only / in the path
override PATH:=$(subst \,/,$(PATH))

# Search for PWD and determine also if we are under linux
PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
ifeq ($(PWD),)
PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
ifeq ($(PWD),)
nopwd:
	@echo You need the GNU utils package to use this Makefile!
	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
	@exit
else
inlinux=1
endif
else
PWD:=$(firstword $(PWD))
endif

# Detect NT - NT sets OS to Windows_NT
ifndef inlinux
ifeq ($(OS),Windows_NT)
inWinNT=1
endif
endif

# Detect OS/2 - OS/2 has OS2_SHELL defined
ifndef inlinux
ifndef inWinNT
ifdef OS2_SHELL
inOS2=1
endif
endif
endif

# The extension of executables
ifdef inlinux
EXEEXT=
else
EXEEXT=.exe
endif

# The path which is searched separated by spaces
ifdef inlinux
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
ifdef inOS2
FPC=ppos2
else
FPC=ppc386
endif
endif
endif
override FPC:=$(subst $(EXEEXT),,$(FPC))
override FPC:=$(subst \,/,$(FPC))$(EXEEXT)

# 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 inlinux
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 src)

# Clean


# Install

ZIPTARGET=install

# Defaults


# Directories


# Packages


# Libraries




#####################################################################
# Default Directories
#####################################################################

# set the prefix directory where to install everything
ifndef PREFIXINSTALLDIR
ifdef inlinux
PREFIXINSTALLDIR=/usr
else
PREFIXINSTALLDIR=/pp
endif
endif
export PREFIXINSTALLDIR

# Where to place the resulting zip files
ifndef DESTZIPDIR
DESTZIPDIR:=$(BASEDIR)
endif
export DESTZIPDIR

#####################################################################
# Redirection
#####################################################################

ifndef REDIRFILE
REDIRFILE=log
endif

ifdef REDIR
ifndef inlinux
override FPC=redir -eo $(FPC)
endif
# set the verbosity to max
override FPCOPT+=-va
override REDIR:= >> $(REDIRFILE)
endif

#####################################################################
# Standard rules
#####################################################################

all: $(addsuffix _all,src)

debug: $(addsuffix _debug,src)

smart: $(addsuffix _smart,src)

shared: $(addsuffix _shared,src)

showinstall: $(addsuffix _showinstall,src)

install: $(addsuffix _install,src)

clean: $(addsuffix _clean,src)

distclean: $(addsuffix _distclean,src)

cleanall: $(addsuffix _cleanall,src)

require: $(addsuffix _require,src)

.PHONY:  all debug smart shared showinstall install clean distclean cleanall require

#####################################################################
# Directories
#####################################################################

OBJECTDIRSRC=1

# Dir src

ifdef OBJECTDIRSRC
.PHONY:  src_all src_debug src_examples src_test src_smart src_shared src_showinstall src_install src_sourceinstall src_exampleinstall src_zipinstall src_zipsourceinstall src_zipexampleinstall src_clean src_distclean src_cleanall src_require src_info

src_all:
	$(MAKE) -C src all

src_debug:
	$(MAKE) -C src debug

src_examples:
	$(MAKE) -C src examples

src_test:
	$(MAKE) -C src test

src_smart:
	$(MAKE) -C src smart

src_shared:
	$(MAKE) -C src shared

src_showinstall:
	$(MAKE) -C src showinstall

src_install:
	$(MAKE) -C src install

src_sourceinstall:
	$(MAKE) -C src sourceinstall

src_exampleinstall:
	$(MAKE) -C src exampleinstall

src_zipinstall:
	$(MAKE) -C src zipinstall

src_zipsourceinstall:
	$(MAKE) -C src zipsourceinstall

src_zipexampleinstall:
	$(MAKE) -C src zipexampleinstall

src_clean:
	$(MAKE) -C src clean

src_distclean:
	$(MAKE) -C src distclean

src_cleanall:
	$(MAKE) -C src cleanall

src_require:
	$(MAKE) -C src require

src_info:
	$(MAKE) -C src info
endif

#####################################################################
# Local Makefile
#####################################################################

ifneq ($(wildcard fpcmake.loc),)
include fpcmake.loc
endif

