bb6b2dcd |
1 | # makefile for pForth |
2 | # Portable Forth written in 'C' |
3 | # by Phil Burk |
4 | # For more info visit http://www.softsynth.com/pforth/ |
970d32b5 |
5 | # |
6 | # See "help" target below. |
90975d26 |
7 | |
bb6b2dcd |
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 | |
bb6b2dcd |
13 | COMPILER = gcc |
14 | |
27f1b5b4 |
15 | PFORTHDIR := $(shell cd ../../; pwd) |
bb6b2dcd |
16 | CSRCDIR = $(PFORTHDIR)/csrc |
17 | FTHDIR = $(PFORTHDIR)/fth |
18 | |
19 | PFDICAPP = $(FTHDIR)/pforth |
20 | PFORTHDIC = $(FTHDIR)/pforth.dic |
21 | PFDICDAT = ${CSRCDIR}/pfdicdat.h |
27f1b5b4 |
22 | PFORTHAPP = $(PFORTHDIR)/pforth_standalone |
bb6b2dcd |
23 | OBJECTDIR = $(PFORTHDIR)/objects |
24 | TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects |
25 | |
970d32b5 |
26 | # This is needed to get pForth to build on Snow Leopard and other 64 bit platforms. |
1cb310e6 |
27 | WIDTHOPT= |
970d32b5 |
28 | |
bb6b2dcd |
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 |
1cb310e6 |
41 | |
970d32b5 |
42 | DEBUGOPTS = -g |
43 | CCOPTS = $(WIDTHOPT) -x c -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS) |
6b91cb54 |
44 | |
45 | IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c |
46 | #IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c |
bb6b2dcd |
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=} |
6b91cb54 |
54 | PFSOURCE = ${wildcard ${CSRCDIR}/*.c} ${IO_SOURCE} |
bb6b2dcd |
55 | PFTEMP = ${PFSOURCE:%.c=%.o} |
56 | PFOBJS = ${PFTEMP:${CSRCDIR}/%=${TEMPOBJECTDIR}/%} |
57 | PFEMBOBJS = ${PFTEMP:${CSRCDIR}/%=${OBJECTDIR}/%} |
58 | |
59 | COMPILE = $(COMPILER) $(CCOPTS) $(CDEFS) |
1cb310e6 |
60 | |
6b91cb54 |
61 | ${TEMPOBJECTDIR}/%.o: ${TEMPOBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c |
bb6b2dcd |
62 | $(COMPILE) -O -o ${TEMPOBJECTDIR}/$*.o -c ${CSRCDIR}/$*.c |
1cb310e6 |
63 | |
64 | ${OBJECTDIR}/%.o: ${OBJECTDIR} $(PFINCLUDES) ${CSRCDIR}/%.c ${CSRCDIR}/pfdicdat.h |
bb6b2dcd |
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} |
1cb310e6 |
80 | |
81 | ${TEMPOBJECTDIR}: |
a741a8b4 |
82 | mkdir -p ${TEMPOBJECTDIR}/posix |
6b91cb54 |
83 | mkdir -p ${TEMPOBJECTDIR}/stdio |
27f1b5b4 |
84 | |
1cb310e6 |
85 | ${OBJECTDIR}: |
923c43d0 |
86 | mkdir -p ${OBJECTDIR}/posix |
6b91cb54 |
87 | mkdir -p ${OBJECTDIR}/stdio |
27f1b5b4 |
88 | |
970d32b5 |
89 | # Build pforth by compiling 'C' source. |
bb6b2dcd |
90 | $(PFDICAPP): $(PFINCLUDES) $(PFOBJS) |
970d32b5 |
91 | $(COMPILER) $(PFOBJS) $(WIDTHOPT) -lm -o $(PFDICAPP) |
bb6b2dcd |
92 | |
970d32b5 |
93 | # Build basic dictionary image by running newly built pforth and including "system.fth". |
bb6b2dcd |
94 | $(PFDICDAT): $(PFDICAPP) |
95 | cd $(FTHDIR); $(PFDICAPP) -i system.fth ; mv pfdicdat.h $(PFDICDAT) |
96 | |
970d32b5 |
97 | $(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS) |
98 | $(COMPILER) $(PFEMBOBJS) $(WIDTHOPT) -lm -o $(PFORTHAPP) |
27f1b5b4 |
99 | @echo "" |
100 | @echo "Standalone pForth executable written to $(PFORTHAPP)" |
1cb310e6 |
101 | |
102 | |
970d32b5 |
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 | |
bb6b2dcd |
121 | clean: |
1cb310e6 |
122 | rm -f $(PFOBJS) $(PFEMBOBJS) |
123 | rm -f $(PFORTHAPP) |
124 | rm -f $(PFDICDAT) |
125 | rm -f $(PFORTHDIC) |
126 | rm -f $(PFDICAPP) |
90975d26 |
127 | rm -rf $(OBJECTDIR) $(TEMPOBJECTDIR) |
128 | |