projects/pk-update-icon

changeset 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 Oct 11 17:07:49 2011 +0200 (2011-10-11)
parents 7539e6e1c299
children 58a3312a1c59
files Makefile
line diff
     1.1 --- a/Makefile	Thu Oct 06 16:02:19 2011 +0200
     1.2 +++ b/Makefile	Tue Oct 11 17:07:49 2011 +0200
     1.3 @@ -1,16 +1,44 @@
     1.4 -CC=gcc
     1.5 -OBJS=main.o notify.o packagekit.o
     1.6 -CFLAGS=$(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) -Wall -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
     1.7 -LDFLAGS=$(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)
     1.8 -NAME=pk-update-icon
     1.9 +INSTALL :=	install
    1.10 +INSTALL.exec :=	$(INSTALL) -D -m 0755
    1.11 +INSTALL.data :=	$(INSTALL) -D -m 0644
    1.12 +SED :=		sed
    1.13  
    1.14 -all: $(NAME)
    1.15 +DESTDIR ?=
    1.16 +prefix ?=	/usr/local
    1.17 +bindir ?=	$(prefix)/bin
    1.18 +sysconfdir ?=	/etc
    1.19 +xdgautostartdir ?=	$(sysconfdir)/xdg/autostart
    1.20  
    1.21 -$(NAME): $(OBJS)
    1.22 -	$(CC) $(OBJS) $(LDFLAGS) -o $(NAME)
    1.23 +PACKAGE =	pk-update-icon
    1.24 +VERSION =	0.1
    1.25 +OBJS =		main.o notify.o packagekit.o
    1.26 +AUTOSTART_FILE =	$(PACKAGE).desktop
    1.27 +CPPFLAGS :=	$(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \
    1.28 +		-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
    1.29 +LDLIBS :=	$(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)
    1.30 +
    1.31 +.DEFAULT_TARGET = all
    1.32 +
    1.33 +.PHONY: all clean install
    1.34 +
    1.35 +all: $(PACKAGE)
    1.36 +
    1.37 +$(PACKAGE): $(OBJS)
    1.38 +	$(LINK.o) $^ $(LDLIBS) -o $@
    1.39  
    1.40  %.o: %.c
    1.41 -	$(CC) -c $< $(CFLAGS) -o $@
    1.42 +	$(COMPILE.c) -MD -o $@ $<
    1.43 +	@cp $*.d $*.P; \
    1.44 +	$(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
    1.45 +	       -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
    1.46 +	rm -f $*.d
    1.47 +
    1.48 +install:
    1.49 +	$(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
    1.50 +	$(INSTALL.data) $(AUTOSTART_FILE) \
    1.51 +			$(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
    1.52  
    1.53  clean:
    1.54 -	rm -f $(OBJS) $(NAME)
    1.55 +	-rm -f $(PACKAGE) $(OBJS)
    1.56 +
    1.57 +-include $(patsubst %.o,%.P,$(OBJS))