-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (58 loc) · 2.01 KB
/
Copy pathMakefile
File metadata and controls
71 lines (58 loc) · 2.01 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
# ── HackerOS Installer – Makefile ───────────────────────────────────────
CC := gcc
TARGET := hackeros-installer
# Source files (all .c in src/)
SRCS := src/main.c \
src/ui.c \
src/screen_welcome.c \
src/screen_locale.c \
src/screen_disk.c \
src/screen_user.c \
src/screen_network.c \
src/screen_roles.c \
src/screen_summary.c \
src/install.c
OBJS := $(SRCS:.c=.o)
# Compiler flags
CFLAGS := -O2 -Wall -Wextra -Wno-unused-parameter \
-std=c11 -D_GNU_SOURCE \
-Isrc
# ── Link mode ────────────────────────────────────────────────────────────
# Default: static link of ncursesw + tinfo, rest dynamic (libc etc.)
# For fully static: make STATIC=1
ifdef STATIC
LDFLAGS := -static
LIBS := -lncursesw -ltinfo
else
LIBS := -lncursesw -ltinfo
LDFLAGS :=
endif
# Static libs path (Debian/Ubuntu)
LIBNCURSESW := /usr/lib/x86_64-linux-gnu/libncursesw.a
LIBTINFO := /usr/lib/x86_64-linux-gnu/libtinfo.a
.PHONY: all clean install strip
all: $(TARGET)
$(TARGET): $(OBJS)
ifdef STATIC
$(CC) $(LDFLAGS) -o $@ $^ $(LIBNCURSESW) $(LIBTINFO)
else
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
endif
@echo ""
@echo " Built: $(TARGET)"
@file $(TARGET)
@ls -lh $(TARGET)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
strip: $(TARGET)
strip --strip-all $(TARGET)
@echo " Stripped: $(TARGET) ($$(ls -lh $(TARGET) | awk '{print $$5}'))"
install: $(TARGET)
install -Dm755 $(TARGET) /usr/local/sbin/$(TARGET)
@echo " Installed to /usr/local/sbin/$(TARGET)"
clean:
rm -f $(OBJS) $(TARGET)
# ── dependency tracking ──────────────────────────────────────────────────
-include $(SRCS:.c=.d)
%.d: %.c
@$(CC) $(CFLAGS) -MM -MT '$(<:.c=.o)' $< > $@