From 615b703925506d704e86ca883fb8a30af5054434 Mon Sep 17 00:00:00 2001 From: Peter Hjalmarsson Date: Mon, 14 Dec 2009 11:04:04 +0100 Subject: [PATCH] Make it possible to only build the daemon This changes makes the daemon only build with its dependencies, making it possible to build and install it without gtk+ and libnotifys devel-packages installed if you do not want the applet. Other changes include using $(CC) rather then hardcoded "gcc", use CFLAGS and LDFLAGS from env if resent, and link with both sets of flags as the gcc documentation suggests and recommends you to do. --- Makefile | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index fc6bb43..f28c955 100644 --- a/Makefile +++ b/Makefile @@ -10,31 +10,43 @@ LOCALESDIR=/usr/share/locale MANDIR=/usr/share/man/man8 CC?=gcc -CFLAGS := -O2 -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -W -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wformat -Wformat-security -Werror=format-security +CFLAGS += -O2 -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -W -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wformat -Wformat-security -Werror=format-security + +# +# As the daemon does not need the applet, and does not need gtk+ or libnotify +# lets seperate the CFLAGS and LDFLAGS so they only get what they need. +# +A_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0` +D_CFLAGS := `pkg-config --cflags glib-2.0 dbus-glib-1` +A_LDFLAGS := `pkg-config --libs libnotify gtk+-2.0` +D_LDFLAGS := `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" -MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0` # # pkg-config tends to make programs pull in a ton of libraries, not all # are needed. -Wl,--as-needed tells the linker to just drop unused ones, # and that makes the applet load faster and use less memory. # -LDF_A := -Wl,--as-needed `pkg-config --libs libnotify gtk+-2.0` -LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" +LDFLAGS += -Wl,--as-needed + all: kerneloops kerneloops-applet kerneloops.8.gz noui: kerneloops kerneloops.8.gz .c.o: - $(CC) $(CFLAGS) $(MY_CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< +kerneloops: CFLAGS += $(D_CFLAGS) +kerneloops: LDFLAGS += $(D_LDFLAGS) kerneloops: kerneloops.o submit.o dmesg.o configfile.o kerneloops.h - gcc kerneloops.o submit.o dmesg.o configfile.o $(LDF_D) -o kerneloops + $(CC) kerneloops.o submit.o dmesg.o configfile.o $(CFLAGS) $(LDFLAGS) -o kerneloops @(cd po/ && $(MAKE)) +kerneloops-applet: CFLAGS += $(A_CFLAGS) +kerneloops-applet: LDFLAGS += $(A_LDFLAGS) kerneloops-applet: kerneloops-applet.o - gcc kerneloops-applet.o $(LDF_A)-o kerneloops-applet + $(CC) kerneloops-applet.o $(CFLAGS) $(LDFLAGS) -o kerneloops-applet kerneloops.8.gz: kerneloops.8 gzip -9 -c $< > $@ -- 1.6.5.6