
BIN_DIR=../bin
SRCS   = ip_to_geo.c test.c cmdline.c server.c
TARGET = $(BIN_DIR)/ip_to_geo
CFLAGS = -Wall
LDFLAGS= -lpthread

ifneq ($(DEBUG),)
CFLAGS += -ggdb -O0
else
CFLAGS += -O2
endif

ifneq ($(DISABLE_SECCOMP),)
CFLAGS  += -DUSE_SECCOMP=1
LDFLAGS += -lseccomp
endif

all: $(BIN_DIR) ip_data.c $(TARGET)

$(BIN_DIR):
	@mkdir $(BIN_DIR)

ip_data.c:
	make -C ../data

cmdline.c: cmdline.ggo
	gengetopt --input $^

$(TARGET): $(SRCS)
	gcc $(CFLAGS) $^ $(LDFLAGS) -o $@

clean:
	rm -f *~ $(TARGET)

ultra_clean: clean
	rm -f ip_data.c
