summaryrefslogtreecommitdiff
path: root/src/port.mk
blob: 5253e8be8d2376a4582e91d79518cbb8e81be504 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Common Makefile for all ports.
# Input: SOURCES - list of C files included in the project
#        SPECIAL - list of special files that should be included in dependencies
#        PEEPRULES - list of all peephole rules (.rul) derrived files
#        PREBUILD - list of special files to build before deps.

# Ports are always located in sdcc/src/<portname>

# Output
LIB = port.a
# Include the sdcc/src directory
INCLUDEFLAGS = -I$(srcdir)/.. -I..

# If the sources aren't specified, assume all in this directory.
ifndef SOURCES
SOURCES = $(sort $(notdir $(wildcard $(srcdir)/*.c)))
endif
ifndef CXXSOURCES
CXXSOURCES = $(sort $(notdir $(wildcard $(srcdir)/*.cc)))
endif

# If the peephole rules aren't specified, assume all.
ifndef PEEPRULES
PEEPDEFS = $(notdir $(wildcard $(srcdir)/*.def))
PEEPRULES = $(PEEPDEFS:.def=.rul)
endif

PREBUILD += $(PEEPRULES)

all: $(PREBUILD) dep $(LIB)

include $(top_builddir)/Makefile.common

$(LIB): $(OBJ)
	rm -f $(LIB)
	$(AR) rc $(LIB) $(OBJ)
	$(RANLIB) $(LIB)

%.rul: %.def
	$(AWK) -f $(srcdir)/../SDCCpeeph.awk $< > $@

dep: Makefile.dep

Makefile.dep: $(PREBUILD) Makefile $(SOURCES) $(CXXSOURCES) $(SPECIAL)
	$(MAKEDEP) $(CPPFLAGS) $(filter %.c %.cc,$^) >Makefile.dep

# don't include Makefile.dep for the listed targets:
ifeq "$(findstring $(MAKECMDGOALS),clean distclean)" ""
  -include Makefile.dep
endif

include $(srcdir)/../port-clean.mk