-# Version
-VERSION = @VERSION@
-VERSIONHI = @VERSIONHI@
-VERSIONLO = @VERSIONLO@
-VERSIONP = @VERSIONP@
-
-# Programs
-SHELL = /bin/sh
-CC = @CC@
-CPP = @CPP@
-RANLIB = @RANLIB@
-INSTALL = @INSTALL@
-YACC = @YACC@
-LEX = @LEX@
-AWK = @AWK@
-# Directories
-PRJDIR = ..
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-libdir = @libdir@
-datadir = @datadir@
-includedir = @includedir@
-mandir = @mandir@
-man1dir = $(mandir)/man1
-man2dir = $(mandir)/man2
-infodir = @infodir@
-srcdir = @srcdir@
-
-# Flags
-DEFS = $(subs -DHAVE_CONFIG_H,,@DEFS@)
-CPPFLAGS = @CPPFLAGS@ -I$(PRJDIR) -I$(PRJDIR)/support
-CFLAGS = @CFLAGS@ -Wall
-M_OR_MM = @M_OR_MM@
-LIBS = -lgc @LIBS@
-LIBDIRS = -L$(PRJDIR)/support/gc
-
-OBJECTS = SDCCy.o SDCClex.o SDCCerr.o SDCChasht.o SDCCmain.o \
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+VPATH = @srcdir@
+
+include $(top_builddir)/Makefile.common
+
+USE_ALT_LEX = 0
+
+PORTS = $(shell cat ../ports.build)
+ALLPORTS = $(shell cat ../ports.all)
+PORT_LIBS = $(PORTS:%=%/port.a)
+
+LIBS = -lm @LIBS@
+
+#CFLAGS += -Werror
+CPPFLAGS += -I$(srcdir)
+LDFLAGS = @LDFLAGS@
+
+ifdef SDCC_SUB_VERSION
+CFLAGS += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\"
+endif
+
+SLIBOBJS = NewAlloc.o MySystem.o BuildCmd.o dbuf.o dbuf_string.o findme.o
+
+OBJECTS = SDCCy.o SDCChasht.o SDCCmain.o \