FLAGS = -Wall -Wextra -fno-strict-aliasing -fno-common -Wp,-D_FORTIFY_SOURCE=2 -O3 -ggdb3 -fPIC LTO = -flto CC = gcc AR = ar RANLIB = ranlib # Uncomment EITHER of the following line to make things work #LTO = #AR = gcc-ar #RANLIB = : all: main clean: rm -f lib.c main.c lib.o main.o libtest.a main lib.c: echo 'int answer(void) { return 42; }' > $@ main.c: echo 'int answer(void); int main(void) { return answer(); }' > $@ main: lib.c main.c $(CC) $(LTO) $(FLAGS) -c lib.c $(CC) $(LTO) $(FLAGS) -c main.c $(AR) cru libtest.a lib.o $(RANLIB) libtest.a $(CC) $(LTO) $(FLAGS) -o main main.o libtest.a .PHONY: clean all