[PATCH 06/65] Makefile: compile with util

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Wed, 16 Apr 2014 17:18:14 +0200

compile with util, make dist adds util.

Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
---
 Makefile | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index f9484d5..096551c 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -1,8 +1,12 @@
 # See LICENSE file for copyright and license details.
 include config.mk
 
-SRC      = ii.c
-OBJ      = ${SRC:.c=.o}
+SRC = ii.c
+LIB = \
+	util/eprintf.o \
+	util/estrtol.o \
+	util/strlcpy.o
+OBJ = ${SRC:.c=.o} $(LIB)
 
 all: options ii
 	_AT_echo built ii
_AT_@ -15,22 +19,23 @@ options:
 	_AT_echo "LDFLAGS  = ${LDFLAGS}"
 	_AT_echo "CC       = ${CC}"
 
+.o:
+	_AT_echo LD $@
+	_AT_$(LD) -o $@ $< util.a $(LDFLAGS)
+
 .c.o:
 	_AT_echo CC $<
-	_AT_${CC} -c ${CFLAGS} $<
-
-dist: clean
-	_AT_mkdir -p ii-${VERSION}
-	_AT_cp -R query.sh Makefile CHANGES README FAQ LICENSE config.mk ii.c ii.1 ii-${VERSION}
-	_AT_tar -cf ii-${VERSION}.tar ii-${VERSION}
-	_AT_gzip ii-${VERSION}.tar
-	_AT_rm -rf ii-${VERSION}
-	_AT_echo created distribution ii-${VERSION}.tar.gz
+	_AT_$(CC) -c -o $@ $< $(CFLAGS)
 
 ii: ${OBJ}
 	_AT_echo LD $@
 	_AT_${CC} -o $@ ${OBJ} ${LDFLAGS}
 
+util.a: $(LIB)
+	_AT_echo AR $@
+	_AT_$(AR) -r -c $@ $(LIB)
+	_AT_ranlib $@
+
 install: all
 	_AT_mkdir -p ${DESTDIR}${DOCDIR}
 	_AT_mkdir -p ${DESTDIR}${BINDIR}
_AT_@ -48,5 +53,13 @@ uninstall: all
 	_AT_rm -f ${DESTDIR}${BINDIR}/ii
 	_AT_echo "uninstalled ii"
 
+dist: clean
+	_AT_mkdir -p ii-${VERSION}
+	_AT_cp -R query.sh Makefile CHANGES README FAQ LICENSE util config.mk ii.c ii.1 ii-${VERSION}
+	_AT_tar -cf ii-${VERSION}.tar ii-${VERSION}
+	_AT_gzip ii-${VERSION}.tar
+	_AT_rm -rf ii-${VERSION}
+	_AT_echo created distribution ii-${VERSION}.tar.gz
+
 clean:
-	rm -f ii *~ *.o *core *.tar.gz
+	rm -f ii *.o
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0007-gitignore-ignore-ii-and-util.a.patch"
Content-Disposition: attachment;
 filename="0007-gitignore-ignore-ii-and-util.a.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST