-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (62 loc) · 1.86 KB
/
Makefile
File metadata and controls
78 lines (62 loc) · 1.86 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
# Makefile for duef - A tool for uncompressing .uecrash files
# Simple Makefile for building duef with zlib dependency
# Compiler settings
CC = gcc
CFLAGS = -O2 -Wall -std=c99
LDFLAGS =
# Directories
ZLIB_DIR = zlib-1.3.1
BUILD_DIR = build
# Target executable
TARGET = duef
SOURCES = duef.c
OBJECTS = $(SOURCES:.c=.o)
# zlib settings
ZLIB_STATIC = $(ZLIB_DIR)/libz.a
ZLIB_OBJS = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o \
compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
# Include paths
INCLUDES = -I$(ZLIB_DIR)
# Platform-specific definitions
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CFLAGS += -D_GNU_SOURCE
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -D_DARWIN_C_SOURCE
endif
# Main target
all: $(TARGET)
# Build duef executable
$(TARGET): $(OBJECTS) $(ZLIB_STATIC)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(ZLIB_STATIC)
# Compile duef.c
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Build zlib static library
$(ZLIB_STATIC): $(addprefix $(ZLIB_DIR)/, $(ZLIB_OBJS))
cd $(ZLIB_DIR) && $(AR) rc libz.a $(ZLIB_OBJS)
cd $(ZLIB_DIR) && ranlib libz.a
# Compile zlib source files
$(ZLIB_DIR)/%.o: $(ZLIB_DIR)/%.c
$(CC) $(CFLAGS) -I$(ZLIB_DIR) -c $< -o $@
# Clean build artifacts
clean:
rm -f $(OBJECTS) $(TARGET)
cd $(ZLIB_DIR) && rm -f $(ZLIB_OBJS) libz.a
# Install target (optional)
install: $(TARGET)
install -D $(TARGET) $(DESTDIR)/usr/local/bin/$(TARGET)
# Uninstall target (optional)
uninstall:
rm -f $(DESTDIR)/usr/local/bin/$(TARGET)
# Show help
help:
@echo "Available targets:"
@echo " all - Build $(TARGET) (default)"
@echo " clean - Remove build artifacts"
@echo " install - Install $(TARGET) to /usr/local/bin"
@echo " uninstall- Remove $(TARGET) from /usr/local/bin"
@echo " help - Show this help message"
# Mark phony targets
.PHONY: all clean install uninstall help