pas2js/Makefile.fpc
2017-12-30 12:23:44 +00:00

207 lines
6.9 KiB
Makefile

#
# Makefile.fpc for running fpmake
#
[package]
name=pas2js
version=3.1.1
[install]
fpcpackage=n
[default]
fpcdir=../../fpc
[prerules]
FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
ifdef OS_TARGET
FPC_TARGETOPT+=--os=$(OS_TARGET)
endif
ifdef CPU_TARGET
FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
endif
LOCALFPMAKE=./fpmake$(SRCEXEEXT)
[rules]
# Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
# Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
# Compose general fpmake-parameters
ifdef FPMAKEOPT
FPMAKE_OPT+=$(FPMAKEOPT)
endif
FPMAKE_OPT+=$(FPC_TARGETOPT)
FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
FPMAKE_OPT+=--compiler=$(FPC)
FPMAKE_OPT+=-bu
.NOTPARALLEL:
fpmake$(SRCEXEEXT): fpmake.pp
$(FPCFPMAKE) fpmake.pp $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
all: fpmake$(SRCEXEEXT)
$(LOCALFPMAKE) compile $(FPMAKE_OPT)
smart: fpmake$(SRCEXEEXT)
$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
release: fpmake$(SRCEXEEXT)
$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
debug: fpmake$(SRCEXEEXT)
$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
# If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
# most often fail because the dependencies are cleared.
# In case of a clean, simply do nothing
ifeq ($(FPMAKE_BIN_CLEAN),)
clean:
else
clean:
$(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
endif
# In case of a distclean, perform an 'old'-style distclean. This to avoid problems
# when the package is compiled using fpcmake prior to running this clean using fpmake
ifeq ($(FPMAKE_BIN_CLEAN),)
distclean: $(addsuffix _distclean,$(TARGET_DIRS)) fpc_cleanall
else
distclean:
ifdef inUnix
{ $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT); if [ $$? != "0" ]; then { echo Something wrong with fpmake exectable. Remove the executable and call make recursively to recover.; $(DEL) $(FPMAKE_BIN_CLEAN); $(MAKE) fpc_cleanall; }; fi; }
else
$(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
endif
-$(DEL) $(LOCALFPMAKE)
endif
cleanall: distclean
install: fpmake$(SRCEXEEXT)
ifdef UNIXHier
$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR)
else
$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR)
endif
# distinstall also installs the example-sources and omits the location of the source-
# files from the fpunits.cfg files.
distinstall: fpmake$(SRCEXEEXT)
ifdef UNIXHier
$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
else
$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
endif
#
# Custom installer
#
.PHONY: democonfig demozip help demoupload
ifndef PAS2JS
PAS2JS=bin/$(CPU_TARGET)-$(OS_TARGET)/pas2js$(EXEEXT)
endif
ifeq (,$(wildcard $(PAS2JS)))
PAS2JS=pas2js$(EXEEXT)
endif
PAS2JSVERSION:=$(shell $(PAS2JS) -iV)
#
# Demo zip
#
PACKAGEFILES=packages/rtl/rtl.js
PACKAGEFILES+=$(wildcard packages/*/*.pas)
PACKAGEFILES+=$(wildcard packages/*/*.pp)
PACKAGEFILES+=$(wildcard packages/*/*.lpk)
DEMOFILES=$(wildcard demo/rtl/*.html)
DEMOFILES+=$(wildcard demo/rtl/*.pas)
DEMOFILES+=$(wildcard demo/rtl/*.lpi)
DEMOFILES+=$(wildcard demo/rtl/*.lpr)
DEMOFILES+=demo/rtl/countries.json
DEMOFILES+=$(wildcard demo/jquery/*.lpr)
DEMOFILES+=$(wildcard demo/jquery/*.lpi)
DEMOFILES+=$(wildcard demo/jquery/*.pas)
DEMOFILES+=$(wildcard demo/jquery/*.html)
DEMOFILES+=$(wildcard demo/fpreport/*.html)
DEMOFILES+=$(wildcard demo/fpreport/*.lpi)
DEMOFILES+=$(wildcard demo/fpreport/*.lpr)
DEMOFILES+=$(wildcard demo/fpreport/*.pp)
DEMOFILES+=$(wildcard demo/fpreport/*.md)
DEMOFILdemoinfES+=$(wildcard demo/hotreload/*.html)
DEMOFILES+=$(wildcard demo/hotreload/*.lpr)
DEMOFILES+=$(wildcard demo/hotreload/*.lpi)
DEMOFILES+=$(wildcard demo/hotreload/*.pas)
DEMOFILES+=$(wildcard demo/fpcunit/*.html)
DEMOFILES+=$(wildcard demo/fpcunit/*.lpr)
DEMOFILES+=$(wildcard demo/fpcunit/*.lpi)
DEMOFILES+=$(wildcard demo/fpcunit/*.pas)
DEMOFILES+=$(wildcard demo/fcldb/*.html)
DEMOFILES+=$(wildcard demo/fcldb/*.lpr)
DEMOFILES+=$(wildcard demo/fcldb/*.lpi)
DEMOFILES+=$(wildcard demo/fcldb/*.pas)
DEMOFILES+=$(wildcard demo/fcldb/*.json)
DEMOFILES+=demo/rtl/README.md
DOCFILES+=docs/translation.html
DEMOZIPFILE=pas2js-demo-$(PAS2JSVERSION).zip
BINDIR=bin/$(CPU_TARGET)-$(OS_TARGET)
COMPILERS=$(wildcard $BINDIR/*$(EXEEXT))
COMPILERS+=$(wildcard $BINDIR/*$(SHAREDLIBEXT))
CFGFILE=bin/$(CPU_TARGET)-$(OS_TARGET)/pas2js.cfg
#
# End of demo zip
#
#
# Upload
#
SSHUPLOAD=fpc@ftpmaster.freepascal.org
SSHUPLOABASEDIR=ftp/contrib/pas2js
SSHUPLOADVERSION=$(SSHUPLOABASEDIR)/$(PAS2JSVERSION)
BASEURL=ftp://ftpmaster.freepascal.org/fpc/contrib/pas2js/
#
# Dist zipfile filename
#
ifeq (1,$(UNIXHier))
ZIPEXT=.tar.gz
else
ZIPEXT=.zip
endif
DISTZIPFILE=$(FULLZIPNAME)$(ZIPEXT)
#
help:
@echo "Detected pas2js version: $(PAS2JSVERSION)"
@echo "Supported targets:"
@echo "help this info"
@echo "all compile for current platform"
@echo "install install in an existing FPC installation"
@echo "clean clear files left over by compilation"
@echo "distclean clean + remove build files"
@echo "info show all used variables"
@echo "zipinstall create zip file which can be installed in a FPC installation."
@echo "upload upload ZIP file created by zipinstall to FPC FTP site"
@echo "democonfig create config file in bin dir"
@echo "demozip create alternate demo zip file (deprecated)"
@echo "demoupload upload alternate demo zip file (deprecated)"
@echo ""
@echo "Demo URL $(BASEURL)$(DEMOZIPFILE)"
@echo "Distribution URL $(BASEURL)$(PAS2JSVERSION)/$(DISTZIPFILE)"
utils/createconfig$(SRCEXEEXT): utils/createconfig.pp
$(FPC) utils/createconfig.pp
democonfig: utils/createconfig$(SRCEXEEXT)
utils/createconfig$(SRCEXEEXT) $(CFGFILE) ../..
demozip: democonfig $(DEMOZIPFILE)
@echo Version: $(PAS2JSVERSION)
rm -f $(DEMOZIPFILE)
cp compiler/utils/pas2js/dist/rtl.js packages/rtl
zip $(DEMOZIPFILE) $(COMPILERS) $(RTLFILES) $(PACKAGEFILES) $(DOCFILES) $(DEMOFILES) $(CFGFILE)
demoupload: demozip
ssh $(SSHUPLOAD) mkdir -p $(SSHUPLOADBASEDIR)
scp $(DEMOZIPFILE) $(SSHUPLOAD):$(SSHUPLOADBASEDIR)
@echo "Demo URL $(BASEURL)$(DEMOZIPFILE)"
$(DISTZIPFILE): zipinstall
upload: $(DISTZIPFILE)
ssh $(SSHUPLOAD) mkdir -p $(SSHUPLOADVERSION)
scp $(DISTZIPFILE) $(SSHUPLOAD):$(SSHUPLOADVERSION)
ssh $(SSHUPLOAD) chhmod 644 $(SSHUPLOADVERSION)/$(DISTZIPFILE)
@echo "Distribution URL $(BASEURL)$(PAS2JSVERSION)/$(DISTZIPFILE)"