3 libdir := $(prefix)/lib
4 includedir := $(prefix)/include
6 objects := osl.o fd.o rbtree.o sha1.o
15 # libosl's versioning consists of three numbers. Let's call them x, y and z.
16 # The way x, y and z are interpreted depends on the OS.
22 CFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
23 CFLAGS += -Wredundant-decls
26 CFLAGS += -Wuninitialized
27 CFLAGS += -Wchar-subscripts
28 CFLAGS += -Wformat-security
29 CFLAGS += -Werror-implicit-function-declaration
30 CFLAGS += -Wmissing-format-attribute
31 CFLAGS += -Wunused-macros
32 CFLAGS += -Wbad-function-cast
34 CFLAGS += -fvisibility=hidden
36 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
37 uname_rs := $(shell uname -rs)
40 ifeq ($(uname_s),Linux)
41 # On Linux, the following conventions apply (see dhweeler's Program
44 # The soname has the prefix ``lib'', the name of the library, the
45 # phrase ``.so'', followed by a period and a version number that is
46 # incremented whenever the interface changes.
47 soname := lib$(libname).so.$(x)
49 # The real name adds to the soname a period, a minor number, another
50 # period, and the release number.
51 realname := $(soname).$(y).$(z)
53 # In addition, there's the name that the compiler uses when requesting
54 # a library, (I'll call it the ``linker name''), which is simply the
55 # soname without any version number.
56 linkername := lib$(libname).so
59 LDFLAGS += -Wl,-soname,$(soname)
60 # disallow undefined symbols
61 LDFLAGS += -Wl,-z,defs
63 ifeq ($(uname_s),Darwin)
64 # Darwin has its own idea on version numbers:
66 realname := lib$(libname).$(x).dylib
68 linkername := lib$(libname).so
69 # The minor version number is an incremental number using the format
70 # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
71 # the gcc -current_version option.
72 LDFLAGS += -current_version $(y).$(z)
74 # The compatibility version number of a library release specifies the
75 # earliest minor version of the clients linked against that release can
77 LDFLAGS += -compatibility_version $(y).0
78 LDFLAGS += -dynamiclib
80 ifeq ($(uname_s),SunOS)
81 # Solaris needs another set of flags
85 realname := lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
86 CPPFLAGS += -I/opt/csw/include
91 Makefile.deps: $(wildcard *.c *.h)
92 $(CC) -MM -MG *.c > $@
94 -include Makefile.deps
97 $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
99 $(realname): $(objects)
100 $(CC) $(LDFLAGS) -o $@ $(objects) $(LDFLAGS) -lcrypto
102 osl_errors.h: errlist
103 sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
104 -e '1s/^/enum osl_errors {\n/1' \
106 -e '$$s/$$/\n};/1' $< > $@
109 sed -e 's/^\([A-Z_]*\)\s*\(.*\)/_S(E_OSL_\1, \2)/g' $< > $@
111 osl.h: osl.h.in osl_errors.h
114 rm -f *.o $(realname) osl.h osl_errors.h errtab.h
117 $(MKDIR) $(libdir) $(includedir)
118 $(RM) $(libdir)/$(linkername)
119 $(LN) -s $(libdir)/$(soname) $(libdir)/$(linkername)
120 $(INSTALL) -s -m 755 $(realname) $(libdir)
121 $(INSTALL) -m 644 $(headers) $(includedir)
123 .PHONY: all clean install