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
15 ifeq "$(origin CC)" "default"
24 # libosl's versioning consists of three numbers. Let's call them x, y and z.
25 # The way x, y and z are interpreted depends on the OS.
29 VERSION
:= $(x
).
$(y
).
$(z
)
32 CFLAGS
+= -Wno-sign-compare
-g
-Wunused
-Wundef
-W
33 CFLAGS
+= -Wredundant-decls
36 CFLAGS
+= -Wuninitialized
37 CFLAGS
+= -Wchar-subscripts
38 CFLAGS
+= -Wformat-security
39 CFLAGS
+= -Werror-implicit-function-declaration
40 CFLAGS
+= -Wmissing-format-attribute
41 CFLAGS
+= -Wunused-macros
42 CFLAGS
+= -Wbad-function-cast
44 # cflags used only for building library objects
46 LIBCFLAGS
+= -fvisibility
=hidden
48 uname_s
:= $(shell uname
-s
2>/dev
/null || echo
"UNKNOWN_OS")
52 ifeq ($(uname_s
),Linux
)
54 LDFLAGS
+= -Wl
,-soname
,$(soname
)
55 # disallow undefined symbols
56 LDFLAGS
+= -Wl
,-z
,defs
58 ifeq ($(uname_s
),Darwin
)
59 # Darwin has its own idea on version numbers:
60 realname
:= lib
$(libname
).
$(x
).dylib
62 linkername
:= lib
$(libname
).dylib
63 # The minor version number is an incremental number using the format
64 # X[.Y[.Z]]. To set the minor version number of a dynamic library, use
65 # the gcc -current_version option.
66 LDFLAGS
+= -current_version
$(y
).
$(z
)
68 # The compatibility version number of a library release specifies the
69 # earliest minor version of the clients linked against that release can
71 LDFLAGS
+= -compatibility_version
$(y
).0
72 LDFLAGS
+= -dynamiclib
74 ifeq ($(uname_s
),SunOS
)
76 # Solaris needs another set of flags
79 CPPFLAGS
+= -I
/opt
/csw
/include
83 ifeq ($(uname_s
),NetBSD
)
85 LDFLAGS
+= -Wl
,-soname
,$(soname
)
88 ifeq ($(uname_s
),FreeBSD
)
90 LDFLAGS
+= -Wl
,-soname
,$(soname
)
94 # On ELf-based systems, the following conventions apply (see dhweeler's
95 # Program Library HOWTO):
97 # The soname has the prefix ``lib'', the name of the library, the
98 # phrase ``.so'', followed by a period and a version number that is
99 # incremented whenever the interface changes.
100 soname
:= lib
$(libname
).so.
$(x
)
102 # The real name adds to the soname a period, a minor number, another
103 # period, and the release number.
104 realname
:= $(soname
).
$(y
).
$(z
)
106 # In addition, there's the name that the compiler uses when requesting
107 # a library, (I'll call it the ``linker name''), which is simply the
108 # soname without any version number.
109 linkername
:= lib
$(libname
).so
113 all: $(realname
) $(executables
) $(man_pages
)
116 Makefile.deps
: $(wildcard *.c
*.h
)
117 $(CC
) -MM
-MG
*.c
> $@
120 -include Makefile.deps
122 fsck.cmdline.o
: fsck.cmdline.c fsck.cmdline.h
123 $(CC
) -c
-DVERSION
='"$(VERSION)"' $<
125 %.fsck.o
: %.c Makefile fsck.cmdline.c fsck.cmdline.h osl.h errtab.h
126 $(CC
) -c
-DVERSION
='"$(VERSION)"' $(CPPFLAGS
) $(CFLAGS
) $< -o
$@
128 %.o
: %.c Makefile errtab.h
129 $(CC
) -c
$(CPPFLAGS
) $(CFLAGS
) $(LIBCFLAGS
) $<
131 fsck.cmdline.h fsck.cmdline.c
: fsck.ggo Makefile
134 --unamed-opts
=table \
135 --no-handle-version \
136 --file-name
=fsck.cmdline \
137 --func-name
=fsck_cmdline_parser \
138 --set-package
="oslfsck" \
139 --arg-struct-name
=fsck_args_info \
142 oslfsck
: $(fsck_objects
)
143 $(CC
) -o
$@
$(fsck_objects
)
146 help2man
-h
--detailed-help
-N .
/$< > $@
148 $(realname
): $(objects
)
149 $(CC
) $(LDFLAGS
) -o
$@
$(objects
)
151 $(libname
).sym
: osl.h.in
152 sed
-Ene
'/^int|^const/{s/.*(osl_.*)\(.*/\1/; p;}' $< > $@
153 $(libname
).ga
: $(objects
)
154 $(LD
) -r
-o
$@
$(objects
)
155 lib
$(libname
).a
: $(libname
).ga
$(libname
).sym
156 $(OBJCOPY
) --keep-global-symbols
$(libname
).sym
$(libname
).ga
$@
158 osl_errors.h
: errlist
159 echo
'/** public error codes of the osl library. */' > $@
160 sed
-e
's/\([A-Z_]*\) .*/ E_OSL_\1/' \
161 -e
'1s/^/enum osl_errors {/1' \
164 -e
'$$s/$$/};/1' $< >> $@
167 sed
-e
's/^\([A-Z_]*\)\s*\(.*\)/OSL_ERROR(E_OSL_\1, \2)/g' $< > $@
169 osl.h
: osl.h.in osl_errors.h Makefile
170 echo
'#ifndef _OSL_H' > $@
171 echo
'#define _OSL_H' >> $@
172 cat osl.h.in osl_errors.h
>> $@
173 echo
'#endif /* _OSL_H */' >> $@
175 rm -f
*.o
$(realname
) osl.h osl_errors.h errtab.h fsck.cmdline.h \
176 fsck.cmdline.c oslfsck
*.a
*.ga
*.sym
179 rm -f web
/index.html web
/oslfsck
.1.html web
/osl.png
182 install-bin
: $(executables
)
184 $(INSTALL
) -m
755 $(executables
) $(bindir)
186 install-man
: $(man_pages
)
188 $(INSTALL
) -m
644 $(man_pages
) $(mandir)
190 install-lib
: $(realname
) $(headers
)
191 $(MKDIR
) $(libdir) $(includedir)
192 $(RM
) $(libdir)/$(linkername
)
193 $(LN
) -s
$(libdir)/$(soname
) $(libdir)/$(linkername
)
194 $(INSTALL
) -m
755 $(realname
) $(libdir)
195 $(INSTALL
) -m
644 $(headers
) $(includedir)
197 install: all install-bin install-man install-lib
199 .PHONY
: all shared
clean install install-bin install-man install-lib
204 web
/osl.png
: web
/osl.pdf Makefile
205 convert
-scale
200x200
$< $@
207 web
/index.html
: web
/oslfsck
.1.html web
/index.html.in INSTALL README
208 sed
-e
'/@README@/,$$d' web
/index.html.in
> $@
209 grutatxt
-nb
< README
>> $@
210 sed
-e
'1,/@README@/d' -e
'/@INSTALL@/,$$d' web
/index.html.in
>> $@
211 grutatxt
-nb
< INSTALL
>> $@
212 sed
-e
'1,/@INSTALL@/d' -e
'/@MAN_PAGE@/,$$d' web
/index.html.in
>> $@
213 sed
-e
'1,/Return to Main Contents/d' -e
'/Index/,$$d' web
/oslfsck
.1.html
>> $@
214 sed
-e
'1,/@MAN_PAGE@/d' web
/index.html.in
>> $@