CFLAGS = -fexceptions -Wall -Werror -g
CC = gcc

all: except-pic except-pdc

clean:
	rm -fv except-pic except-pdc *.o *.so

pic.s: test.c Makefile
	$(CC) $(CFLAGS) -fPIC -S -o $@ $<

pdc.s: test.c Makefile
	$(CC) $(CFLAGS) -S -o $@ $<

except-pdc: test-main.c exception.c
	$(CC) $(CFLAGS) -o $@ $^

exception.s: exception.c
	$(CC) $(CFLAGS) -S -o $@ -fPIC $^

libexcept.so: exception.c
	$(CC) $(CFLAGS) -shared -o $@ -fPIC $^

except-pic: test-main.c libexcept.so
	$(CC) $(CFLAGS) -o $@ $< -L. -lexcept

