CFLAGS=-g -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-array-bounds -Wno-stringop-overflow -m32 -no-pie -fno-pie
LDFLAGS=-m32
LDLIBS=-lpthread
C=$(wildcard *.c)
O=$(C:.c=)
O2=$(C:.c=.O2)

pframe:
	curl -o pframe.tgz  https://dept-info.labri.fr/~thibault/SecuLog/pframe.tgz && \
		tar -xf pframe.tgz &&\
		rm -rf pframe.tgz

.gdbinit:

configure: pframe .gdbinit
	$(shell echo "python import pframe" > .gdbinit) 
%.O2: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -O2 $^ $(LDLIBS) -o $@

all: $O $(O2)

PHONY: gdb_%
gdb_%: $(subst gdb_,,%)
	PYTHONPATH=${PWD}/pframe${PYTHONPATH:+:${PYTHONPATH}} gdb $<

clean:
	rm -f $O $(O2)
