3 libdir := $(prefix)/lib
4 includedir := $(prefix)/include
6 objects := osl.o fd.o rbtree.o sha1.o
7 fsck_objects := fsck.fsck.o osl.fsck.o fd.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)
44 ifeq ($(uname_s),Linux)
45 # On Linux, the following conventions apply (see dhweeler's Program
48 # The soname has the prefix ``lib'', the name of the library, the
49 # phrase ``.so'', followed by a period and a version number that is
50 # incremented whenever the interface changes.
51 soname := lib$(libname).so.$(x)
53 # The real name adds to the soname a period, a minor number, another
54 # period, and the release number.
55 realname := $(soname).$(y).$(z)
57 # In addition, there's the name that the compiler uses when requesting
58 # a library, (I'll call it the ``linker name''), which is simply the
59 # soname without any version number.
60 linkername := lib$(libname).so
63 LDFLAGS += -Wl,-soname,$(soname)
64 # disallow undefined symbols
65 LDFLAGS += -Wl,-z,defs
67 ifeq ($(uname_s),Darwin)
68 # Darwin has its own idea on version numbers:
70 realname := lib$(libname).$(x).dylib
72 linkername := lib$(libname).so
73 # The minor version number is an incremental number using the format
74 # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
75 # the gcc -current_version option.
76 LDFLAGS += -current_version $(y).$(z)
78 # The compatibility version number of a library release specifies the
79 # earliest minor version of the clients linked against that release can
81 LDFLAGS += -compatibility_version $(y).0
82 LDFLAGS += -dynamiclib
84 ifeq ($(uname_s),SunOS)
85 # Solaris needs another set of flags
89 realname := lib$(libname).so.$(major_version).$(minor_version).$(patchlevel_version)
90 CPPFLAGS += -I/opt/csw/include
93 all: $(realname) oslfsck
94 Makefile.deps: $(wildcard *.c *.h)
95 $(CC) -MM -MG *.c > $@
98 -include Makefile.deps
100 fsck.cmdline.o: fsck.cmdline.c fsck.cmdline.h
101 $(CC) -c -DVERSION='"$(VERSION)"' $<
103 %.fsck.o: %.c Makefile fsck.cmdline.c fsck.cmdline.h
104 $(CC) -c -DVERSION='"$(VERSION)"' $(CPPFLAGS) $(CFLAGS) $< -o $@
107 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(LIBCFLAGS) $<
109 fsck.cmdline.h fsck.cmdline.c: fsck.ggo
112 --unamed-opts=table \
113 --file-name=fsck.cmdline \
114 --func-name=fsck_cmdline_parser \
115 --set-package="oslfsck" \
116 --arg-struct-name=fsck_args_info \
119 oslfsck: $(fsck_objects)
120 $(CC) -o $@ $(fsck_objects) -lcrypto
122 $(realname): $(objects)
123 $(CC) $(LDFLAGS) -o $@ $(objects) -lcrypto
125 osl_errors.h: errlist
126 sed -e 's/\([A-Z_]*\) .*/ E_OSL_\1/' \
127 -e '1s/^/enum osl_errors {/1' \
130 -e '$$s/$$/};/1' $< > $@
133 sed -e 's/^\([A-Z_]*\)\s*\(.*\)/_S(E_OSL_\1, \2)/g' $< > $@
135 osl.h: osl.h.in osl_errors.h Makefile
136 cat osl.h.in osl_errors.h > $@
138 rm -f *.o $(realname) osl.h osl_errors.h errtab.h fsck.cmdline.h fsck.cmdline.c
141 $(MKDIR) $(libdir) $(includedir)
142 $(RM) $(libdir)/$(linkername)
143 $(LN) -s $(libdir)/$(soname) $(libdir)/$(linkername)
144 $(INSTALL) -s -m 755 $(realname) $(libdir)
145 $(INSTALL) -m 644 $(headers) $(includedir)
147 .PHONY: all clean install