From b0b6b5d559244ee79af51aa338d768e1c20546b5 Mon Sep 17 00:00:00 2001 From: Stefan Gehn Date: Sat, 23 Aug 2014 17:56:46 +0200 Subject: [PATCH] Share makefile rules and vars between client/server Move all make variables and rules duplicated between gkrellm and gkrellmd makefiles into a common file that can be included. This avoids duplication and hopefully avoids the two makefiles getting out of sync too much. This is also a preparation to ease overriding toolchain binaries (compiler, linker, pkgconfig) as part of windows cross compiling. This change also puts the "ar" tool into a variable that can be overridden if needed. Please note that this change uses the GNU Make specific include statement but AFAICS the makefiles already depend on GNU extensions in other areas (":=" and "ifdef" are non-standard make syntax). --- common.mk | 35 +++++++++++++++++++++++++++++++++++ server/Makefile | 35 ++++------------------------------- src/Makefile | 33 ++++----------------------------- 3 files changed, 43 insertions(+), 60 deletions(-) create mode 100644 common.mk diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..21172c5 --- /dev/null +++ b/common.mk @@ -0,0 +1,35 @@ +# makefile variables and rules shared by both gkrellm and gkrellmd + +CC ?= gcc +AR ?= ar +PKG_CONFIG ?= pkg-config +WINDRES ?= windres + +PREFIX ?= /usr/local +INSTALLROOT ?= $(DESTDIR)$(PREFIX) + +BINMODE ?= 755 +BINEXT ?= + +INSTALLDIRMODE ?= 755 + +INCLUDEDIR ?= $(INSTALLROOT)/include +INCLUDEMODE ?= 644 +INCLUDEDIRMODE ?= 755 + +LIBDIR ?= $(INSTALLROOT)/lib +LIBDIRMODE ?= 755 + +MANMODE ?= 644 +MANDIRMODE ?= 755 + +INSTALL ?= install +STRIP ?= -s +LINK_FLAGS ?= -Wl,-E + +SHARED_PATH = ../shared +# Make GNU Make search for sources somewhere else as well +VPATH = $(SHARED_PATH) + +%.o: %.c + $(CC) -c -Wall $(FLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@ diff --git a/server/Makefile b/server/Makefile index 290fd20..301f51f 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,35 +1,16 @@ -PACKAGE_D ?= gkrellmd -PKG_CONFIG ?= pkg-config -BINMODE ?= 755 -BINEXT ?= +include ../common.mk -PREFIX ?= /usr/local -INSTALLROOT ?= $(DESTDIR)$(PREFIX) +PACKAGE_D ?= gkrellmd SINSTALLDIR ?= $(INSTALLROOT)/bin -INSTALLDIRMODE ?= 755 - -INCLUDEDIR ?= $(INSTALLROOT)/include -INCLUDEMODE ?= 644 -INCLUDEDIRMODE ?= 755 - -LIBDIR ?= $(INSTALLROOT)/lib -LIBDIRMODE ?= 755 CFGDIR ?= $(INSTALLROOT)/etc CFGDIRMODE ?= 755 CFGMODE ?= 644 SMANDIR ?= $(INSTALLROOT)/share/man/man1 -MANMODE ?= 644 -MANDIRMODE ?= 755 -INSTALL ?= install -LINK_FLAGS ?= -Wl,-E -EXTRAOBJS = -SHARED_PATH = ../shared -# Make GNU Make search for sources somewhere else as well -VPATH = $(SHARED_PATH) +EXTRAOBJS = ifeq ($(without-libsensors),yes) CONFIGURE_ARGS += --without-libsensors @@ -45,11 +26,6 @@ ifeq ($(HAVE_LIBSENSORS),1) SENSORS_LIBS ?= -lsensors endif - -CC ?= gcc -WINDRES ?= windres -STRIP ?= -s - GKRELLMD_INCLUDES = gkrellmd.h $(SHARED_PATH)/log.h PKG_INCLUDE = `$(PKG_CONFIG) --cflags glib-2.0 gmodule-2.0 gthread-2.0` @@ -234,11 +210,8 @@ win32-resource.o: win32-resource.rc win32-resource.h $(WINDRES) $< -o $@ win32-libgkrellmd.o: win32-libgkrellmd.c win32-plugin.h $(GKRELLMD_H) libgkrellmd.a: win32-libgkrellmd.o - ar -cr libgkrellmd.a win32-libgkrellmd.o + $(AR) -cr libgkrellmd.a win32-libgkrellmd.o # Checks if the build environment is ok check_env: $(PKG_CONFIG) --atleast-version=2.32 glib-2.0 - -%.o: %.c - $(CC) -c -Wall $(FLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@ diff --git a/src/Makefile b/src/Makefile index f73a143..e385825 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,31 +1,13 @@ -PACKAGE ?= gkrellm -PKG_CONFIG ?= pkg-config -BINMODE ?= 755 -BINEXT ?= +include ../common.mk -PREFIX ?= /usr/local -INSTALLROOT ?= $(DESTDIR)$(PREFIX) +PACKAGE ?= gkrellm INSTALLDIR ?= $(INSTALLROOT)/bin -INSTALLDIRMODE ?= 755 -INCLUDEDIR ?= $(INSTALLROOT)/include -INCLUDEMODE ?= 644 -INCLUDEDIRMODE ?= 755 -LIBDIR ?= $(INSTALLROOT)/lib -LIBDIRMODE ?= 755 MANDIR ?= $(INSTALLROOT)/share/man/man1 -MANMODE ?= 644 -MANDIRMODE ?= 755 -INSTALL ?= install -LINK_FLAGS ?= -Wl,-E + X11_LIBS ?= -L/usr/X11R6/lib -lX11 -lSM -lICE MATH_LIB ?= -lm -SHARED_PATH = ../shared -# Make GNU Make search for sources somewhere else as well -VPATH = $(SHARED_PATH) - - ifeq ($(without-gnutls),1) CONFIGURE_ARGS += --without-gnutls endif @@ -60,10 +42,6 @@ ifneq ($(HAVE_SSL),1) EXTRAOBJS ?= md5c.o endif -CC ?= gcc -WINDRES ?= windres -STRIP ?= -s - GKRELLM_INCLUDES = gkrellm.h gkrellm-public-proto.h $(SHARED_PATH)/log.h PKG_INCLUDE = `$(PKG_CONFIG) --cflags gtk+-2.0 gmodule-2.0 gthread-2.0` @@ -348,12 +326,9 @@ win32-resource.o: win32-resource.rc win32-resource.h $(WINDRES) $< -o $@ libgkrellm.a: win32-libgkrellm.o - ar -cr libgkrellm.a win32-libgkrellm.o + $(AR) -cr libgkrellm.a win32-libgkrellm.o # Checks if the build environment is ok check_env: $(PKG_CONFIG) --atleast-version=2.32 glib-2.0 $(PKG_CONFIG) --atleast-version=2.4 gtk+-2.0 - -%.o: %.c - $(CC) -c -Wall $(FLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@