CC?=gcc CFLAGS+=-Wall -I. LDFLAGS+=-L. .PHONY: all clean all: example example_static example_dynamic clean: rm -f example *.o lib*.a example: example.o hello.o $(CC) $(LDFLAGS) example.o hello.o -o example example.o: example.c hello.h $(CC) $(CFLAGS) -c example.c -o example.o hello.o: hello.c hello.h debug.h $(CC) $(CFLAGS) -c hello.c -o hello.o libhello.a: hello.o ar rcs libhello.a hello.o example_static: example.o libhello.a $(CC) $(LDFLAGS) example.o -Wl,-Bstatic -lhello -Wl,-Bdynamic -o example_static hello_fpic.o: hello.c hello.h debug.h $(CC) $(CFLAGS) -c -fPIC hello.c -o hello_fpic.o libhello.so: hello_fpic.o $(CC) $(LDFLAGS) -shared hello_fpic.o -o libhello.so example_dynamic: example.o libhello.so $(CC) $(LDFLAGS) example.o -lhello -L. -o example_dynamic