view Makefile @ 7:56a7ed833d0a

allow overriding CFLAGS add automatic target dependencies to makefile add install target to Makefile minor makefile fixes
author Guido Berhoerster <guido@berhoerster.name>
date Tue, 11 Oct 2011 17:07:49 +0200
parents 7539e6e1c299
children 58a3312a1c59
line wrap: on
line source

INSTALL :=	install
INSTALL.exec :=	$(INSTALL) -D -m 0755
INSTALL.data :=	$(INSTALL) -D -m 0644
SED :=		sed

DESTDIR ?=
prefix ?=	/usr/local
bindir ?=	$(prefix)/bin
sysconfdir ?=	/etc
xdgautostartdir ?=	$(sysconfdir)/xdg/autostart

PACKAGE =	pk-update-icon
VERSION =	0.1
OBJS =		main.o notify.o packagekit.o
AUTOSTART_FILE =	$(PACKAGE).desktop
CPPFLAGS :=	$(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \
		-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
LDLIBS :=	$(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)

.DEFAULT_TARGET = all

.PHONY: all clean install

all: $(PACKAGE)

$(PACKAGE): $(OBJS)
	$(LINK.o) $^ $(LDLIBS) -o $@

%.o: %.c
	$(COMPILE.c) -MD -o $@ $<
	@cp $*.d $*.P; \
	$(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
	       -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
	rm -f $*.d

install:
	$(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
	$(INSTALL.data) $(AUTOSTART_FILE) \
			$(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)

clean:
	-rm -f $(PACKAGE) $(OBJS)

-include $(patsubst %.o,%.P,$(OBJS))