3 libdir := $(prefix)/lib
4 includedir := $(prefix)/include
5 bindir := $(prefix)/bin
6 mandir := $(prefix)/man/man1
8 objects := osl.o util.o rbtree.o sha1.o
9 fsck_objects := fsck.fsck.o osl.fsck.o util.fsck.o rbtree.fsck.o sha1.fsck.o fsck.cmdline.o
11 executables := oslfsck
12 man_pages := oslfsck.1
20 # libosl's versioning consists of three numbers. Let's call them x, y and z.
21 # The way x, y and z are interpreted depends on the OS.
25 VERSION := $(x).$(y).$(z)
28 CFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
29 CFLAGS += -Wredundant-decls
32 CFLAGS += -Wuninitialized
33 CFLAGS += -Wchar-subscripts
34 CFLAGS += -Wformat-security
35 CFLAGS += -Werror-implicit-function-declaration
36 CFLAGS += -Wmissing-format-attribute
37 CFLAGS += -Wunused-macros
38 CFLAGS += -Wbad-function-cast
40 # cflags used only for building library objects
42 LIBCFLAGS += -fvisibility=hidden
44 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
45 uname_rs := $(shell uname -rs)
49 ifeq ($(uname_s),Linux)
51 LDFLAGS += -Wl,-soname,$(soname)
52 # disallow undefined symbols
53 LDFLAGS += -Wl,-z,defs
55 ifeq ($(uname_s),Darwin)
56 # Darwin has its own idea on version numbers:
57 realname := lib$(libname).$(x).dylib
59 linkername := lib$(libname).so
60 # The minor version number is an incremental number using the format
61 # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
62 # the gcc -current_version option.
63 LDFLAGS += -current_version $(y).$(z)
65 # The compatibility version number of a library release specifies the
66 # earliest minor version of the clients linked against that release can
68 LDFLAGS += -compatibility_version $(y).0
69 LDFLAGS += -dynamiclib
71 ifeq ($(uname_s),SunOS)
73 # Solaris needs another set of flags
76 CPPFLAGS += -I/opt/csw/include
80 ifeq ($(uname_s),NetBSD)
82 LDFLAGS += -Wl,-soname,$(soname)
85 ifeq ($(uname_s),FreeBSD)
87 LDFLAGS += -Wl,-soname,$(soname)
91 # On ELf-based systems, the following conventions apply (see dhweeler's
92 # Program Library HOWTO):
94 # The soname has the prefix ``lib'', the name of the library, the
95 # phrase ``.so'', followed by a period and a version number that is
96 # incremented whenever the interface changes.
97 soname := lib$(libname).so.$(x)
99 # The real name adds to the soname a period, a minor number, another
100 # period, and the release number.
101 realname := $(soname).$(y).$(z)
103 # In addition, there's the name that the compiler uses when requesting
104 # a library, (I'll call it the ``linker name''), which is simply the
105 # soname without any version number.
106 linkername := lib$(libname).so
111 all: $(realname) $(executables) $(man_pages)
112 Makefile.deps: $(wildcard *.c *.h)
113 $(CC) -MM -MG *.c > $@
116 -include Makefile.deps
118 fsck.cmdline.o: fsck.cmdline.c fsck.cmdline.h
119 $(CC) -c -DVERSION='"$(VERSION)"' $<
121 %.fsck.o: %.c Makefile fsck.cmdline.c fsck.cmdline.h osl.h errtab.h
122 $(CC) -c -DVERSION='"$(VERSION)"' $(CPPFLAGS) $(CFLAGS) $< -o $@
124 %.o: %.c Makefile errtab.h
125 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(LIBCFLAGS) $<
127 fsck.cmdline.h fsck.cmdline.c: fsck.ggo Makefile
130 --unamed-opts=table \
131 --no-handle-version \
132 --file-name=fsck.cmdline \
133 --func-name=fsck_cmdline_parser \
134 --set-package="oslfsck" \
135 --arg-struct-name=fsck_args_info \
138 oslfsck: $(fsck_objects)
139 $(CC) -o $@ $(fsck_objects) -lcrypto
142 help2man -h --detailed-help -N ./$< > $@
144 $(realname): $(objects)
145 $(CC) $(LDFLAGS) -o $@ $(objects) -lcrypto
147 osl_errors.h: errlist
148 echo '/** public error codes of the osl library. */' > $@
149 sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
150 -e '1s/^/enum osl_errors {/1' \
153 -e '$$s/$$/};/1' $< >> $@
156 sed -e 's/^\([A-Z_]*\)\s*\(.*\)/OSL_ERROR(E_OSL_\1, \2)/g' $< > $@
158 osl.h: osl.h.in osl_errors.h Makefile
159 echo '#ifndef _OSL_H' > $@
160 echo '#define _OSL_H' >> $@
161 cat osl.h.in osl_errors.h >> $@
162 echo '#endif /* _OSL_H */' >> $@
164 rm -f *.o $(realname) osl.h osl_errors.h errtab.h fsck.cmdline.h \
165 fsck.cmdline.c oslfsck
168 rm -f web/index.html web/oslfsck.1.html web/osl.png
172 $(MKDIR) $(libdir) $(includedir)
173 $(RM) $(libdir)/$(linkername)
174 $(LN) -s $(libdir)/$(soname) $(libdir)/$(linkername)
175 $(INSTALL) -s -m 755 $(realname) $(libdir)
176 $(INSTALL) -m 644 $(headers) $(includedir)
177 $(INSTALL) -m 755 $(executables) $(bindir)
178 $(INSTALL) -m 644 $(man_pages) $(mandir)
180 .PHONY: all clean install
185 web/osl.png: web/osl.pdf
188 web/index.html: web/oslfsck.1.html web/index.html.in INSTALL README
189 sed -e '/@README@/,$$d' web/index.html.in > $@
190 grutatxt -nb < README >> $@
191 sed -e '1,/@README@/d' -e '/@INSTALL@/,$$d' web/index.html.in >> $@
192 grutatxt -nb < INSTALL >> $@
193 sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' web/index.html.in >> $@
194 sed -e '1,/Return to Main Contents/d' -e '/Index/,$$d' web/oslfsck.1.html >> $@
195 sed -e '1,/@MAN_PAGE@/d' web/index.html.in >> $@