feat: Makefile
This commit is contained in:
parent
ca9f8261bf
commit
845677abe1
2 changed files with 91 additions and 0 deletions
62
Makefile
Normal file
62
Makefile
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
.POSIX:
|
||||||
|
.SUFFIXES:
|
||||||
|
.PHONY: all run clean distclean install uninstall cgi
|
||||||
|
|
||||||
|
include config.mk
|
||||||
|
|
||||||
|
TARGET = feuille
|
||||||
|
SRC = feuille.c util.c server.c bin.c
|
||||||
|
OBJ = $(SRC:%.c=%.o)
|
||||||
|
|
||||||
|
all: $(TARGET) $(TARGET).1 cgi
|
||||||
|
|
||||||
|
run: $(TARGET)
|
||||||
|
./$(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@printf "%-8s $(OBJ)\n" "rm"
|
||||||
|
@rm -f $(OBJ)
|
||||||
|
|
||||||
|
distclean:
|
||||||
|
@printf "%-8s $(TARGET) $(OBJ)\n" "rm"
|
||||||
|
@rm -f $(TARGET) $(OBJ)
|
||||||
|
|
||||||
|
install: $(TARGET) $(TARGET).1
|
||||||
|
@echo "installing executable file to $(PREFIX)/bin"
|
||||||
|
@mkdir -p "$(PREFIX)/bin"
|
||||||
|
@cp -f $(TARGET) "$(PREFIX)/bin"
|
||||||
|
@chmod 755 "$(PREFIX)/bin/$(TARGET)"
|
||||||
|
|
||||||
|
@echo "installing manpage to $(MAN)/man1"
|
||||||
|
@mkdir -p $(MAN)/man1
|
||||||
|
@mv -f $(TARGET).1 $(MAN)/man1
|
||||||
|
@chmod 644 $(MAN)/man1/$(TARGET).1
|
||||||
|
|
||||||
|
uninstall: $(PREFIX)/bin/$(TARGET) $(MAN)/man1/$(TARGET).1
|
||||||
|
@echo "removing executable file from $(PREFIX)/bin"
|
||||||
|
@rm -f "$(PREFIX)/bin/$(TARGET)"
|
||||||
|
|
||||||
|
@echo "removing manpage from $(MAN)/man1"
|
||||||
|
@rm -f $(MAN)/man1/$(TARGET).1
|
||||||
|
|
||||||
|
$(TARGET): $(OBJ)
|
||||||
|
@printf "%-8s $(OBJ) -o $@\n" "$(CC)"
|
||||||
|
@$(CC) $(LDFLAGS) $(OBJ) -o $@
|
||||||
|
|
||||||
|
$(TARGET).1: $(TARGET).1.md
|
||||||
|
@printf "%-8s $(TARGET).1.md -o $@\n" "pandoc"
|
||||||
|
@sed "s/{VERSION}/$(VERSION)/g" $(TARGET).1.md | pandoc -s -t man -o $@
|
||||||
|
|
||||||
|
ADDR = 127.0.0.1
|
||||||
|
PORT = 8888
|
||||||
|
|
||||||
|
cgi: web/cgi/feuille.cgi
|
||||||
|
|
||||||
|
web/cgi/feuille.cgi: web/cgi/feuille.cgi.c
|
||||||
|
@printf "%-8s web/cgi/feuille.cgi.c -o $@\n" "$(CC)"
|
||||||
|
@$(CC) $(CFLAGS) $(LDFLAGS) -static -DADDR=\"$(ADDR)\" -DPORT=$(PORT) web/cgi/feuille.cgi.c -o $@
|
||||||
|
|
||||||
|
.SUFFIXES: .c .o
|
||||||
|
.c.o:
|
||||||
|
@printf "%-8s $<\n" "$(CC)"
|
||||||
|
@$(CC) $(CFLAGS) -c $<
|
29
config.mk
Normal file
29
config.mk
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# feuille version
|
||||||
|
VERSION = 1.0.0
|
||||||
|
|
||||||
|
# paths (customize them to fit your system)
|
||||||
|
PREFIX = /usr/local
|
||||||
|
MAN = $(PREFIX)/share/man
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I/usr/include -I.
|
||||||
|
LIBS = -L/usr/lib -lc
|
||||||
|
|
||||||
|
# OpenBSD / FreeBSD (uncomment)
|
||||||
|
#MAN = $(PREFIX)/man
|
||||||
|
#INCS = -I/usr/share/include -I.
|
||||||
|
#LIBS = -L/usr/share/lib -lc
|
||||||
|
|
||||||
|
# compiler
|
||||||
|
CC = cc
|
||||||
|
|
||||||
|
# debug build
|
||||||
|
CFLAGS = -g -std=c99 -Wall -Wextra -Wpedantic -Wno-sign-compare -DVERSION=\"$(VERSION)\" $(INCS)
|
||||||
|
LDFLAGS = -g $(LIBS)
|
||||||
|
|
||||||
|
# release build
|
||||||
|
CFLAGS$(DEBUG) = -std=c99 -Wall -Wextra -Wno-sign-compare -DVERSION=\"$(VERSION)\" -O3 $(INCS)
|
||||||
|
LDFLAGS$(DEBUG) = -s $(LIBS)
|
||||||
|
|
||||||
|
# static build (uncomment)
|
||||||
|
#LD_FLAGS += -static
|
Reference in a new issue