aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authors-over-42023-06-22 23:46:09 -0400
committers-over-42023-06-22 23:46:09 -0400
commit22c5a86f83288b94975bb84cbd1ebfa62d2ed2af (patch)
tree36b51b4ed5db954963d5eaebd097f902349c7ec1 /Makefile
parent3a38a28da1b26cba5d71d01db6e71ce30091765c (diff)
Makefile changes
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile60
1 files changed, 40 insertions, 20 deletions
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