Make polishing

This commit is contained in:
Imbus 2024-04-08 01:14:45 +02:00
parent 7c747ad404
commit 5f94263789

View file

@ -22,9 +22,11 @@ CFLAGS += -Wno-unused-macros
CFLAGS += -O3
CFLAGS += -g
GITHASH = $(shell git rev-parse --short HEAD)
# Specify the target binary (call it whatever)
TARGET = build/bin.elf
TARGET_TAR = $(TARGET).tar.zst
TARGET = build/program
TARGET_TAR = $(TARGET)-$(GITHASH).tar.zst
TARGET_SIG = $(TARGET_TAR).minisig
SRCS := $(wildcard src/*.c)
@ -32,45 +34,41 @@ SRCS := $(wildcard src/*.c)
# Specify the object files in the build directory
OBJS := $(patsubst src/%.c,build/%.o,$(SRCS))
all : $(TARGET)
release : $(TARGET)
@strip $(TARGET)
@upx -q --force-overwrite $(TARGET) -o $(TARGET).upx > /dev/null
@minisign -Sm $(TARGET)
@tar --zstd -cvf $(TARGET).tar.zst $(TARGET) $(TARGET).minisig 1>/dev/null
@zip $(TARGET).zip $(TARGET) $(TARGET).minisig 1>/dev/null
@7za a $(TARGET).7z $(TARGET) $(TARGET).minisig 1>/dev/null
all: $(TARGET)
# For convenience
run : $(TARGET)
run: $(TARGET)
@./$(TARGET)
# Create the build directory
mkbuilddir:
@mkdir -p build
# Link the object files into the target binary
$(TARGET) : $(OBJS)
$(TARGET): $(OBJS)
@$(CC) $(CFLAGS) -o $@ $^
@echo -e "LD \t$^"
# Compile the source files into object files
build/%.o : src/%.c | mkbuilddir
build/%.o: src/%.c | mkbuilddir
@$(CC) $(CFLAGS) -c -o $@ $< || (rm -f $@ && exit 1)
@echo -e "CC \t$<"
# Print the size of the target binary
size : $(TARGET)
size: $(TARGET)
$(SIZE) $(TARGET)
# Clean up the build directory
clean :
clean:
rm -r build
rm -f build/*.o
rm -f $(TARGET)*
# Create a signed release
tar: $(TARGET_TAR) $(TARGET_SIG)
tar: $(TARGET_TAR)
# Sign the tar
sign: $(TARGET_SIG)
$(TARGET_SIG): $(TARGET_TAR)
minisign -Sm $<
@ -79,4 +77,4 @@ $(TARGET_TAR): $(TARGET)
strip $<
tar --zstd -cvf $@ $<
.PHONY : all clean size mkbuilddir run gdb
.PHONY: all clean size mkbuilddir run tar sign