From 22c5a86f83288b94975bb84cbd1ebfa62d2ed2af Mon Sep 17 00:00:00 2001 From: s-over-4 Date: Thu, 22 Jun 2023 23:46:09 -0400 Subject: Makefile changes --- Makefile | 60 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 20 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 057890d..fa953ca 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,49 @@ -.PHONY: install uninstall dev clean test me a sandwich -name := halk -cc := gcc -flags := -devflags := -ggdb -fsanitize=leak,address,undefined -fno-omit-frame-pointer -sources := $(wildcard src/*.c) -sources := $(filter-out src/parser.c, $(sources)) # exclude the incomplete parser for now. -objects := $(sources:.c=.o) - -$(name): $(objects) - $(cc) $(objects) $(flags) -o ./$(name).out - -dev: $(objects) - $(cc) $(objects) $(devflags) -o ./$(name).out - -%.o: %.c include/%.h - $(cc) -c $(flags) $< -o $@ +PREFIX := /usr/local +BINDIR := $(PREFIX)/bin +BIN := halk +TMPBIN := halk.out +CC := gcc +FLAGS := +DEVFLAGS := -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: + @echo "HALK build options " + @echo "================== " + @echo "cc: $(CC) " + @echo "flags: $(FLAGS) " + @echo " " + +devoptions: + @echo "HALK build options (development) " + @echo "================================ " + @echo "cc: $(CC) " + @echo "flags: $(DEVFLAGS) " + @echo " " + +HALK: $(OBJS) + $(CC) $(OBJS) $(FLAGS) -o $(TMPBIN) + +dev: $(OBJS) + @make devoptions + $(CC) $(OBJS) $(DEVFLAGS) -o $(TMPBIN) install: make - cp ./$(name).out /usr/bin/$(name) + cp ./$(BIN).out $(BINDIR)/$(BIN) uninstall: - rm -f /usr/bin/$(name) + rm -f $(BINDIR)/$(BIN) clean: - rm -f ./$(name).out ./src/*.o + rm -f $(TMPBIN) src/*.o + +%.o: %.c include/%.h + $(CC) -c $(FLAGS) $< -o $@ # fun me: @@ -33,3 +52,4 @@ me: a sandwich: @exit +.PHONY: all options devoptions dev install uninstall clean -- cgit v1.2.3