summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAndreas Fankhauser (@tux-six)2022-05-30 16:13:08 +0200
committerAndreas Fankhauser (@tux-six)2022-05-30 16:13:08 +0200
commit3f8ac6551aa0f53fd14b216e97e79939635b8b82 (patch)
treed71d6b71cd5781692ca95fe938de630bd286e647 /Makefile
parent4d54d900cd2cfb880b5cada3b9baef6a30a04332 (diff)
downloadbulk-ln-3f8ac6551aa0f53fd14b216e97e79939635b8b82.zip
bulk-ln-3f8ac6551aa0f53fd14b216e97e79939635b8b82.tar.gz
Add from existing sources after some cleanup.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile81
1 files changed, 81 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f3abfb7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,81 @@
+
+CC=gcc
+LD=ld
+AR=ar
+TAR=tar
+BINEXT=
+TOOLS=lxGcc64
+
+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 +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$(BINEXT)
+
+build/obj/%.o: src/%.c
+ @echo "\n[INFO ] Compile '$@'"
+ @mkdir -p $(shell dirname build/obj/$*)
+ $(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
+
+build/bin/bulk-ln$(BINEXT): \
+ 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 "[ERROR] Worktree not clean as it should be (see: git status)"; exit 1; 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/*$(BINEXT)
+ @(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.
+