2 # Portable Forth written in 'C'
4 # For more info visit http://www.softsynth.com/pforth/
6 # See "help" target below.
10 # Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
11 # See "docs/pf_ref.htm" file for more info.
15 PFORTHDIR := $(shell cd ../../; pwd)
16 CSRCDIR = $(PFORTHDIR)/csrc
17 FTHDIR = $(PFORTHDIR)/fth
19 PFDICAPP = $(FTHDIR)/pforth
20 PFORTHDIC = $(FTHDIR)/pforth.dic
21 PFDICDAT = ${CSRCDIR}/pfdicdat.h
22 PFORTHAPP = $(PFORTHDIR)/pforth_standalone
23 OBJECTDIR = $(PFORTHDIR)/objects
24 TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects
26 # This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
34 -fno-keep-inline-functions \
39 -Wmissing-prototypes \
40 -Wmissing-declarations
43 CCOPTS = $(WIDTHOPT) -x c -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS)
45 IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c
46 #IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
48 EMBCCOPTS = -DPF_STATIC_DIC
50 #######################################
51 # Build file lists from wildcards.
52 PFITEMP = ${wildcard ${CSRCDIR}/*.h}
53 PFINCLUDES = ${PFITEMP:${CSRCDIR}/pfdicdat.h=}
54 PFSOURCE = ${wildcard ${CSRCDIR}/*.c} ${IO_SOURCE}
55 PFTEMP = ${PFSOURCE:%.c=%.o}
56 PFOBJS = ${PFTEMP:${CSRCDIR}/%=${TEMPOBJECTDIR}/%}
57 PFEMBOBJS = ${PFTEMP:${CSRCDIR}/%=${OBJECTDIR}/%}
59 COMPILE = $(COMPILER) $(CCOPTS) $(CDEFS)
61 ${TEMPOBJECTDIR}/%.o: ${TEMPOBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c
62 $(COMPILE) -O -o ${TEMPOBJECTDIR}/$*.o -c ${CSRCDIR}/$*.c
64 ${OBJECTDIR}/%.o: ${OBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c ${CSRCDIR}/pfdicdat.h
65 $(COMPILE) -O -o ${OBJECTDIR}/$*.o -c ${CSRCDIR}/$*.c $(EMBCCOPTS)
70 @echo "ITEMP FILES -----------------"
72 @echo "INCLUDE FILES -----------------"
74 @echo "'C' FILES ---------------------"
76 @echo "OBJECT FILES ------------------"
78 @echo "EMBEDDED OBJECT FILES ------------------"
82 mkdir -p ${TEMPOBJECTDIR}/posix
83 mkdir -p ${TEMPOBJECTDIR}/stdio
86 mkdir -p ${OBJECTDIR}/posix
87 mkdir -p ${OBJECTDIR}/stdio
89 # Build pforth by compiling 'C' source.
90 $(PFDICAPP): $(PFINCLUDES) $(PFOBJS)
91 $(COMPILER) $(PFOBJS) $(WIDTHOPT) -lm -o $(PFDICAPP)
93 # Build basic dictionary image by running newly built pforth and including "system.fth".
94 $(PFDICDAT): $(PFDICAPP)
95 cd $(FTHDIR); $(PFDICAPP) -i system.fth ; mv pfdicdat.h $(PFDICDAT)
97 $(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS)
98 $(COMPILER) $(PFEMBOBJS) $(WIDTHOPT) -lm -o $(PFORTHAPP)
100 @echo "Standalone pForth executable written to $(PFORTHAPP)"
104 pfdicapp: $(PFDICAPP)
106 pfdicdat: $(PFDICDAT)
108 pforthapp: $(PFORTHAPP)
111 @echo "Use 'make all' to build standalone pForth executable."
112 @echo "PForth can be built in several stages using these targets:"
113 @echo " pfdicapp = executable pForth with minimal dictionary. All from 'C'."
114 @echo " pfdicdat = image of full dictionary build by compiling Forth code."
115 @echo " pforthapp = executable with embedded dictionary image. DEFAULT 'all' target."
117 @echo " The file 'fth/pfdicdat.h' is generated by pForth. It contains a binary image of the Forth dictionary."
118 @echo " It allows pForth to work as a standalone image that does not need to load a dictionary file."
122 -rm -f $(PFOBJS) $(PFEMBOBJS)