-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (63 loc) · 1.82 KB
/
Makefile
File metadata and controls
81 lines (63 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2025 Masoud Bolhassani
CC = gcc
CFLAGS = -Wall -Wextra -O2 -I./include
CFLAGS += $(RPM_OPT_FLAGS)
CFLAGS += -Wunused-result
LDFLAGS = -lpcap -lncurses
SRC_DIR = src
BUILD_DIR = build
BIN_DIR = bin
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
TARGET = $(BIN_DIR)/trafix
VERSION := $(shell grep -v '^#' VERSION | head -n 1)
TAG := v$(VERSION)
TARBALL := trafix-$(VERSION).tar.gz
PREFIX := trafix-$(VERSION)
SOURCEDIR := $(HOME)/rpmbuild/SOURCES
SPECDIR := $(HOME)/rpmbuild/SPECS
# Default build
all: $(BIN_DIR) $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET) $(LDFLAGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BIN_DIR):
mkdir -p $(BIN_DIR)
# Version bumping script
bump:
@read -p "Enter version bump type (patch, minor, major): " bump_type; \
./scripts/bump-version.sh $$bump_type
# Git tag from version file
tag:
@if git rev-parse $(TAG) >/dev/null 2>&1; then \
echo "Tag $(TAG) already exists."; \
else \
git tag -a $(TAG) -m "Release $(TAG)"; \
git push origin $(TAG); \
fi
# Note: Tarball creation is no longer needed - GitHub auto-generates archives
# Copy spec to rpmbuild
copy-spec:
./scripts/copy-spec.sh $(SPECDIR)/
# Build RPM
rpm:
rpmbuild -ba $(SPECDIR)/trafix.spec
rpmbuild -bs $(SPECDIR)/trafix.spec
# Full release process
release: tag copy-spec rpm
# Installation
install: install-bin
install-bin:
install -D -m 0755 $(TARGET) $(DESTDIR)/usr/bin/trafix
uninstall:
rm -f $(DESTDIR)/usr/bin/trafix
rm -rf $(DESTDIR)/usr/share/doc/trafix
# Clean build files
clean:
rm -f $(TARGET)
rm -rf $(BUILD_DIR) $(BIN_DIR)
.PHONY: all clean install install-bin install-doc uninstall bump tag tarball copy-spec rpm release