switching to config build sys
lunix is why we can't have nice things
This commit is contained in:
85
ke/Makefile
85
ke/Makefile
@@ -1,50 +1,57 @@
|
||||
BIN := ke
|
||||
OBJS := main.o
|
||||
INSTROOT := $(HOME)
|
||||
VERSION := 0.9.2
|
||||
CC ?= gcc
|
||||
TARGET := ke
|
||||
OBJS := main.o
|
||||
LIBS := -lefence
|
||||
|
||||
LDFLAGS :=
|
||||
CFLAGS := -pedantic -Wall -Werror -Wextra -O2 -std=c99 -g
|
||||
CFLAGS += -fno-builtin-memmove -DKE_VERSION="\"$(VERSION)\""
|
||||
PREFIX ?= /usr/local
|
||||
MANDIR ?= /usr/local/man
|
||||
|
||||
.PHONY: all
|
||||
all: build
|
||||
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g
|
||||
CFLAGS += -DKE_VERSION="\"$(TARGET) version $(VERSION)\""
|
||||
CFLAGS += -D_DEFAULT_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE
|
||||
all: $(TARGET)
|
||||
|
||||
.PHONY: build
|
||||
build: $(BIN)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS)
|
||||
|
||||
$(BIN).1.txt: $(BIN).1
|
||||
mandoc -Tutf8 $(BIN).1 > $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(BIN) $(OBJS) *.core keypress
|
||||
-rm -f .?*.* *.core *.o *.html tags $(TARGET) $(OBJS)
|
||||
-rm -rf security
|
||||
-rm -rf $(TARGET)-$(VERSION)
|
||||
-rm -f $(TARGET)-$(VERSION).tgz
|
||||
|
||||
.PHONY: run
|
||||
run: $(BIN)
|
||||
reset
|
||||
./$(BIN) hello.txt
|
||||
$(TARGET): $(OBJS)
|
||||
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS)
|
||||
|
||||
keypress: keypress.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ keypress.c
|
||||
install: $(TARGET)
|
||||
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
|
||||
install -m 0755 -d $(MANDIR)/man1
|
||||
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
|
||||
|
||||
.PHONY: install
|
||||
install: $(BIN) $(BIN).1
|
||||
install -d $(INSTROOT)/bin/
|
||||
install -d $(INSTROOT)/share/man/man1
|
||||
install -C $(BIN) $(INSTROOT)/bin/
|
||||
install -C $(BIN).1 $(INSTROOT)/share/man/man1/$(BIN).1
|
||||
uninstall:
|
||||
-rm -f $(PREFIX)/bin/$(TARGET)
|
||||
-rm -f $(MANDIR)/man1/$(TARGET).1
|
||||
|
||||
.PHONY: upload
|
||||
upload: $(BIN).1.txt
|
||||
scp main.c p.kyleisom.net:/var/www/sites/p/ke/$(BIN)_$(VERSION).c.txt
|
||||
scp $(BIN).1.txt p.kyleisom.net:/var/www/sites/p/ke/$(BIN).1.txt
|
||||
lint:
|
||||
-mkdir security
|
||||
-rats -w 3 $(TARGET).[ch] > security/rats.out
|
||||
-lint -fhrs $(TARGET).c > security/lint.out
|
||||
-splint +posixlib $(TARGET).[ch] > security/splint.out
|
||||
|
||||
.PHONY: cloc
|
||||
cloc:
|
||||
cloc main.c
|
||||
dist: clean
|
||||
-mkdir $(TARGET)-$(VERSION)
|
||||
-cp * $(TARGET)-$(VERSION)
|
||||
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
|
||||
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
|
||||
|
||||
%.o: %.c
|
||||
distclean: clean
|
||||
-rm -f Makefile
|
||||
|
||||
htmldoc:
|
||||
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
|
||||
|
||||
tags:
|
||||
ctags *.[ch]
|
||||
|
||||
.c.o:
|
||||
$(CC) -c ${CFLAGS} $?
|
||||
|
||||
.PHONY: clean all install lint uninstall dist distclean htmldoc tags
|
||||
|
||||
Reference in New Issue
Block a user