7204f88f535053b622048fbb1a0a2b0d80889674
[osl.git] / Makefile
1 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
2 uname_rs := $(shell uname -rs)
3
4 objects := osl.o fd.o rbtree.o sha1.o
5 major_version := 0
6 minor_version := 1
7 patchlevel_version := 0
8 libname := osl
9
10
11 ifeq ($(uname_s),Linux)
12 dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
13 dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
14 endif
15 ifeq ($(uname_s),Darwin)
16 dso_opts := -dynamiclib -current_version $(major_version).$(minor_version) \
17 -compatibility_version $(major_version).$(minor_version) -fvisibility=hidden
18 dso_filename := lib$(libname).$(major_version)
19 endif
20 ifeq ($(uname_s),SunOS)
21 dso_opts := --shared -z text -z defs
22 dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
23 CPPFLAGS += -I/opt/csw/include
24 endif
25 ifeq ($(uname_s),FreeBSD)
26 dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
27 dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
28 endif
29 ifeq ($(uname_s),NetBSD)
30 dso_opts := --shared -Wl,-soname,libosl.so.$(major_version)
31 dso_filename :=lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
32 endif
33 all: $(dso_filename)
34
35 # disallow undefined symbols
36 LDFLAGS += -Wl,-z,defs
37
38 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
39 DEBUG_CPPFLAGS += -Wredundant-decls
40 CPPFLAGS += -Os
41 CPPFLAGS += -Wall
42 CPPFLAGS += -Wuninitialized
43 CPPFLAGS += -Wchar-subscripts
44 CPPFLAGS += -Wformat-security
45 CPPFLAGS += -Werror-implicit-function-declaration
46 CPPFLAGS += -Wmissing-format-attribute
47 CPPFLAGS += -Wunused-macros
48 CPPFLAGS += -Wbad-function-cast
49 CPPFLAGS += -fPIC
50 CPPFLAGS += -fvisibility=hidden
51
52 Makefile.deps: $(wildcard *.c *.h)
53 gcc -MM -MG *.c > $@
54
55 -include Makefile.deps
56
57 %.o: %.c Makefile
58 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
59 $(dso_filename): $(objects)
60 $(CC) $(dso_opts) -o $@ $(objects) $(LDFLAGS) -lcrypto
61
62 osl_errors.h: errlist
63 sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
64 -e '1s/^/enum osl_errors {\n/1' \
65 -e '$$!s/$$/,/g' \
66 -e '$$s/$$/\n};/1' $< > $@
67
68 errtab.h: errlist
69 sed -e 's/^\([A-Z_]*\)\s*\(.*\)/_S(E_OSL_\1, \2)/g' $< > $@
70 osl.h: osl.h.in osl_errors.h
71 cat $^ > $@
72 clean:
73 rm -f *.o $(dso_filename) osl.h osl_errors.h errtab.h