blob: 86b113f11d135d12b09113581f3290a839ea5991 (
plain)
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
82
83
84
85
86
87
88
89
90
91
|
CC=gcc
TAR=tar
MKDIRS=mkdir -p
TOOLS=lxGcc64
# See "./configure"
PREFIX=/usr/local
EXEC_PREFIX=$(PREFIX)
EXEC_SUFFIX=
BINDIR=$(EXEC_PREFIX)/bin
ifndef PROJECT_VERSION
# We just provide a primitive version string so we can see which build
# we're using while debugging. For a release we will override the version
# by providing it from cli args to 'make' as in:
# make clean package PROJECT_VERSION=1.2.3
PROJECT_VERSION=$(shell date -u +0.0.0-%Y%m%d.%H%M%S)
endif
CFLAGS= --std=c99 \
-Wall -Wextra -Werror -fmax-errors=3 \
-Wno-error=unused-function -Wno-error=unused-label \
-Wno-error=unused-variable -Wno-error=unused-parameter \
-Wno-error=unused-const-variable \
-Werror=implicit-fallthrough=1 \
-Wno-error=unused-but-set-variable \
-Wno-unused-function -Wno-unused-parameter \
-DPROJECT_VERSION=$(PROJECT_VERSION)
LDFLAGS= -Wl,--no-demangle,--fatal-warnings
INCDIRS= -Isrc/bulk_ln -Isrc/common
ifndef NDEBUG
CFLAGS := $(CFLAGS) -ggdb -O0 -g3
else
CFLAGS := $(CFLAGS) -ffunction-sections -fdata-sections -Os "-DNDEBUG=1"
LDFLAGS := $(LDFLAGS) -Wl,--gc-sections,--as-needed
endif
default: link package
.PHONY: clean
clean:
@echo "\n[INFO ] Clean"
rm -rf build dist
.PHONY: link
link: build/bin/bulk-ln$(EXEC_SUFFIX)
build/obj/%.o: src/%.c
@echo "\n[INFO ] Compile '$@'"
@mkdir -p $(shell dirname build/obj/$*)
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
build/bin/bulk-ln$(EXEC_SUFFIX): \
build/obj/bulk_ln/bulk_ln.o \
build/obj/bulk_ln/bulk_ln_main.o
@echo "\n[INFO ] Link '$@'"
@mkdir -p $(shell dirname $@)
$(CC) -o $@ $(LDFLAGS) $^ $(LIBSDIR)
.PHONY: package
package: link
@echo "\n[INFO ] Package"
@rm -rf build/dist-* dist
@mkdir dist
@echo
@bash -c 'if [[ -n `git status --porcelain` ]]; then echo "[WARN ] Worktree not clean!"; sleep 3; fi'
@# Create Executable bundle.
@rm -rf build/dist-bin && mkdir -p build/dist-bin
@cp -t build/dist-bin \
README*
@mkdir build/dist-bin/bin
@cp -t build/dist-bin/bin \
build/bin/*$(EXEC_SUFFIX)
@(cd build/dist-bin && find . -type f -not -name MD5SUM -exec md5sum -b {} \;) > build/MD5SUM
@mv build/MD5SUM build/dist-bin/.
@(cd build/dist-bin && $(TAR) --owner=0 --group=0 -czf ../../dist/BulkLn-$(PROJECT_VERSION)-$(TOOLS).tgz *)
@echo "\n[INFO ] DONE: Artifacts created and placed in 'dist'."
@echo
@echo See './dist/' for result.
.PHONY: install
install:
@$(MKDIRS) "$(BINDIR)"
$(TAR) -f "$(shell ls dist/BulkLn-*-$(TOOLS).tgz)" \
-C "$(BINDIR)" --strip-components=1 -x bin
|