From 8e25b218ad52abdb5349b19a21ef3f4b19ccad04 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Fri, 9 Sep 2016 18:31:53 +0200 Subject: [PATCH] Factorize Makefiles rules --- apps/Makefile | 26 ++++++++++---------------- apps/octonet/Makefile | 25 +++++++------------------ 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/apps/Makefile b/apps/Makefile index 31a1ed5..af6a242 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,20 +1,14 @@ -all: cit citin flashprog modt ddtest setmod ddflash setmod2 pls setmod3 +PTHREAD_BINS=cit modt +INCLUDE_BINS=setmod setmod2 setmod3 +STANDARD_BINS=flashprog ddtest ddflash pls -cit: cit.c - $(CC) -o cit cit.c -lpthread +all: $(PTHREAD_BINS) $(INCLUDE_BINS) $(STANDARD_BINS) -modt: modt.c - $(CC) -o modt modt.c -lpthread +$(PTHREAD_BINS): %: %.c + gcc -o $@ $< -lpthread -setmod: setmod.c - $(CC) -o setmod setmod.c -I../include/ - -setmod2: setmod2.c - $(CC) -o setmod2 setmod2.c -I../include/ - -setmod3: setmod3.c - $(CC) -o setmod3 setmod3.c -I../include/ - -%.o: %.c - $(CC) $(CFLAGS) -o $@ $< +$(STANDARD_BINS): %: %.c + gcc -o $@ $< +$(INCLUDE_BINS): %: %.c + gcc -o $@ $< -I../include diff --git a/apps/octonet/Makefile b/apps/octonet/Makefile index bcc10c8..ae86d10 100644 --- a/apps/octonet/Makefile +++ b/apps/octonet/Makefile @@ -1,20 +1,9 @@ -all: ddtest octonet octokey ddflash +PROGS=ddtest octonet octokey ddflash +all: $(PROGS) -install: all - install -m 0755 ddtest $(DESTDIR)/usr/bin - install -m 0755 octonet $(DESTDIR)/usr/bin - install -m 0755 octokey $(DESTDIR)/usr/bin - install -m 0755 ddflash $(DESTDIR)/usr/bin - -ddflash: ddflash.c - $(CC) -o ddflash ddflash.c - -ddtest: ddtest.c - $(CC) -o ddtest ddtest.c - -octonet: octonet.c - $(CC) -o octonet octonet.c - -octokey: octokey.c - $(CC) -o octokey octokey.c +install: $(subst,$(PROGS),%,install-%) +$(subst,$(PROGS),%,install-%): install-%: % + install -m 0755 $< $(DESTDIR)/usr/bin +$(PROGS): %: %.c + $(CC) -o $@ $<