39 lines
773 B
Makefile
39 lines
773 B
Makefile
|
|
# needed cflags
|
|
CFLAGS += -std=gnu2x
|
|
|
|
# add include directory
|
|
CFLAGS += -isystem ../include -DPREFIX=$(PREFIX)
|
|
INCLUDE += ../include
|
|
|
|
# add lib directory
|
|
SRC += ../lib
|
|
|
|
H_SRC = $(shell find $(SRC) $(INCLUDE) -type f -name "*.h")
|
|
C_SRC = $(shell find $(SRC) -type f -name "*.c")
|
|
C_OBJ = $(patsubst %.c,$(BIN)/%.o,$(C_SRC))
|
|
|
|
.PHONY: clean build run fuzz
|
|
|
|
build: $(BIN)/$(OUT)
|
|
|
|
clean:
|
|
rm -fr $(BIN)
|
|
rm -fr ../bin/lib
|
|
|
|
run: build
|
|
$(BIN)/$(OUT)
|
|
|
|
fuzz: clean
|
|
make -C . build CC=afl-cc LD=afl-cc
|
|
mkdir -p ../fuzz
|
|
rm -fr ../fuzz/$(OUT)
|
|
afl-fuzz -i ../test/$(OUT) -o ../fuzz -M $(OUT) -- $(BIN)/$(OUT) @@
|
|
|
|
$(C_OBJ): $(BIN)/%.o : %.c
|
|
@mkdir -p $(@D)
|
|
$(CC) -c $(CFLAGS) -o $@ $<
|
|
|
|
$(BIN)/$(OUT): $(C_OBJ) $(H_SRC)
|
|
@mkdir -p $(@D)
|
|
$(LD) $(LDFLAGS) -o $(BIN)/$(OUT) $(C_OBJ)
|