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")
20 DATE := $(shell date '+%B %Y')
21 GIT_VERSION := $(shell ./version-gen.sh)
23 m4_man_pages := lopsub-suite.5 lopsub.7
24 all := $(m4_man_pages) liblopsub.a lopsubgen lopsubgen.1 \
30 lopsub.o lsg.o: lopsub.h lopsub-internal.h
31 lsg.o: lopsubgen.lsg.h lopsub-internal.h
32 lopsubex.o: lopsubex.lsg.h lopsub.h
33 config_file.c: lopsub-internal.h lopsub.h
37 gendoc := gendoc/gendoc.m4
39 $(M4) -DOUTPUT_MODE=C $(gendoc) $< > $@
40 $(m4_man_pages): %: %.m4 version.c
41 $(M4) -DGIT_VERSION=$(GIT_VERSION) -DDATE="$(DATE)" $< > $@
48 lopsubgen.lsg.c lopsubgen.lsg.h: lopsubgen.suite lopsubgen-stage1 \
50 ./lopsubgen-stage1 < $<
51 %.lsg.c: %.suite lopsubgen
52 ./lopsubgen --gen-c < $<
53 %.lsg.h: %.suite lopsubgen
54 ./lopsubgen --gen-header < $<
55 %.1: %.suite lopsubgen
56 ./lopsubgen --gen-man=$@ --version-string $(GIT_VERSION) < $<
59 lsg1_objs := lopsubgen.o lsg1.o version.o
60 lsg_objs := lopsubgen.o lsg.o lopsubgen.lsg.o lopsub.o version.o
61 liblopsub_objs := config_file.o lopsub.o version.o
62 lopsubex_objs := lopsubex.o lopsubex.lsg.o version.o
64 $(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c
65 lopsubgen.o config_file.o:
66 $(CC) -g -c -o $@ ${@:.o=.c}
68 $(CC) -g -DSTAGE1 -Wall -g -c $< -o $@
70 $(CC) -Wall -I. -g -c -o $@ $<
73 lopsubgen-stage1: $(lsg1_objs)
74 $(CC) -Wall -g $(lsg1_objs) -o $@
75 lopsubgen: $(lsg_objs)
76 $(CC) -Wall -g -o $@ $(lsg_objs)
77 liblopsub.a: $(liblopsub_objs)
79 lopsubex: $(lopsubex_objs) liblopsub.a
80 $(CC) -Wall -g -o $@ $^
83 html := $(addprefix web/, $(addsuffix .html, \
84 index lopsub-api lopsubgen.1 lopsubex.1 $(m4_man_pages)))
85 $(html): $(addprefix web/, $(addsuffix .html, header footer))
89 web/lopsub-api.html: lopsub.h.m4
90 $(M4) -DOUTPUT_MODE=HTML web/header.html $(gendoc) \
91 $< web/footer.html > $@
92 web/index.html: web/lopsub.7.html
93 $(LN) -s $(notdir $<) $@
95 $(CP) web/header.html $@
96 $(GROFF) -m man -Thtml $< | sed -e '1,/^<body>/d' >> $@
98 install: liblopsub.a lopsub.7
99 $(INSTALL) -d $(PREFIX)/lib $(PREFIX)/include $(PREFIX)/man/man1 \
100 $(PREFIX)/man/man5 $(PREFIX)/man/man7 $(PREFIX)/bin
101 $(INSTALL) -m 755 liblopsub.a $(PREFIX)/lib
102 $(INSTALL) -m 755 lopsubgen $(PREFIX)/bin
103 $(INSTALL) -m 644 lopsub.h $(PREFIX)/include
104 $(INSTALL) -m 644 lopsub-internal.h $(PREFIX)/include
105 $(INSTALL) -m 644 lopsubgen.1 $(PREFIX)/man/man1
106 $(INSTALL) -m 644 lopsub-suite.5 $(PREFIX)/man/man5
107 $(INSTALL) -m 644 lopsub.7 $(PREFIX)/man/man7
110 $(RM) $(all) $(html) *.o *.man *.lsg.c *.lsg.h \
111 lopsubgen.c config_file.c lopsubgen-stage1 \
112 lopsub.h lopsub.7 lopsub-suite.5 version.c