1 # Implicit rules are implemented in make as suffix rules. The following rule
2 # empties the suffix list to disable the predefined implicit rules. This
3 # increases performance and avoids hard-to-debug behaviour.
6 ifeq ("$(origin CC)", "default")
12 # Recipes which redirect stdout to the target of the rule (i.e., constructs
13 # like cmd > $@) create empty or incomplete output files if the command fails,
14 # for example when cmd was not found. Since the target exists and is uptodate
15 # in this case, this may lead to all sorts of problems. The following target
16 # makes sure that such files are removed.
31 dummy
!= $(M4
) /dev
/null || printf
'failed'
32 ifeq ($(dummy
), failed
)
33 $(error m4 is required to build this package
)
35 dummy
!= printf
'%%%%\n' |
$(LEX
) -o
/dev
/null || printf
'failed'
36 ifeq ($(dummy
), failed
)
37 $(error
(f
)lex is required to build this package
)
41 # To get a reproducible build, we use $(SOURCE_DATE_EPOCH) instead of the
42 # current time if this variable is set.
43 ifdef SOURCE_DATE_EPOCH
44 DATE
:= $(shell LC_ALL
=C date
-u
-d
'@$(SOURCE_DATE_EPOCH)' \
45 '$(DATE_FMT)' 2>/dev
/null || LC_ALL
=C date
-u
'$(DATE_FMT)')
47 DATE
:= $(shell date
'$(DATE_FMT)')
49 GIT_VERSION
:= $(shell .
/version-gen.sh
)
50 PLAIN_VERSION
:= $(firstword $(subst -, , $(GIT_VERSION
)))
51 MAJOR_VERSION
:= $(firstword $(subst .
, , $(PLAIN_VERSION
)))
52 SONAME
:= liblopsub.so.
$(MAJOR_VERSION
)
53 REALNAME
:= liblopsub.so.
$(PLAIN_VERSION
)
54 LINKERNAME
:=liblopsub.so
56 m4_man_pages
:= lopsub-suite
.5.gz lopsub
.7.gz
57 all := $(m4_man_pages
) $(REALNAME
) lopsubgen lopsubgen
.1.gz \
58 lopsubex lopsubex
.1.gz
63 lopsub.o lsg.o
: lopsub.h lopsub-internal.h
64 lsg.o
: lopsubgen.lsg.h lopsub-internal.h
65 lopsubex.o
: lopsubex.lsg.h lopsub.h
66 config_file.c
: lopsub-internal.h lopsub.h
70 gendoc
:= gendoc
/gendoc.m4
72 $(M4
) -DOUTPUT_MODE
=C
$(gendoc
) $< > $@
73 $(m4_man_pages
): %.gz
: %.m4 version.c
74 $(M4
) -DGIT_VERSION
=$(GIT_VERSION
) -DDATE
="$(DATE)" $< |
$(GZIP
) > $@
81 lopsubgen.lsg.c lopsubgen.lsg.h
: lopsubgen.suite lopsubgen-stage1 \
83 .
/lopsubgen-stage1
< $<
84 %.lsg.c
: %.suite lopsubgen
85 .
/lopsubgen
--gen-c
< $<
86 %.lsg.h
: %.suite lopsubgen
87 .
/lopsubgen
--gen-header
< $<
88 %.1.gz
: %.suite lopsubgen
89 .
/lopsubgen
--gen-man
=${@
:.gz
=} --version-string
$(GIT_VERSION
) < $<
93 lsg1_objs
:= lopsubgen.o lsg1.o version.o
94 lsg_objs
:= lopsubgen.o lsg.o lopsubgen.lsg.o lopsub.o version.o
95 liblopsub_objs
:= config_file.o lopsub.o version.o
96 lopsubex_objs
:= lopsubex.o lopsubex.lsg.o
$(liblopsub_objs
)
98 LLS_CFLAGS
:= -g
-fPIC
99 STRICT_CFLAGS
:= -Wall
100 STRICT_CFLAGS
+= -Werror-implicit-function-declaration
102 $(lsg_objs
) $(liblopsub_objs
) $(lopsubex_objs
): %.o
: %.c
103 lopsubgen.o config_file.o
:
104 $(CC
) $(CPPFLAGS
) $(LLS_CFLAGS
) $(CFLAGS
) -c
-o
$@
${@
:.o
=.c
}
106 $(CC
) $(CPPFLAGS
) $(LLS_CFLAGS
) $(STRICT_CFLAGS
) $(CFLAGS
) -DSTAGE1
-c
-o
$@
$<
108 $(CC
) -I.
$(CPPFLAGS
) $(LLS_CFLAGS
) $(STRICT_CFLAGS
) $(CFLAGS
) -c
-o
$@
$<
111 lopsubgen-stage1
: $(lsg1_objs
)
112 $(CC
) -Wall
-g
$(lsg1_objs
) -o
$@
113 lopsubgen
: $(lsg_objs
)
114 $(CC
) -Wall
-g
-o
$@
$(lsg_objs
)
115 $(REALNAME
): $(liblopsub_objs
)
116 $(CC
) --shared
-Wl
,-soname
,liblopsub.so.
$(MAJOR_VERSION
) -o
$@
$^
117 lopsubex
: $(lopsubex_objs
) $(REALNAME
)
118 $(CC
) -Wall
-g
-o
$@
$(lopsubex_objs
)
121 html
:= $(addprefix web
/, $(addsuffix .html
, \
122 index lopsub-api lopsubgen
.1 lopsubex
.1 $(m4_man_pages
:.gz
=)))
124 web
/lopsub-api.html
: lopsub.h.m4 web
/header.html web
/footer.html
125 $(M4
) -DOUTPUT_MODE
=HTML web
/header.html
$(gendoc
) \
126 $< web
/footer.html
> $@
127 web
/index.html
: web
/lopsub
.7.html
128 $(LN
) -s
$(notdir $<) $@
129 web
/%.html
: %.gz web
/header.html
130 $(CP
) web
/header.html
$@
131 $(ZCAT
) $< |
$(GROFF
) -m man
-Thtml | sed
-e
'1,/^<body>/d' >> $@
134 $(INSTALL
) -d
$(DESTDIR
)$(PREFIX
)/lib
$(DESTDIR
)$(PREFIX
)/include \
135 $(DESTDIR
)$(PREFIX
)/share
/man
/man1
$(DESTDIR
)$(PREFIX
)/share
/man
/man5 \
136 $(DESTDIR
)$(PREFIX
)/share
/man
/man7
$(DESTDIR
)$(PREFIX
)/bin
137 $(INSTALL
) -m
644 $(REALNAME
) $(DESTDIR
)$(PREFIX
)/lib
138 $(LN
) -s
$(REALNAME
) $(DESTDIR
)$(PREFIX
)/lib
/$(SONAME
)
139 $(LN
) -s
$(SONAME
) $(DESTDIR
)$(PREFIX
)/lib
/$(LINKERNAME
)
140 $(INSTALL
) -m
755 lopsubgen
$(DESTDIR
)$(PREFIX
)/bin
141 $(INSTALL
) -m
644 lopsub.h
$(DESTDIR
)$(PREFIX
)/include
142 $(INSTALL
) -m
644 lopsub-internal.h
$(DESTDIR
)$(PREFIX
)/include
143 $(INSTALL
) -m
644 lopsubgen
.1.gz
$(DESTDIR
)$(PREFIX
)/share
/man
/man1
144 $(INSTALL
) -m
644 lopsub-suite
.5.gz
$(DESTDIR
)$(PREFIX
)/share
/man
/man5
145 $(INSTALL
) -m
644 lopsub
.7.gz
$(DESTDIR
)$(PREFIX
)/share
/man
/man7
148 $(RM
) $(all) $(html
) *.o
*.man
150 $(RM
) *.lsg.c
*.lsg.h lopsubgen.c config_file.c lopsubgen-stage1 \
151 lopsub.h lopsub
.7 lopsub-suite
.5 version.c