1all: a.out liba.dylib libb.dylib libc.dylib libd.dylib 2 3CC ?= clang 4ifeq "$(ARCH)" "" 5 ARCH = x86_64 6endif 7CFLAGS ?=-arch $(ARCH) -g -O0 8CWD := $(shell pwd) 9 10all: a.out hidden/libd.dylib 11 12a.out: main.o libd.dylib 13 $(CC) $(CFLAGS) -o a.out main.o -L. -ld 14 15main.o: main.c 16 $(CC) $(CFLAGS) -c main.c 17 18hidden/libd.dylib: b.o 19 $(CC) $(CFLAGS) -dynamiclib -o hidden/libd.dylib d.o 20 dsymutil -o hidden/libd.dylib.dSYM hidden/libd.dylib 21 22liba.dylib: a.o libb.dylib 23 $(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/liba.dylib" -o liba.dylib a.o -L. -lb 24 dsymutil liba.dylib 25 26a.o: a.c 27 $(CC) $(CFLAGS) -c a.c 28 29libb.dylib: b.o 30 $(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/libb.dylib" -o libb.dylib b.o 31 dsymutil libb.dylib 32 33b.o: b.c 34 $(CC) $(CFLAGS) -c b.c 35 36libc.dylib: c.o 37 $(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/libc.dylib" -o libc.dylib c.o 38 dsymutil libc.dylib 39 40c.o: c.c 41 $(CC) $(CFLAGS) -c c.c 42 43libd.dylib: d.o 44 $(CC) $(CFLAGS) -dynamiclib -install_name "$(CWD)/libd.dylib" -o libd.dylib d.o 45 dsymutil libd.dylib 46 47d.o: d.c 48 $(CC) $(CFLAGS) -c d.c 49 50clean: 51 rm -rf *.o *~ *.dylib a.out *.dSYM hidden/* 52