diff options
author | c+1 | 2023-10-19 14:45:42 -0400 |
---|---|---|
committer | c+1 | 2023-10-19 14:45:42 -0400 |
commit | cc7bb40ae5e7f8f345195547b2c5044efc4d61ba (patch) | |
tree | 3e9135bbaa690efaddfefab45a7802d6d99a9d20 | |
parent | 85bb2db8dee7898c890f5d1fc0b3874bee3d88ba (diff) |
Fix Makefile
-rw-r--r-- | Makefile | 99 |
1 files changed, 45 insertions, 54 deletions
@@ -1,61 +1,52 @@ -NAME := HALK -PREFIX := /usr/local -BINDIR := $(PREFIX)/bin -BIN := $(shell echo $(NAME) | tr '[:upper:]' '[:lower:]') -TMPBIN := $(BIN).out -CC := gcc -FLAGS := -O3 -s -DEVFLAGS := -g -ggdb -fsanitize=leak,address,undefined -fno-omit-frame-pointer -SRCS := $(wildcard src/*.c) -SRCS := $(filter-out src/parser.c, $(SRCS)) # exclude the incomplete parser for now. -OBJS := $(SRCS:.c=.o) - -all: options HALK - -options: - @$(eval $@_TITLE := "$(NAME) build options") - @$(eval $@_ULINE := $(shell echo "$($@_TITLE)" | tr '[:print:]' '=')) - @echo "$($@_TITLE)" - @echo "$($@_ULINE)" - @echo "cc: $(CC)" - @echo "flags: $(FLAGS)" - @echo "" - -devoptions: - @$(eval $@_TITLE := "$(NAME) build options \(development\)") - @$(eval $@_ULINE := $(shell echo "$($@_TITLE)" | tr '[:print:]' '=')) - @echo "$($@_TITLE)" - @echo "$($@_ULINE)" - @echo "cc: $(CC)" - @echo "flags: $(DEVFLAGS)" - @echo "" - -HALK: $(OBJS) - $(CC) $(OBJS) $(FLAGS) -o $(TMPBIN) - -dev: devoptions $(OBJS) - $(CC) $(OBJS) $(DEVFLAGS) -o $(TMPBIN) - -install: - make - cp ./$(BIN).out $(BINDIR)/$(BIN) - -uninstall: - rm -f $(BINDIR)/$(BIN) - -clean: - rm -f $(TMPBIN) src/*.o +BIN := halk +PREFIX := /usr/local/bin +CC := gcc +REG_CFLAGS := -std=c99 -O3 -s +DBG_CFLAGS := -Og -ggdb -pedantic -Wall -Wno-deprecated-declarations -fsanitize=leak,address,undefined -fno-omit-frame-pointer +CFLAGS := ${REG_CFLAGS} +SRCS := $(wildcard src/*.c) +SRCS := $(filter-out src/parser.c, $(SRCS)) +OBJS := $(SRCS:.c=.o) + +all: halk + +reg_options: + @echo "HALK build options:" + @echo "CC: ${CC}" + @echo "REG_CFLAGS: ${REG_CFLAGS}" + @echo + +dbg_options: + @echo "HALK build options (dbg):" + @echo "CC: ${CC}" + @echo "DBG_CFLAGS: ${DBG_CFLAGS}" + @echo + +halk: reg_options ${OBJS} + ${CC} ${OBJS} ${REG_CFLAGS} -o ${BIN}.out + +dbg: CFLAGS += ${DBG_CFLAGS} +dbg: dbg_options ${OBJS} + ${CC} ${OBJS} ${DBG_CFLAGS} -o ${BIN}.out %.o: %.c include/%.h - $(CC) -c $(DEVFLAGS) $< -o $@ + ${CC} -c ${CFLAGS} $< -o $@ -%.o: %.c - $(CC) -c $(DEVFLAGS) $< -o $@ +install: all + mkdir -p ${PREFIX} + cp -f ${BIN}.out ${PREFIX}/${BIN} + chmod 755 ${PREFIX}/${BIN} -me: - @[ "$(USER)" = "root" ] && echo "Okay." || echo "What? Make it yourself." +uninstall: + rm -f ${PREFIX}/${BIN} + +clean: + rm -f ${BIN}.out src/*.o -a sandwich: +me a: @exit -.PHONY: all options devoptions dev install uninstall clean +sandwich: + @[ "$(USER)" = "root" ] && echo "Okay." || echo "What? Make(1) it yourself." + +.PHONY: all reg_options dbg_options dbg install uninstall clean |