Skip to content

Commit 397b15e

Browse files
author
Julio Viera
committed
Improves Makefile to one generated generated with chatgpt
1 parent 779aa64 commit 397b15e

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

Makefile

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
all: args/args.c eatmemory.c
1+
CC := gcc
2+
CFLAGS := -Wall -Wextra -std=c99
3+
LDFLAGS :=
4+
SRC := $(shell find . -type f -name '*.c')
5+
EXE := eatmemory
6+
PREFIX := /usr/local
7+
INSTALL_DIR := $(PREFIX)/bin
28

3-
ifeq ($(shell uname 2>/dev/null), AIX)
4-
gcc -maix64 args/args.c eatmemory.c -o eatmemory
5-
else
6-
$(CC) args/args.c eatmemory.c -o eatmemory
7-
endif
9+
# Default target: Build the eatmemory program
10+
all: $(EXE)
811

12+
$(EXE): $(SRC)
13+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
914

10-
install: eatmemory
11-
mkdir -p $(PREFIX)/bin
12-
install -m 0755 eatmemory $(PREFIX)/bin/
15+
# Install the executable to the specified PREFIX directory
16+
install: $(EXE)
17+
mkdir -p $(INSTALL_DIR)
18+
install -m 755 $< $(INSTALL_DIR)
1319

20+
# Clean generated files
1421
clean:
15-
rm -rf *o eatmemory
22+
rm -f $(EXE)
23+
24+
# Display help message
25+
help:
26+
@echo "Usage: make [target] [PREFIX=/your/installation/path]"
27+
@echo "Targets:"
28+
@echo " all (default) - Build the eatmemory program"
29+
@echo " install - Install the executable to PREFIX/bin"
30+
@echo " clean - Remove generated files"
31+
@echo " help - Display this help message"
32+
33+
.PHONY: all install clean help

0 commit comments

Comments
 (0)