commit 91db3e45d9d09f8b25def75bfcab42e911f28e3c parent ce1bf7b0423244d600ef309d7589e051aafe9a89 Author: lostd <lostd@2f30.org> Date: Thu, 14 Nov 2013 18:52:21 +0200 Use a generic rule to build the .so file Diffstat:
M | Makefile | | | 23 | +++++++++++------------ |
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile @@ -1,17 +1,16 @@ -SRC = callgraph.c -OBJ = ${SRC:.c=.o} -SONAME = ${SRC:.c=.so} -CC = gcc +LIB = callgraph.so -all: callgraph +CC = gcc +CFLAGS = -fPIC -Wall -Wextra -std=gnu99 -Wshadow -Wunreachable-code -g +LDFLAGS = -shared -Wl,-soname=${LIB} +LDLIBS = -lc -.c.o: - ${CC} -fPIC -Wall -Wextra -std=gnu99 -Wshadow -Wunreachable-code -g -c ${SRC} - -callgraph: ${OBJ} - ${CC} -g -shared -Wl,-soname,${SONAME} -o ${SONAME} ${OBJ} -lc +all: ${LIB} clean: - @rm -f ${OBJ} ${SONAME} callgraph.dot* + rm -f ${LIB} callgraph.dot* -.PHONY: all clean +.o.so: + ${CC} ${LDFLAGS} $< ${LDLIBS} -o $@ + +.SUFFIXES: .so