summaryrefslogtreecommitdiffstats
path: root/rules.mk
blob: 2bc5a30ea5a5f169ea3fcd6134f6edf92e77bb20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

VPATH = $(srcdir)

CPPFLAGS += -I$(top_srcdir) -I$(top_srcdir)/lib -I$(builddir)
LDFLAGS += $(CFLAGS)

# we need paths to be overridable at build-time
DEFS += '-DPREFIX="$(prefix)"' '-DPKG_SHARE_DIR="$(pkgdatadir)"' \
	'-DLOCAL_STATE_DIR="$(localstatedir)"'

# programs
pb_discover = discover/pb-discover
pb_cui = ui/ncurses/pb-cui
pb_test = ui/test/pb-test
pb_twin = ui/twin/pb-twin
pb_event = utils/pb-event
parser_test = test/parser-test

# install targets and components
daemons = $(pb_discover)
parsers = event kboot yaboot
uis = $(pb_cui) $(pb_test)
tests = $(parser_test)
utils = $(pb_event)

ifeq ($(PBTWIN),y)
	uis += $(pb_twin)
endif

# other to install
artwork = background.jpg cdrom.png hdd.png usbpen.png tux.png cursor.gz
rules = utils/99-petitboot.rules
udhcpc = utils/udhcpc

# client/daemon lib objs
list_objs = lib/list/list.o
log_objs = lib/log/log.o
protocol_objs = lib/pb-protocol/pb-protocol.o
system_objs = lib/system/system.o
talloc_objs = lib/talloc/talloc.o
waiter_objs = lib/waiter/waiter.o

# daemon objs
parser_objs = discover/parser.o discover/parser-conf.o discover/paths.o \
	$(foreach p, $(parsers), discover/$(p)-parser.o)
discover_objs = discover/event.o discover/user-event.o discover/udev.o \
	discover/discover-server.o discover/device-handler.o discover/paths.o \
	discover/parser-utils.o

# client objs
ui_common_objs = ui/common/discover-client.o ui/common/loader.o \
	ui/common/ui-system.o ui/common/timer.o ui/common/url.o
ncurses_objs = ui/ncurses/nc-scr.o ui/ncurses/nc-menu.o \
	 ui/ncurses/nc-ked.o ui/ncurses/nc-cui.o
twin_objs = ui/twin/pb-twin.o

# Makefiles
makefiles = Makefile $(top_srcdir)/rules.mk

# object collections
lib_objs = $(list_objs) $(log_objs) $(protocol_objs) $(system_objs) \
	$(talloc_objs) $(waiter_objs)

daemon_objs = $(lib_objs) $(parser_objs) $(discover_objs)

client_objs = $(lib_objs) $(ui_common_objs)

all: $(uis) $(daemons) $(utils)

# ncurses cui
pb_cui_objs-$(ENABLE_PS3) += ui/ncurses/ps3-cui.o ui/common/ps3.o
pb_cui_ldflags-$(ENABLE_PS3) += -lps3-utils

pb_cui_objs = $(client_objs) $(ncurses_objs) $(pb_cui_objs-y)
$(pb_cui_objs): $(makefiles)
$(pb_cui): LDFLAGS += $(pb_cui_ldflags-y) -lmenu -lform -lncurses

$(pb_cui): $(pb_cui_objs)
	$(LINK.o) -o $@ $^

# test ui
pb_test_objs = $(client_objs) ui/test/pb-test.o
$(pb_test_objs): $(makefiles)

$(pb_test): $(pb_test_objs)
	$(LINK.o) -o $@ $^

# twin gui
pb_twin_objs = $(client_objs) $(twin_objs) ui/twin/ps3-twin.o
$(pb_twin_objs): $(makefiles)

$(pb_twin): LDFLAGS+=$(twin_LDFLAGS) $(LIBTWIN)
$(pb_twin): CFLAGS+=$(twin_CFLAGS)

$(pb_twin): $(pb_twin_objs)
	$(LINK.o) -o $@ $^

# discovery daemon
pb_discover_objs = $(daemon_objs) discover/pb-discover.o
$(pb_discover_objs): $(makefiles)

$(pb_discover): $(pb_discover_objs)
	$(LINK.o) -o $@ $^

# utils
pb_event_objs = utils/pb-event.o
$(pb_event_objs): $(makefiles)

$(pb_event): $(pb_event_objs)
	$(LINK.o) -o $@ $^

# parser-test
parser_test_objs = $(lib_objs) $(parser_objs) test/parser-test.o
$(parser_test_objs): $(makefiles)

$(parser_test): $(parser_test_objs)
	$(LINK.o) -o $@ $^

parser-test: $(parser_test)

install: all $(rules) $(udhcpc)
	$(INSTALL) -d $(DESTDIR)$(sbindir)/
	$(INSTALL_PROGRAM) $(daemons) $(uis) $(utils) $(DESTDIR)$(sbindir)/
	$(INSTALL) -d $(DESTDIR)$(pkgdatadir)/artwork/
	$(INSTALL_DATA) $(addprefix $(top_srcdir)/ui/twin/artwork/,$(artwork)) \
		$(DESTDIR)$(pkgdatadir)/artwork/
	$(INSTALL) -d $(DESTDIR)$(pkgdatadir)/utils
	$(INSTALL_DATA) $(top_srcdir)/$(rules) $(DESTDIR)$(pkgdatadir)/utils
	$(INSTALL_DATA) $(top_srcdir)/$(udhcpc) $(DESTDIR)$(pkgdatadir)/utils

dist: $(PACKAGE)-$(VERSION).tar.gz

check: parser-test
	$(SHELL) test/parser-test.sh

distcheck: dist
	tar -xvf $(PACKAGE)-$(VERSION).tar.gz
	cd $(PACKAGE)-$(VERSION) && make check

$(PACKAGE)-$(VERSION).tar.gz: $(PACKAGE)-$(VERSION)
	tar czvf $@ $^

$(PACKAGE)-$(VERSION): clean
	for f in $$(git --git-dir=$(top_srcdir)/.git ls-files); do \
		d=$@/$$(dirname $$f); \
		mkdir -p $$d; \
		cp -a $(top_srcdir)/$$f $$d; \
	done

clean:
	rm -rf $(PACKAGE)-$(VERSION)
	rm -f $(uis)
	rm -f $(pb_cui_objs)
	rm -f $(pb_test_objs)
	rm -f $(pb_twin_objs)
	rm -f $(daemons)
	rm -f $(pb_discover_objs)
	rm -f $(utils)
	rm -f $(pb_event_objs)
	rm -f $(tests)
	rm -f $(parser_test_objs)

maintainer-clean: clean
	-rm -f $(top_srcdir)/aclocal.m4
	-rm -rf $(top_srcdir)/autom4te.cache
	-rm -f $(top_srcdir)/config.h.in
	-rm -f $(top_srcdir)/configure
	-rm -f config.h
	-rm -f config.log
	-rm -f config.status
	-rm -f Makefile
	-rm -f $(PACKAGE)-$(VERSION).tar.gz
OpenPOWER on IntegriCloud