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.o osl.o util.o rbtree.o sha1.o oslfsck.lsg.o
10 deps
:= $(sort $(objects
:.o
=.d
) $(fsck_objects
:.o
=.d
))
12 executables
:= oslfsck
13 man_pages
:= oslfsck
.1
16 ifeq "$(origin CC)" "default"
25 # libosl's versioning consists of three numbers. Let's call them x, y and z.
29 VERSION
:= $(x
).
$(y
).
$(z
)
31 OSL_CPPFLAGS
+= -DOSL_VERSION
='"$(VERSION)"'
33 OSL_CFLAGS
+= -Wno-sign-compare
-g
-Wunused
-Wundef
-W
34 OSL_CFLAGS
+= -Wredundant-decls
37 OSL_CFLAGS
+= -Wuninitialized
38 OSL_CFLAGS
+= -Wchar-subscripts
39 OSL_CFLAGS
+= -Wformat-security
40 OSL_CFLAGS
+= -Werror-implicit-function-declaration
41 OSL_CFLAGS
+= -Wmissing-format-attribute
42 OSL_CFLAGS
+= -Wunused-macros
43 OSL_CFLAGS
+= -Wbad-function-cast
45 OSL_CFLAGS
+= -fvisibility
=hidden
47 OSL_LDFLAGS
+= -Wl
,-soname
,$(soname
)
48 OSL_LDFLAGS
+= -Wl
,-z
,defs
49 OSL_LDFLAGS
+= --shared
51 # On ELf-based systems, the following conventions apply (see dhweeler's
52 # Program Library HOWTO):
54 # The soname has the prefix ``lib'', the name of the library, the
55 # phrase ``.so'', followed by a period and a version number that is
56 # incremented whenever the interface changes.
58 soname
:= lib
$(libname
).so.
$(x
)
60 # The real name adds to the soname a period, a minor number, another
61 # period, and the release number.
62 realname
:= $(soname
).
$(y
).
$(z
)
64 # In addition, there's the name that the compiler uses when requesting
65 # a library, (I'll call it the ``linker name''), which is simply the
66 # soname without any version number.
67 linkername
:= lib
$(libname
).so
69 all: $(realname
) $(executables
) $(man_pages
)
72 ifeq ($(findstring clean, $(MAKECMDGOALS
)),)
75 %.o
: %.c Makefile errtab.h
76 $(CC
) $(OSL_CPPFLAGS
) $(CPPFLAGS
) \
77 -c
-MMD
-MF
$(*F
).d
-MT
$@ \
78 $(OSL_CFLAGS
) $(CFLAGS
) $<
81 oslfsck
: $(fsck_objects
)
82 $(CC
) -o
$@
$(fsck_objects
) -llopsub
85 lopsubgen
--gen-c
< $<
88 lopsubgen
--gen-header
< $<
91 lopsubgen
--gen-man
=$@
< $<
93 $(realname
): $(objects
)
94 $(CC
) $(OSL_LDFLAGS
) $(LDFLAGS
) -o
$@
$(objects
)
96 $(libname
).sym
: osl.h.in
97 sed
-Ene
'/^int|^const/{s/.*(osl_.*)\(.*/\1/; p;}' $< > $@
98 $(libname
).ga
: $(objects
)
99 $(LD
) -r
-o
$@
$(objects
)
100 lib
$(libname
).a
: $(libname
).ga
$(libname
).sym
101 $(OBJCOPY
) --keep-global-symbols
$(libname
).sym
$(libname
).ga
$@
103 osl_errors.h
: errlist
104 echo
'/** public error codes of the osl library. */' > $@
105 sed
-e
's/\([A-Z_]*\) .*/ E_OSL_\1/' \
106 -e
'1s/^/enum osl_errors {/1' \
109 -e
'$$s/$$/};/1' $< >> $@
112 sed
-e
's/^\([A-Z_]*\)\s*\(.*\)/OSL_ERROR(E_OSL_\1, \2)/g' $< > $@
114 osl.h
: osl.h.in osl_errors.h Makefile
115 echo
'#ifndef _OSL_H' > $@
116 echo
'#define _OSL_H' >> $@
117 cat osl.h.in osl_errors.h
>> $@
118 echo
'#endif /* _OSL_H */' >> $@
120 rm -f
*.o
$(realname
) osl.h osl_errors.h errtab.h \
121 oslfsck
*.a
*.ga
*.sym
*.lsg.
* *.d
124 rm -f web
/index.html web
/oslfsck
.1.html web
/osl.png
127 install-bin
: $(executables
)
129 $(INSTALL
) -m
755 $(executables
) $(bindir)
131 install-man
: $(man_pages
)
133 $(INSTALL
) -m
644 $(man_pages
) $(mandir)
135 install-lib
: $(realname
) $(headers
)
136 $(MKDIR
) $(libdir) $(includedir)
137 $(RM
) $(libdir)/$(linkername
)
138 $(LN
) -s
$(soname
) $(libdir)/$(linkername
)
139 $(INSTALL
) -m
755 $(realname
) $(libdir)
140 $(INSTALL
) -m
644 $(headers
) $(includedir)
142 install: all install-bin install-man install-lib
143 www
: web
/index.html web
/osl.png web
/doxygen
/index.html
145 .PHONY
: all shared
clean install install-bin install-man install-lib www
147 web
/osl.png
: web
/osl.pdf Makefile
148 convert
-scale
200x200
$< $@
150 web
/index.html
: oslfsck
.1 web
/index.html.in INSTALL README
151 sed
-e
'/@README@/,$$d' web
/index.html.in
> $@
152 markdown
< README
>> $@
153 sed
-e
'1,/@README@/d' -e
'/@INSTALL@/,$$d' web
/index.html.in
>> $@
154 markdown
< INSTALL
>> $@
155 sed
-e
'1,/@INSTALL@/d' -e
'/@MAN_PAGE@/,$$d' web
/index.html.in
>> $@
156 groff
-m man
-Thtml
-P
-l oslfsck
.1 | sed
-e
'1,/^<body>/d; /^<\/body>/,$$d' >> $@
157 sed
-e
'1,/@MAN_PAGE@/d' web
/index.html.in
>> $@
159 web
/doxygen
/index.html
: $(wildcard *.c
*.h
) web
/Doxyfile web
/header.html \