I hate bmake

This commit is contained in:
Emil 2023-08-02 08:29:19 -06:00
parent 5b269aa405
commit a7b6cd8e89
2 changed files with 69 additions and 21 deletions

46
GNUmakefile Normal file
View File

@ -0,0 +1,46 @@
.POSIX: # Just kidding, use GNU Make
# OVERRIDE ME #
PREFIX := .
PROGN := probotic
CC := cc
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic
CPPFLAGS := -I/usr/bin/ircclient/
LDFLAGS := -lircclient
SRC.DIR := src
OBJ.DIR := $(PREFIX)/obj
# INC.DIR := include
OBJ := $(addprefix $(OBJ.DIR)/,fetch.o main.o)
# HDR :=
VPATH := $(INC.DIR) $(SRC.DIR) $(OBJ.DIR)
ifeq ($(DEBUG),1)
CFLAGS += -Og -g3
else
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
endif
ifdef SAN
CFLAGS += -fsanitize=$(SAN)
endif
CPPFLAGS += -DPROGN="\"$(PROGN)\""
$(OBJ.DIR)/%.o: $(SRC.DIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(PREFIX)/$(PROGN): $(VPATH) $(PREFIX) $(HDR) | $(OBJ)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $| $(LDFLAGS)
# include/config.h: include/config.mk.h
# cp -f $< $@
$(VPATH) $(PREFIX):
mkdir -p $@
clean:
$(RM) $(OBJ) $(PROGN)

View File

@ -1,7 +1,4 @@
.POSIX: # Just kidding, use GNU Make
# OVERRIDE ME #
PREFIX := .
PROGN := probotic
CC := cc
@ -10,37 +7,42 @@ CPPFLAGS := -I/usr/bin/ircclient/
LDFLAGS := -lircclient
SRC.DIR := src
OBJ.DIR := $(PREFIX)/obj
OBJ.DIR := obj
# INC.DIR := include
OBJ := $(addprefix $(OBJ.DIR)/,fetch.o main.o)
SRC := fetch.c main.c
OBJ := ${OBJ.DIR}/fetch.o ${OBJ.DIR}/main.o
# HDR :=
VPATH := $(INC.DIR) $(SRC.DIR) $(OBJ.DIR)
VPATH := ${INC.DIR}:${SRC.DIR}:${OBJ.DIR}
ifeq ($(DEBUG),1)
CFLAGS += -Og -g3
else
CFLAGS += -O3 -flto=auto -fomit-frame-pointer
endif
.if "${DEBUG}" == "1"
CFLAGS := ${CFLAGS} -Og -g3
.else
CFLAGS := ${CFLAGS} -O3 -flto=auto -fomit-frame-pointer
.endif
ifdef SAN
CFLAGS += -fsanitize=$(SAN)
endif
.ifdef SAN
CFLAGS := ${CFLAGS} -fsanitize=${SAN}
.endif
CPPFLAGS += -DPROGN="\"$(PROGN)\""
CPPFLAGS := ${CPPFLAGS} -DPROGN="\"${PROGN}\""
$(OBJ.DIR)/%.o: $(SRC.DIR)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
all: ${PROGN}
$(PREFIX)/$(PROGN): $(VPATH) $(PREFIX) $(HDR) | $(OBJ)
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $| $(LDFLAGS)
${PROGN}: ${OBJ.DIR} ${PREFIX} ${HDR} ${OBJ}
${CC} ${CFLAGS} ${CPPFLAGS} -o $@ ${OBJ} ${LDFLAGS}
${OBJ.DIR}/main.o: ${SRC.DIR}/main.c
${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ ${SRC.DIR}/main.c
${OBJ.DIR}/fetch.o: ${SRC.DIR}/fetch.c
${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ ${SRC.DIR}/fetch.c
# include/config.h: include/config.mk.h
# cp -f $< $@
$(VPATH) $(PREFIX):
${OBJ.DIR} ${PREFIX}:
mkdir -p $@
clean:
$(RM) $(OBJ) $(PROGN)
${RM} ${OBJ} ${PROGN}