From 0ccb1b33091a54fd101c49bedc90bb0232b6eae3 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 17 Aug 2025 14:11:33 +0800 Subject: [PATCH] Simplify build process --- .gitignore | 5 +---- Makefile | 27 ++++++++++++--------------- diff --git a/.gitignore b/.gitignore index 95c08474031edcdbdef3f1392e1e308057869749..9b1c8b133c966006ff025957aa43c7de7bc04be8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ -/forge -/source.tar.gz -*.c.BAK -*.o +/dist diff --git a/Makefile b/Makefile index 2dc95f5595543ba57b8f5483d29d834b4545ac0c..4a049fa560f8a8fa7e74fefdda5cbe13a61befd0 100644 --- a/Makefile +++ b/Makefile @@ -7,29 +7,26 @@ # sufficiently expressive. This needs to be fixed sometime (or we might move to # some other build system). # -.PHONY: clean +.PHONY: clean all CFLAGS = -Wall -Wextra -pedantic -std=c99 -D_GNU_SOURCE -VERSION = $(shell git describe --tags --always --dirty) SOURCE_FILES = $(shell git ls-files) -EMBED = git2d/git2d hookc/hookc $(wildcard LICENSE*) $(wildcard forged/static/*) $(wildcard forged/templates/*) -EMBED_ = $(EMBED:%=forged/internal/embed/%) -forge: $(EMBED_) $(SOURCE_FILES) - CGO_ENABLED=0 go build -o forge -ldflags '-extldflags "-f no-PIC -static" -X "go.lindenii.runxiyu.org/forge/forged/internal/unsorted.version=$(VERSION)"' -tags 'osusergo netgo static_build' ./forged +all: dist/forged dist/git2d dist/hookc -hookc/hookc: +dist/forged: $(SOURCE_FILES) + mkdir -p dist + CGO_ENABLED=0 go build -o dist/forged -ldflags '-extldflags "-f no-PIC -static"' -tags 'osusergo netgo static_build' ./forged + +dist/git2d: $(wildcard git2d/*.c) + mkdir -p dist + $(CC) $(CFLAGS) -o dist/git2d $^ $(shell pkg-config --cflags --libs libgit2) -lpthread -git2d/git2d: $(wildcard git2d/*.c) - $(CC) $(CFLAGS) -o git2d/git2d $^ $(shell pkg-config --cflags --libs libgit2) -lpthread +dist/hookc: $(wildcard hookc/*.c) + mkdir -p dist + $(CC) $(CFLAGS) -o dist/hookc $^ clean: rm -rf forge hookc/hookc git2d/git2d */*.o -forged/internal/embed/%: % - @mkdir -p $(shell dirname $@) - @cp $^ $@ - -forged/internal/embed/.gitignore: - @touch $@ -- 2.48.1