V25 with 64-bit support
[debian/pforth] / build / unix / Makefile
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 \r
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
13 COMPILER = gcc
14
15 PFORTHDIR   := $(shell cd ../../; pwd)
16 CSRCDIR      = $(PFORTHDIR)/csrc
17 FTHDIR       = $(PFORTHDIR)/fth
18
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
25
26 # This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
27 WIDTHOPT=
28
29 FULL_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
42 DEBUGOPTS = -g
43 CCOPTS = $(WIDTHOPT) -x c -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS)
44
45 IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c
46 #IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
47
48 EMBCCOPTS = -DPF_STATIC_DIC
49
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}/%}
58
59 COMPILE = $(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
67 all: $(PFORTHAPP)
68
69 pffiles:
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
104 pfdicapp: $(PFDICAPP)
105
106 pfdicdat: $(PFDICDAT)
107
108 pforthapp: $(PFORTHAPP)
109
110 help:
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
121 clean:
122         rm -f $(PFOBJS) $(PFEMBOBJS)
123         rm -f $(PFORTHAPP)
124         rm -f $(PFDICDAT)
125         rm -f $(PFORTHDIC)
126         rm -f $(PFDICAPP)