# Portable Forth written in 'C'
# For more info visit http://www.softsynth.com/pforth/
# See "help" target below.
# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
# See "docs/pf_ref.htm" file for more info.
PFORTHDIR
:= $(shell cd ..
/..
/; pwd
)
CSRCDIR
= $(PFORTHDIR
)/csrc
FTHDIR
= $(PFORTHDIR
)/fth
PFDICAPP
= $(FTHDIR
)/pforth
PFORTHDIC
= $(FTHDIR
)/pforth.dic
PFDICDAT
= ${CSRCDIR}/pfdicdat.h
PFORTHAPP
= $(PFORTHDIR
)/pforth_standalone
OBJECTDIR
= $(PFORTHDIR
)/objects
TEMPOBJECTDIR
= $(PFORTHDIR
)/tempobjects
# This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
-fno-keep-inline-functions \
CCOPTS
= $(WIDTHOPT
) -x c
-DPF_SUPPORT_FP
-O2
$(FULL_WARNINGS
) $(EXTRA_CCOPTS
) $(DEBUGOPTS
)
IO_SOURCE
= ${CSRCDIR}/posix
/pf_io_posix.c
#IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
EMBCCOPTS
= -DPF_STATIC_DIC
#######################################
# Build file lists from wildcards.
PFITEMP
= ${wildcard ${CSRCDIR}/*.h
}
PFINCLUDES
= ${PFITEMP
:${CSRCDIR}/pfdicdat.h
=}
PFSOURCE
= ${wildcard ${CSRCDIR}/*.c
} ${IO_SOURCE}
PFTEMP
= ${PFSOURCE
:%.c
=%.o
}
PFOBJS
= ${PFTEMP
:${CSRCDIR}/%=${TEMPOBJECTDIR}/%}
PFEMBOBJS
= ${PFTEMP
:${CSRCDIR}/%=${OBJECTDIR}/%}
COMPILE
= $(COMPILER
) $(CCOPTS
) $(CDEFS
)
${TEMPOBJECTDIR}/%.o
: ${TEMPOBJECTDIR} $(PFINCLUDES
) ${CSRCDIR}/%.c
$(COMPILE
) -O
-o
${TEMPOBJECTDIR}/$*.o
-c
${CSRCDIR}/$*.c
${OBJECTDIR}/%.o
: ${OBJECTDIR} $(PFINCLUDES
) ${CSRCDIR}/%.c
${CSRCDIR}/pfdicdat.h
$(COMPILE
) -O
-o
${OBJECTDIR}/$*.o
-c
${CSRCDIR}/$*.c
$(EMBCCOPTS
)
@echo
"ITEMP FILES -----------------"
@echo
"INCLUDE FILES -----------------"
@echo
"'C' FILES ---------------------"
@echo
"OBJECT FILES ------------------"
@echo
"EMBEDDED OBJECT FILES ------------------"
mkdir
-p
${TEMPOBJECTDIR}/posix
mkdir
-p
${TEMPOBJECTDIR}/stdio
mkdir
-p
${OBJECTDIR}/posix
mkdir
-p
${OBJECTDIR}/stdio
# Build pforth by compiling 'C' source.
$(PFDICAPP
): $(PFINCLUDES
) $(PFOBJS
)
$(COMPILER
) $(PFOBJS
) $(WIDTHOPT
) -lm
-o
$(PFDICAPP
)
# Build basic dictionary image by running newly built pforth and including "system.fth".
cd
$(FTHDIR
); $(PFDICAPP
) -i system.fth
; mv pfdicdat.h
$(PFDICDAT
)
$(PFORTHAPP
): $(PFDICDAT
) $(PFEMBOBJS
)
$(COMPILER
) $(PFEMBOBJS
) $(WIDTHOPT
) -lm
-o
$(PFORTHAPP
)
@echo
"Standalone pForth executable written to $(PFORTHAPP)"
@echo
"Use 'make all' to build standalone pForth executable."
@echo
"PForth can be built in several stages using these targets:"
@echo
" pfdicapp = executable pForth with minimal dictionary. All from 'C'."
@echo
" pfdicdat = image of full dictionary build by compiling Forth code."
@echo
" pforthapp = executable with embedded dictionary image. DEFAULT 'all' target."
@echo
" The file 'fth/pfdicdat.h' is generated by pForth. It contains a binary image of the Forth dictionary."
@echo
" It allows pForth to work as a standalone image that does not need to load a dictionary file."
rm -f
$(PFOBJS
) $(PFEMBOBJS
)
rm -rf
$(OBJECTDIR
) $(TEMPOBJECTDIR
)