summaryrefslogtreecommitdiff
path: root/src/port.mk
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /src/port.mk
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'src/port.mk')
-rw-r--r--src/port.mk52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/port.mk b/src/port.mk
new file mode 100644
index 0000000..5253e8b
--- /dev/null
+++ b/src/port.mk
@@ -0,0 +1,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