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