]> git.ozlabs.org Git - petitboot/blobdiff - Makefile
Make petitboot installable
[petitboot] / Makefile
index b0a92ea420074af9c956585e6ebc7aadaebfe7d5..a9ae25c09fb65f187fdc6e5adeb5d1736ad41a3b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,37 @@
+PREFIX?=/usr
 CC=gcc
+INSTALL=install
 TWIN_CFLAGS=$(shell pkg-config --cflags libtwin)
 TWIN_LDFLAGS=$(shell pkg-config --libs libtwin)
 
-LDFLAGS = $(TWIN_LDFLAGS)
-CFLAGS = -O0 -ggdb -Wall $(TWIN_CFLAGS)
+LDFLAGS = 
+CFLAGS = -O0 -ggdb -Wall '-DPREFIX="$(PREFIX)"'
 
-OBJFILES = petitboot.o devices.o
+PARSERS = native
+ARTWORK = background.png cdrom.png hdd.png usbpen.png cursor
 
-petitboot: $(OBJFILES)
+all: petitboot udev-helper
+
+petitboot: petitboot.o devices.o
+       $(CC) $(LDFLAGS) -o $@ $^
+
+petitboot: LDFLAGS+=$(TWIN_LDFLAGS)
+petitboot: CFLAGS+=$(TWIN_CFLAGS)
+
+udev-helper: devices/udev-helper.o devices/params.o \
+               $(foreach p,$(PARSERS),devices/$(p)-parser.o)
        $(CC) $(LDFLAGS) -o $@ $^
 
+devices/%: CFLAGS+=-I.
+
+install: all
+       $(INSTALL) -D petitboot $(PREFIX)/sbin/petitboot
+       $(INSTALL) -D udev-helper $(PREFIX)/sbin/udev-helper
+       $(INSTALL) -Dd $(PREFIX)/share/petitboot/artwork/
+       $(INSTALL) -t $(PREFIX)/share/petitboot/artwork/ \
+               $(foreach a,$(ARTWORK),artwork/$(a))
+
 clean:
        rm -f petitboot
-       rm -f *.o
+       rm -f udev-helper
+       rm -f *.o devices/*.o