3 libdir := $(prefix)/lib
4 includedir := $(prefix)/include
6 objects := osl.o util.o rbtree.o sha1.o
7 fsck_objects := fsck.fsck.o osl.fsck.o util.fsck.o rbtree.fsck.o sha1.fsck.o fsck.cmdline.o
16 # libosl's versioning consists of three numbers. Let's call them x, y and z.
17 # The way x, y and z are interpreted depends on the OS.
21 VERSION := $(x).$(y).$(z)
24 CFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
25 CFLAGS += -Wredundant-decls
28 CFLAGS += -Wuninitialized
29 CFLAGS += -Wchar-subscripts
30 CFLAGS += -Wformat-security
31 CFLAGS += -Werror-implicit-function-declaration
32 CFLAGS += -Wmissing-format-attribute
33 CFLAGS += -Wunused-macros
34 CFLAGS += -Wbad-function-cast
36 # cflags used only for building library objects
38 LIBCFLAGS += -fvisibility=hidden
40 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
41 uname_rs := $(shell uname -rs)
45 ifeq ($(uname_s),Linux)
47 LDFLAGS += -Wl,-soname,$(soname)
48 # disallow undefined symbols
49 LDFLAGS += -Wl,-z,defs
51 ifeq ($(uname_s),Darwin)
52 # Darwin has its own idea on version numbers:
53 realname := lib$(libname).$(x).dylib
55 linkername := lib$(libname).so
56 # The minor version number is an incremental number using the format
57 # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
58 # the gcc -current_version option.
59 LDFLAGS += -current_version $(y).$(z)
61 # The compatibility version number of a library release specifies the
62 # earliest minor version of the clients linked against that release can
64 LDFLAGS += -compatibility_version $(y).0
65 LDFLAGS += -dynamiclib
67 ifeq ($(uname_s),SunOS)
69 # Solaris needs another set of flags
72 CPPFLAGS += -I/opt/csw/include
76 ifeq ($(uname_s),NetBSD)
78 LDFLAGS += -Wl,-soname,$(soname)
81 ifeq ($(uname_s),FreeBSD)
83 LDFLAGS += -Wl,-soname,$(soname)
87 # On ELf-based systems, the following conventions apply (see dhweeler's
88 # Program Library HOWTO):
90 # The soname has the prefix ``lib'', the name of the library, the
91 # phrase ``.so'', followed by a period and a version number that is
92 # incremented whenever the interface changes.
93 soname := lib$(libname).so.$(x)
95 # The real name adds to the soname a period, a minor number, another
96 # period, and the release number.
97 realname := $(soname).$(y).$(z)
99 # In addition, there's the name that the compiler uses when requesting
100 # a library, (I'll call it the ``linker name''), which is simply the
101 # soname without any version number.
102 linkername := lib$(libname).so
107 all: $(realname) oslfsck
108 Makefile.deps: $(wildcard *.c *.h)
109 $(CC) -MM -MG *.c > $@
112 -include Makefile.deps
114 fsck.cmdline.o: fsck.cmdline.c fsck.cmdline.h
115 $(CC) -c -DVERSION='"$(VERSION)"' $<
117 %.fsck.o: %.c Makefile fsck.cmdline.c fsck.cmdline.h osl.h errtab.h
118 $(CC) -c -DVERSION='"$(VERSION)"' $(CPPFLAGS) $(CFLAGS) $< -o $@
120 %.o: %.c Makefile errtab.h
121 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(LIBCFLAGS) $<
123 fsck.cmdline.h fsck.cmdline.c: fsck.ggo Makefile
126 --unamed-opts=table \
127 --no-handle-version \
128 --file-name=fsck.cmdline \
129 --func-name=fsck_cmdline_parser \
130 --set-package="oslfsck" \
131 --arg-struct-name=fsck_args_info \
134 oslfsck: $(fsck_objects)
135 $(CC) -o $@ $(fsck_objects) -lcrypto
137 $(realname): $(objects)
138 $(CC) $(LDFLAGS) -o $@ $(objects) -lcrypto
140 osl_errors.h: errlist
141 sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
142 -e '1s/^/enum osl_errors {/1' \
145 -e '$$s/$$/};/1' $< > $@
148 sed -e 's/^\([A-Z_]*\)\s*\(.*\)/OSL_ERROR(E_OSL_\1, \2)/g' $< > $@
150 osl.h: osl.h.in osl_errors.h Makefile
151 cat osl.h.in osl_errors.h > $@
153 rm -f *.o $(realname) osl.h osl_errors.h errtab.h fsck.cmdline.h \
154 fsck.cmdline.c oslfsck
157 $(MKDIR) $(libdir) $(includedir)
158 $(RM) $(libdir)/$(linkername)
159 $(LN) -s $(libdir)/$(soname) $(libdir)/$(linkername)
160 $(INSTALL) -s -m 755 $(realname) $(libdir)
161 $(INSTALL) -m 644 $(headers) $(includedir)
163 .PHONY: all clean install