]> git.sur5r.net Git - cc65/blob - src/ld65/make/gcc.mak
Create the .inc files before creating the dependency file, so we avoid
[cc65] / src / ld65 / make / gcc.mak
1 #
2 # gcc Makefile for ld65
3 #
4
5 # ------------------------------------------------------------------------------
6
7 # The executable to build
8 EXE     = ld65
9
10 # Library dir
11 COMMON  = ../common
12
13 # Several search paths. You may redefine these on the command line
14 LD65_LIB = \"/usr/lib/cc65/lib/\"
15 LD65_OBJ = \"/usr/lib/cc65/lib/\"
16 LD65_CFG = \"/usr/lib/cc65/cfg/\"
17
18 #
19 CC      = gcc
20 CFLAGS  = -g -O2 -Wall -W -std=c89
21 CFLAGS += -I$(COMMON)
22 CFLAGS += -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
23 EBIND   = emxbind
24 LDFLAGS =
25
26 # Perl script for config file conversion
27 CVT=cfg/cvt-cfg.pl
28
29 # -----------------------------------------------------------------------------
30 # List of all object files
31
32 OBJS =  asserts.o       \
33         bin.o           \
34         binfmt.o        \
35         cfgexpr.o       \
36         condes.o        \
37         config.o        \
38         dbgfile.o       \
39         dbginfo.o       \
40         dbgsyms.o       \
41         error.o         \
42         exports.o       \
43         expr.o          \
44         extsyms.o       \
45         fileinfo.o      \
46         fileio.o        \
47         filepath.o      \
48         fragment.o      \
49         global.o        \
50         library.o       \
51         lineinfo.o      \
52         main.o          \
53         mapfile.o       \
54         o65.o           \
55         objdata.o       \
56         objfile.o       \
57         scanner.o       \
58         segments.o      \
59         spool.o         \
60         tgtcfg.o
61
62 # -----------------------------------------------------------------------------
63 # List of all config includes
64
65 INCS =  apple2.inc      \
66         apple2enh.inc   \
67         atari.inc       \
68         atmos.inc       \
69         bbc.inc         \
70         c128.inc        \
71         c16.inc         \
72         c64.inc         \
73         cbm510.inc      \
74         cbm610.inc      \
75         geos.inc        \
76         lunix.inc       \
77         lynx.inc        \
78         module.inc      \
79         nes.inc         \
80         none.inc        \
81         pet.inc         \
82         plus4.inc       \
83         supervision.inc \
84         vic20.inc
85
86 LIBS = $(COMMON)/common.a
87
88
89 # ------------------------------------------------------------------------------
90 # Makefile targets
91
92 # Main target - must be first
93 .PHONY: all
94 ifeq (.depend,$(wildcard .depend))
95 all:    $(EXE)
96 include .depend
97 else
98 all:    depend
99         @$(MAKE) -f make/gcc.mak all
100 endif
101
102 $(EXE): $(INCS) $(OBJS) $(LIBS)
103         $(CC) $(OBJS) $(LIBS) $(LDFLAGS) -o $@
104         @if [ $(OS2_SHELL) ] ;  then $(EBIND) $(EXE) ; fi
105
106 inc:    $(INCS)
107
108 clean:
109         $(RM) *~ core.* *.map
110
111 zap:    clean
112         $(RM) *.o $(INCS) $(EXE) .depend
113
114 # ------------------------------------------------------------------------------
115 # Make the dependencies
116
117 .PHONY: depend dep
118 depend dep:     $(INCS) $(OBJS:.o=.c)
119         @echo "Creating dependency information"
120         $(CC) $(CFLAGS) -MM $(OBJS:.o=.c) > .depend
121
122 # -----------------------------------------------------------------------------
123 # Rules to make config includes
124
125 apple2.inc:     cfg/apple2.cfg
126         @$(CVT) $< $@ CfgApple2
127
128 apple2enh.inc:  cfg/apple2enh.cfg
129         @$(CVT) $< $@ CfgApple2Enh
130
131 atari.inc:      cfg/atari.cfg
132         @$(CVT) $< $@ CfgAtari
133
134 atmos.inc:      cfg/atmos.cfg
135         @$(CVT) $< $@ CfgAtmos
136
137 bbc.inc:        cfg/bbc.cfg
138         @$(CVT) $< $@ CfgBBC
139
140 c16.inc:        cfg/c16.cfg
141         @$(CVT) $< $@ CfgC16
142
143 c64.inc:        cfg/c64.cfg
144         @$(CVT) $< $@ CfgC64
145
146 c128.inc:       cfg/c128.cfg
147         @$(CVT) $< $@ CfgC128
148
149 cbm510.inc:     cfg/cbm510.cfg
150         @$(CVT) $< $@ CfgCBM510
151
152 cbm610.inc:     cfg/cbm610.cfg
153         @$(CVT) $< $@ CfgCBM610
154
155 geos.inc:       cfg/geos.cfg
156         @$(CVT) $< $@ CfgGeos
157
158 lunix.inc:      cfg/lunix.cfg
159         @$(CVT) $< $@ CfgLunix
160
161 lynx.inc:       cfg/lynx.cfg
162         @$(CVT) $< $@ CfgLynx
163
164 module.inc:     cfg/module.cfg
165         @$(CVT) $< $@ CfgModule
166
167 nes.inc:        cfg/nes.cfg
168         @$(CVT) $< $@ CfgNES
169
170 none.inc:       cfg/none.cfg
171         @$(CVT) $< $@ CfgNone
172
173 pet.inc:        cfg/pet.cfg
174         @$(CVT) $< $@ CfgPET
175
176 plus4.inc:      cfg/plus4.cfg
177         @$(CVT) $< $@ CfgPlus4
178
179 supervision.inc:        cfg/supervision.cfg
180         @$(CVT) $< $@ CfgSupervision
181
182 vic20.inc:      cfg/vic20.cfg
183         @$(CVT) $< $@ CfgVic20
184
185