]> git.gag.com Git - fw/sdcc/blob - src/port.mk.in
* support/regression/valdiag/tests/switch.c,
[fw/sdcc] / src / port.mk.in
1 # Common Makefile for all ports.
2 # Input: SOURCES - list of C files included in the project
3 #        SPECIAL - list of special files that should be included in dependencies
4 #        PEEPRULES - list of all peephole rules (.rul) derrived files
5 #        PREBUILD - list of special files to build before deps.
6
7 # Ports are always located in sdcc/src/<portname>
8
9 CPPFLAGS += @CPPFLAGS@
10
11 # Output
12 LIB = port.a
13 # Include the sdcc/src directory
14 INCLUDEFLAGS = -I$(srcdir)/.. -I..
15
16 # If the sources aren't specified, assume all in this directory.
17 ifndef SOURCES
18 SOURCES = $(notdir $(wildcard $(srcdir)/*.c))
19 endif
20
21 # If the peephole rules aren't specified, assume all.
22 ifndef PEEPRULES
23 PEEPDEFS = $(notdir $(wildcard $(srcdir)/*.def))
24 PEEPRULES = $(PEEPDEFS:.def=.rul)
25 endif
26
27 PREBUILD += $(PEEPRULES)
28
29 all: $(PREBUILD) dep $(LIB)
30
31 include $(top_builddir)Makefile.common
32
33 $(LIB): $(OBJ)
34         rm -f $(LIB)
35         $(AR) r $(LIB) $(OBJ)
36         $(RANLIB) $(LIB)
37
38 %.rul: %.def
39         $(AWK) -f $(srcdir)/../SDCCpeeph.awk $< > $@
40
41 dep: Makefile.dep
42
43 Makefile.dep: $(PREBUILD) Makefile $(SOURCES) $(SPECIAL)
44         $(CPP) $(CPPFLAGS) $(M_OR_MM) $(filter %.c,$^) >Makefile.dep
45
46 # don't include Makefile.dep for the listed targets:
47 ifeq "$(findstring $(MAKECMDGOALS),clean distclean)" ""
48   include Makefile.dep
49 endif
50
51 include $(srcdir)/../port-clean.mk