-ifeq ($(uname_s),FreeBSD)
- dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
- dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
-endif
-ifeq ($(uname_s),NetBSD)
- dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
- dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
+MKDIR := mkdir -p
+RM := rm -f
+LN := ln
+LD := ld
+M4 := m4 -g
+OBJCOPY := objcopy
+
+# libosl's versioning consists of three numbers. Let's call them x, y and z.
+x := 0
+y := 1
+z := 3
+VERSION := $(x).$(y).$(z)
+
+OSL_CPPFLAGS += -DOSL_VERSION='"$(VERSION)"'
+
+OSL_CFLAGS += -g -Wunused -Wundef -W
+OSL_CFLAGS += -Wredundant-decls
+OSL_CFLAGS += -Os
+OSL_CFLAGS += -Wall
+OSL_CFLAGS += -Wuninitialized
+OSL_CFLAGS += -Wchar-subscripts
+OSL_CFLAGS += -Wformat-security
+OSL_CFLAGS += -Werror-implicit-function-declaration
+OSL_CFLAGS += -Wmissing-format-attribute
+OSL_CFLAGS += -Wunused-macros
+OSL_CFLAGS += -Wbad-function-cast
+OSL_CFLAGS += -fPIC
+OSL_CFLAGS += -fvisibility=hidden
+
+OSL_LDFLAGS += -Wl,-soname,$(soname)
+OSL_LDFLAGS += -Wl,-z,defs
+OSL_LDFLAGS += --shared
+
+# On ELf-based systems, the following conventions apply (see dhweeler's
+# Program Library HOWTO):
+#
+# The soname has the prefix ``lib'', the name of the library, the
+# phrase ``.so'', followed by a period and a version number that is
+# incremented whenever the interface changes.
+libname := osl
+soname := lib$(libname).so.$(x)
+
+# The real name adds to the soname a period, a minor number, another
+# period, and the release number.
+realname := $(soname).$(y).$(z)
+
+# In addition, there's the name that the compiler uses when requesting
+# a library, (I'll call it the ``linker name''), which is simply the
+# soname without any version number.
+linkername := lib$(libname).so
+
+all: $(realname) $(executables) $(man_pages) $(headers)
+shared: $(realname)
+
+ifeq ($(findstring clean, $(MAKECMDGOALS)),)
+-include $(deps)