+ifeq ($(format),elf)
+ # 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.
+ 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
+ LDFLAGS += --shared
+endif
+
+all: $(realname) $(executables) $(man_pages)
+shared: $(realname)
+
+ifeq ($(findstring clean, $(MAKECMDGOALS)),)
+-include $(deps)
+endif
+%.o: %.c Makefile errtab.h
+ $(CC) $(CPPFLAGS) -c -MMD -MF $(*F).d -MT $@ $(CFLAGS) $(LIBCFLAGS) $<
+
+fsck.o: oslfsck.lsg.h
+oslfsck: $(fsck_objects)
+ $(CC) -o $@ $(fsck_objects) -llopsub
+
+%.lsg.c: %.suite
+ lopsubgen --gen-c < $<
+
+%.lsg.h: %.suite
+ lopsubgen --gen-header < $<
+
+%.1: %.suite
+ lopsubgen --gen-man=$@ < $<
+
+$(realname): $(objects)
+ $(CC) $(LDFLAGS) -o $@ $(objects)
+
+$(libname).sym: osl.h.in
+ sed -Ene '/^int|^const/{s/.*(osl_.*)\(.*/\1/; p;}' $< > $@
+$(libname).ga: $(objects)
+ $(LD) -r -o $@ $(objects)
+lib$(libname).a: $(libname).ga $(libname).sym
+ $(OBJCOPY) --keep-global-symbols $(libname).sym $(libname).ga $@
+
+osl_errors.h: errlist
+ echo '/** public error codes of the osl library. */' > $@
+ sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
+ -e '1s/^/enum osl_errors {/1' \
+ -e '1s/$$/=1/1' \
+ -e '$$!s/$$/,/g' \
+ -e '$$s/$$/};/1' $< >> $@
+
+errtab.h: errlist
+ sed -e 's/^\([A-Z_]*\)\s*\(.*\)/OSL_ERROR(E_OSL_\1, \2)/g' $< > $@
+
+osl.h: osl.h.in osl_errors.h Makefile
+ echo '#ifndef _OSL_H' > $@
+ echo '#define _OSL_H' >> $@
+ cat osl.h.in osl_errors.h >> $@
+ echo '#endif /* _OSL_H */' >> $@