Use DESTDIR for make install
[petitboot] / Makefile
1 PREFIX?=/usr
2 VERSION=0.0.1
3 PACKAGE=petitboot
4 CC=gcc
5 INSTALL=install
6 TWIN_CFLAGS=$(shell pkg-config --cflags libtwin)
7 TWIN_LDFLAGS=$(shell pkg-config --libs libtwin)
8
9 LDFLAGS = 
10 CFLAGS = -O0 -ggdb -Wall '-DPREFIX="$(PREFIX)"'
11
12 PARSERS = native yaboot
13 ARTWORK = background.png cdrom.png hdd.png usbpen.png cursor
14
15 all: petitboot udev-helper
16
17 petitboot: petitboot.o devices.o
18         $(CC) $(LDFLAGS) -o $@ $^
19
20 petitboot: LDFLAGS+=$(TWIN_LDFLAGS)
21 petitboot: CFLAGS+=$(TWIN_CFLAGS)
22
23 udev-helper: devices/udev-helper.o devices/params.o devices/yaboot-cfg.o \
24                 $(foreach p,$(PARSERS),devices/$(p)-parser.o)
25         $(CC) $(LDFLAGS) -o $@ $^
26
27 devices/%: CFLAGS+=-I.
28
29 install: all
30         $(INSTALL) -D petitboot $(DESTDIR)$(PREFIX)/sbin/petitboot
31         $(INSTALL) -D udev-helper $(DESTDIR)$(PREFIX)/sbin/udev-helper
32         $(INSTALL) -Dd $(DESTDIR)$(PREFIX)/share/petitboot/artwork/
33         $(INSTALL) -t $(DESTDIR)$(PREFIX)/share/petitboot/artwork/ \
34                 $(foreach a,$(ARTWORK),artwork/$(a))
35
36 dist:   $(PACKAGE)-$(VERSION).tar.gz
37
38 $(PACKAGE)-$(VERSION).tar.gz: $(PACKAGE)-$(VERSION)
39         tar czvf $@ $^
40
41 $(PACKAGE)-$(VERSION): clean
42         mkdir $@ $@/devices
43         cp -a artwork $@
44         cp *.[ch] $@
45         cp -a devices/*.[ch] $@/devices/
46         cp Makefile $@
47
48 clean:
49         rm -f petitboot
50         rm -f udev-helper
51         rm -f *.o devices/*.o