aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile99
1 files changed, 45 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index 151bafd..d9602c2 100644
--- a/Makefile
+++ b/Makefile
@@ -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