comparison 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
comparison
equal deleted inserted replaced
6:7539e6e1c299 7:56a7ed833d0a
1 CC=gcc 1 INSTALL := install
2 OBJS=main.o notify.o packagekit.o 2 INSTALL.exec := $(INSTALL) -D -m 0755
3 CFLAGS=$(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) -Wall -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE 3 INSTALL.data := $(INSTALL) -D -m 0644
4 LDFLAGS=$(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2) 4 SED := sed
5 NAME=pk-update-icon
6 5
7 all: $(NAME) 6 DESTDIR ?=
7 prefix ?= /usr/local
8 bindir ?= $(prefix)/bin
9 sysconfdir ?= /etc
10 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
8 11
9 $(NAME): $(OBJS) 12 PACKAGE = pk-update-icon
10 $(CC) $(OBJS) $(LDFLAGS) -o $(NAME) 13 VERSION = 0.1
14 OBJS = main.o notify.o packagekit.o
15 AUTOSTART_FILE = $(PACKAGE).desktop
16 CPPFLAGS := $(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \
17 -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
18 LDLIBS := $(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)
19
20 .DEFAULT_TARGET = all
21
22 .PHONY: all clean install
23
24 all: $(PACKAGE)
25
26 $(PACKAGE): $(OBJS)
27 $(LINK.o) $^ $(LDLIBS) -o $@
11 28
12 %.o: %.c 29 %.o: %.c
13 $(CC) -c $< $(CFLAGS) -o $@ 30 $(COMPILE.c) -MD -o $@ $<
31 @cp $*.d $*.P; \
32 $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
33 -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
34 rm -f $*.d
35
36 install:
37 $(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
38 $(INSTALL.data) $(AUTOSTART_FILE) \
39 $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
14 40
15 clean: 41 clean:
16 rm -f $(OBJS) $(NAME) 42 -rm -f $(PACKAGE) $(OBJS)
43
44 -include $(patsubst %.o,%.P,$(OBJS))