GITREV ?= $(shell git describe --dirty --always) BLDDATE ?= $(shell date -I) CR_YEAR ?= $(shell date +%Y) VERSION ?= "$(shell git describe --tags --always --abbrev=0 2>/dev/null || git rev-parse --short HEAD)" CFLAGS ?= -Wall -Wextra -Wpedantic -O2 -std=gnu99 CFLAGS += -DGITREV='"$(GITREV)"' CFLAGS += -DBLDDATE='"$(BLDDATE)"' CFLAGS += -DCR_YEAR='"$(CR_YEAR)"' CFLAGS += -DVERSION='$(VERSION)' CFLAGS += $(EXTRA_CFLAGS) PREFIX ?= /usr/local DESTDIR ?= writeimg: writeimg.c $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $^ clean: rm -f *.o writeimg install: writeimg install -d $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 install -m 0755 $< $(DESTDIR)$(PREFIX)/bin/$< install -m 0644 $<.1 $(DESTDIR)$(PREFIX)/share/man/man1/$<.1 # Note that this bypasses PREFIX, since # bash does not source /usr/local by default install_bash: writeimg_completion_bash.sh install -d $(DESTDIR)/etc/bash_completion.d install -m 0644 $< $(DESTDIR)/etc/bash_completion.d/$< uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/writeimg rm -f $(DESTDIR)$(PREFIX)/share/man/man1/writeimg.1 rm -f $(DESTDIR)/etc/bash_completion.d/writeimg* .PHONY: clean install uninstall