CC = gcc CCFLAGS=-pedantic -Wall LD_OPTS= # $< - the current dependency file # $@ - the current target file # $* - the base name of the current target # $? - all dependencies that are newer than the target # -fPIV : emit position-independent code # -nostartfiles : do not use the standard system startup files when linking %.o: %.c $(CC) $(CCFLAGS) -c -I. -o $@ $< default: all clib.o: clib.c clib.h $(CC) $(CCFLAGS) -c -fPIC $< libclib.so: clib.o $(CC) $(CCFLAGS) -shared -nostartfiles -Wl,-soname,libclib.so -o libclib.so.1.0 $< ldlinks: @ldconfig -n . main: libclib.so ldlinks main.o clib.h $(CC) $(LD_OPTS) main.o -L. -lclib -o main all: main clean: @rm -f main *.o *.so* *~