Fix REPOSITION-FILE, HISTORY, locked file handle and other problems.
[pforth] / build / unix / Makefile
... / ...
CommitLineData
1# makefile for pForth
2# Portable Forth written in 'C'
3# by Phil Burk
4# For more info visit http://www.softsynth.com/pforth/
5#
6# See "help" target below.
7
8.SUFFIXES: .c .o
9
10# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
11# See "docs/pf_ref.htm" file for more info.
12
13COMPILER = gcc
14
15PFORTHDIR := $(shell cd ../../; pwd)
16CSRCDIR = $(PFORTHDIR)/csrc
17FTHDIR = $(PFORTHDIR)/fth
18
19PFDICAPP = $(FTHDIR)/pforth
20PFORTHDIC = $(FTHDIR)/pforth.dic
21PFDICDAT = ${CSRCDIR}/pfdicdat.h
22PFORTHAPP = $(PFORTHDIR)/pforth_standalone
23OBJECTDIR = $(PFORTHDIR)/objects
24TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects
25
26# This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
27WIDTHOPT=
28
29FULL_WARNINGS = \
30 -fsigned-char \
31 -fno-builtin \
32 -fno-unroll-loops \
33 -fpeephole \
34 -fno-keep-inline-functions \
35 -Wcast-qual \
36 -Wall \
37 -Wwrite-strings \
38 -Winline \
39 -Wmissing-prototypes \
40 -Wmissing-declarations
41
42DEBUGOPTS = -g
43CCOPTS = $(WIDTHOPT) -x c -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS)
44
45IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c
46#IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
47
48EMBCCOPTS = -DPF_STATIC_DIC
49
50#######################################
51# Build file lists from wildcards.
52PFITEMP = ${wildcard ${CSRCDIR}/*.h}
53PFINCLUDES = ${PFITEMP:${CSRCDIR}/pfdicdat.h=}
54PFSOURCE = ${wildcard ${CSRCDIR}/*.c} ${IO_SOURCE}
55PFTEMP = ${PFSOURCE:%.c=%.o}
56PFOBJS = ${PFTEMP:${CSRCDIR}/%=${TEMPOBJECTDIR}/%}
57PFEMBOBJS = ${PFTEMP:${CSRCDIR}/%=${OBJECTDIR}/%}
58
59COMPILE = $(COMPILER) $(CCOPTS) $(CDEFS)
60
61${TEMPOBJECTDIR}/%.o: ${TEMPOBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c
62 $(COMPILE) -O -o ${TEMPOBJECTDIR}/$*.o -c ${CSRCDIR}/$*.c
63
64${OBJECTDIR}/%.o: ${OBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c ${CSRCDIR}/pfdicdat.h
65 $(COMPILE) -O -o ${OBJECTDIR}/$*.o -c ${CSRCDIR}/$*.c $(EMBCCOPTS)
66
67all: $(PFORTHAPP)
68
69pffiles:
70 @echo "ITEMP FILES -----------------"
71 @echo ${PFITEMP}
72 @echo "INCLUDE FILES -----------------"
73 @echo ${PFINCLUDES}
74 @echo "'C' FILES ---------------------"
75 @echo ${PFSOURCE}
76 @echo "OBJECT FILES ------------------"
77 @echo ${PFOBJS}
78 @echo "EMBEDDED OBJECT FILES ------------------"
79 @echo ${PFEMBOBJS}
80
81${TEMPOBJECTDIR}:
82 mkdir -p ${TEMPOBJECTDIR}/posix
83 mkdir -p ${TEMPOBJECTDIR}/stdio
84
85${OBJECTDIR}:
86 mkdir -p ${OBJECTDIR}/posix
87 mkdir -p ${OBJECTDIR}/stdio
88
89# Build pforth by compiling 'C' source.
90$(PFDICAPP): $(PFINCLUDES) $(PFOBJS)
91 $(COMPILER) $(PFOBJS) $(WIDTHOPT) -lm -o $(PFDICAPP)
92
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)
96
97$(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS)
98 $(COMPILER) $(PFEMBOBJS) $(WIDTHOPT) -lm -o $(PFORTHAPP)
99 @echo ""
100 @echo "Standalone pForth executable written to $(PFORTHAPP)"
101
102
103# target aliases
104pfdicapp: $(PFDICAPP)
105
106pfdicdat: $(PFDICDAT)
107
108pforthapp: $(PFORTHAPP)
109
110help:
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."
116 @echo ""
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."
119
120
121clean:
122 rm -f $(PFOBJS) $(PFEMBOBJS)
123 rm -f $(PFORTHAPP)
124 rm -f $(PFDICDAT)
125 rm -f $(PFORTHDIC)
126 rm -f $(PFDICAPP)
127 rm -rf $(OBJECTDIR) $(TEMPOBJECTDIR)
128