]> git.ozlabs.org Git - petitboot/blob - rules.mk
3251b0454607bf2c1505d1b894a07caeb3662c94
[petitboot] / rules.mk
1
2 VPATH = $(srcdir)
3
4 CPPFLAGS += -I$(top_srcdir) -I$(top_srcdir)/lib -I$(builddir)
5 LDFLAGS += $(CFLAGS)
6
7 # we need paths to be overridable at build-time
8 DEFS += '-DPREFIX="$(prefix)"' '-DPKG_SHARE_DIR="$(pkgdatadir)"' \
9         '-DLOCAL_STATE_DIR="$(localstatedir)"'
10
11 # programs
12 pb_discover = discover/pb-discover
13 pb_cui = ui/ncurses/pb-cui
14 pb_test = ui/test/pb-test
15 pb_twin = ui/twin/pb-twin
16 pb_event = utils/pb-event
17 parser_test = test/parser-test
18
19 # install targets and components
20 daemons = $(pb_discover)
21 parsers = event kboot yaboot
22 uis = $(pb_test)
23 tests = $(parser_test)
24 utils = $(pb_event)
25
26 ifeq ($(PBTWIN),y)
27         uis += $(pb_twin)
28 endif
29
30 # other to install
31 artwork = background.jpg cdrom.png hdd.png usbpen.png tux.png cursor.gz
32 rules = utils/99-petitboot.rules
33
34 # client/daemon lib objs
35 list_objs = lib/list/list.o
36 log_objs = lib/log/log.o
37 protocol_objs = lib/pb-protocol/pb-protocol.o
38 system_objs = lib/system/system.o
39 talloc_objs = lib/talloc/talloc.o
40 waiter_objs = lib/waiter/waiter.o
41
42 # daemon objs
43 parser_objs = discover/parser.o discover/parser-conf.o discover/paths.o \
44         $(foreach p, $(parsers), discover/$(p)-parser.o)
45 discover_objs = discover/event.o discover/user-event.o discover/udev.o \
46         discover/discover-server.o discover/device-handler.o discover/paths.o \
47         discover/parser-utils.o
48
49 # client objs
50 ui_common_objs = ui/common/discover-client.o ui/common/loader.o \
51         ui/common/ui-system.o ui/common/url.o
52 ncurses_objs =
53 twin_objs = ui/twin/pb-twin.o
54
55 # Makefiles
56 makefiles = Makefile $(top_srcdir)/rules.mk
57
58 # object collections
59 lib_objs = $(list_objs) $(log_objs) $(protocol_objs) $(system_objs) \
60         $(talloc_objs) $(waiter_objs)
61
62 daemon_objs = $(lib_objs) $(parser_objs) $(discover_objs)
63
64 client_objs = $(lib_objs) $(ui_common_objs)
65
66 all: $(uis) $(daemons) $(utils)
67
68 # ncurses cui
69 pb_cui_objs = $(client_objs) $(ncurses_objs) ui/ncurses/ps3-cui.o \
70         ui/common/ps3.o
71 $(pb_cui_objs): $(makefiles)
72
73 $(pb_cui): LDFLAGS += -lps3-utils -lmenu -lform -lncurses
74
75 $(pb_cui): $(pb_cui_objs)
76         $(LINK.o) -o $@ $^
77
78 # test ui
79 pb_test_objs = $(client_objs) ui/test/pb-test.o
80 $(pb_test_objs): $(makefiles)
81
82 $(pb_test): $(pb_test_objs)
83         $(LINK.o) -o $@ $^
84
85 # twin gui
86 pb_twin_objs = $(client_objs) $(twin_objs) ui/twin/ps3-twin.o
87 $(pb_twin_objs): $(makefiles)
88
89 $(pb_twin): LDFLAGS+=$(twin_LDFLAGS) $(LIBTWIN)
90 $(pb_twin): CFLAGS+=$(twin_CFLAGS)
91
92 $(pb_twin): $(pb_twin_objs)
93         $(LINK.o) -o $@ $^
94
95 # discovery daemon
96 pb_discover_objs = $(daemon_objs) discover/pb-discover.o
97 $(pb_discover_objs): $(makefiles)
98
99 $(pb_discover): $(pb_discover_objs)
100         $(LINK.o) -o $@ $^
101
102 # utils
103 pb_event_objs = utils/pb-event.o
104 $(pb_event_objs): $(makefiles)
105
106 $(pb_event): $(pb_event_objs)
107         $(LINK.o) -o $@ $^
108
109 # parser-test
110 parser_test_objs = $(lib_objs) $(parser_objs) test/parser-test.o
111 $(parser_test_objs): $(makefiles)
112
113 $(parser_test): $(parser_test_objs)
114         $(LINK.o) -o $@ $^
115
116 parser-test: $(parser_test)
117
118 install: all $(rules)
119         $(INSTALL) -d $(DESTDIR)$(sbindir)/
120         $(INSTALL) $(daemons) $(uis) $(utils) $(DESTDIR)$(sbindir)/
121         $(INSTALL) -d $(DESTDIR)$(pkgdatadir)/artwork/
122         $(INSTALL) $(addprefix $(top_srcdir)/ui/twin/artwork/,$(artwork)) \
123                 $(DESTDIR)$(pkgdatadir)/artwork/
124         $(INSTALL) -d $(DESTDIR)$(pkgdatadir)/utils
125         $(INSTALL) -m 644 $(top_srcdir)/$(rules) $(DESTDIR)$(pkgdatadir)/utils
126
127 dist: $(PACKAGE)-$(VERSION).tar.gz
128
129 check: parser-test
130         $(SHELL) test/parser-test.sh
131
132 distcheck: dist
133         tar -xvf $(PACKAGE)-$(VERSION).tar.gz
134         cd $(PACKAGE)-$(VERSION) && make check
135
136 $(PACKAGE)-$(VERSION).tar.gz: $(PACKAGE)-$(VERSION)
137         tar czvf $@ $^
138
139 $(PACKAGE)-$(VERSION): clean
140         for f in $$(git --git-dir=$(top_srcdir)/.git ls-files); do \
141                 d=$@/$$(dirname $$f); \
142                 mkdir -p $$d; \
143                 cp -a $(top_srcdir)/$$f $$d; \
144         done
145
146 clean:
147         rm -rf $(PACKAGE)-$(VERSION)
148         rm -f $(uis)
149         rm -f $(pb_cui_objs)
150         rm -f $(pb_test_objs)
151         rm -f $(pb_twin_objs)
152         rm -f $(daemons)
153         rm -f $(pb_discover_objs)
154         rm -f $(utils)
155         rm -f $(pb_event_objs)
156         rm -f $(tests)
157         rm -f $(parser_test_objs)
158
159 maintainer-clean: clean
160         -rm -f $(top_srcdir)/aclocal.m4
161         -rm -rf $(top_srcdir)/autom4te.cache
162         -rm -f $(top_srcdir)/config.h.in
163         -rm -f $(top_srcdir)/configure
164         -rm -f config.h
165         -rm -f config.log
166         -rm -f config.status
167         -rm -f Makefile
168         -rm -f $(PACKAGE)-$(VERSION).tar.gz