]> git.tuebingen.mpg.de Git - osl.git/blobdiff - Makefile
Fix target osl_errors.h on MacOS.
[osl.git] / Makefile
index e79390c4ddad37f9d93c624f84c2ecc1984e98c3..b5d4b169a4833bb4ad3470d1319f0d2e4836a081 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
 uname_rs := $(shell uname -rs)
 
-objects := osl.o fd.o rbtree.o string.o sha1.o
+objects := osl.o fd.o rbtree.o sha1.o
 major_version := 0
 minor_version := 1
 patchlevel_version := 0
@@ -11,12 +11,22 @@ libname := osl
 ifeq ($(uname_s),Linux)
        dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
        dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
+       # disallow undefined symbols
+       LDFLAGS += -Wl,-z,defs
 endif
 ifeq ($(uname_s),Darwin)
-       mac_major_version := $(shell expr 41 + $(major_version))
-       dso_opts := -dynamiclib -current_version $(major_version).$(minor_version) \
-               -compatibility_version $(major_version).$(minor_version) -fvisibility=hidden
-       dso_filename := lib$(libname).$(shell printf "\\x"$(mac_major_version).dylib)
+       # Darwin has its own idea on version numbers:
+       #
+       # The minor version number is an incremental number using the format
+       # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
+       # the gcc -current_version option.
+       #
+       # The compatibility version number of a library release specifies the
+       # earliest minor version of the clients linked against that release can
+       # use.
+       dso_opts := -dynamiclib -current_version $(minor_version).$(patchlevel_version) \
+               -compatibility_version $(minor_version).0 -fvisibility=hidden
+       dso_filename := lib$(libname).$(major_version).dylib
 endif
 ifeq ($(uname_s),SunOS)
        dso_opts := --shared -z text -z defs
@@ -35,9 +45,9 @@ all: $(dso_filename)
 
 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
 DEBUG_CPPFLAGS += -Wredundant-decls
-#CPPFLAGS += -Os
+CPPFLAGS += -Os
 CPPFLAGS += -Wall
-#CPPFLAGS += -Wuninitialized
+CPPFLAGS += -Wuninitialized
 CPPFLAGS += -Wchar-subscripts
 CPPFLAGS += -Wformat-security
 CPPFLAGS += -Werror-implicit-function-declaration
@@ -45,6 +55,7 @@ CPPFLAGS += -Wmissing-format-attribute
 CPPFLAGS += -Wunused-macros
 CPPFLAGS += -Wbad-function-cast
 CPPFLAGS += -fPIC
+CPPFLAGS += -fvisibility=hidden
 
 Makefile.deps: $(wildcard *.c *.h)
        gcc -MM -MG *.c > $@
@@ -54,7 +65,17 @@ Makefile.deps: $(wildcard *.c *.h)
 %.o: %.c Makefile
        $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
 $(dso_filename): $(objects)
-       $(CC) $(dso_opts) -o $@ $(objects) -lcrypto
+       $(CC) $(dso_opts) -o $@ $(objects) $(LDFLAGS) -lcrypto
 
+osl_errors.h: errlist
+       sed -e 's/\([A-Z_]*\)   .*/     E_OSL_\1/' \
+               -e '1s/^/enum osl_errors {/1' \
+               -e '$$!s/$$/,/g' \
+               -e '$$s/$$/};/1' $< > $@
+
+errtab.h: errlist
+       sed -e 's/^\([A-Z_]*\)\s*\(.*\)/_S(E_OSL_\1, \2)/g' $< > $@
+osl.h: osl.h.in osl_errors.h
+       cat $^ > $@
 clean:
-       rm -f *.o $(dso_filename)
+       rm -f *.o $(dso_filename) osl.h osl_errors.h errtab.h