Initial commit: IP geolocation tool using MaxMind GeoLite2
This commit is contained in:
commit
2e8c91bf33
5 files changed
+505
No files matched your search
@@ -0,0 +1,43 @@
|
||||
# ================================================================
|
||||
# Makefile for ip_geolocate
|
||||
#
|
||||
# Targets:
|
||||
# make — build release binary
|
||||
# make debug — build with AddressSanitizer + debug symbols
|
||||
# make clean — remove build artefacts
|
||||
# make run — build and run
|
||||
# ================================================================
|
||||
|
||||
CC = gcc
|
||||
TARGET = ip_geolocate
|
||||
SRC = ip_geolocate.c
|
||||
|
||||
CFLAGS = -O2 -Wall -Wextra -std=c11
|
||||
LDFLAGS = -lmaxminddb
|
||||
|
||||
# macOS: Homebrew puts libmaxminddb here
|
||||
UNAME := $(shell uname 2>/dev/null)
|
||||
ifeq ($(UNAME), Darwin)
|
||||
CFLAGS += -I/opt/homebrew/include -I/usr/local/include
|
||||
LDFLAGS += -L/opt/homebrew/lib -L/usr/local/lib
|
||||
endif
|
||||
|
||||
.PHONY: all debug clean run
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(SRC)
|
||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
||||
@echo "Build successful → ./$(TARGET)"
|
||||
@echo "Make sure GeoLite2-City.mmdb is in this directory."
|
||||
|
||||
debug: $(SRC)
|
||||
$(CC) -g -O0 -fsanitize=address,undefined -Wall -Wextra \
|
||||
-o $(TARGET)_debug $< $(LDFLAGS)
|
||||
@echo "Debug build → ./$(TARGET)_debug"
|
||||
|
||||
run: all
|
||||
./$(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(TARGET)_debug
|
||||
Reference in new issue
Block a user