Skip to content

Commit

Permalink
Improves Makefile to one generated generated with chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio Viera committed Sep 22, 2023
1 parent 779aa64 commit 397b15e
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
all: args/args.c eatmemory.c
CC := gcc
CFLAGS := -Wall -Wextra -std=c99
LDFLAGS :=
SRC := $(shell find . -type f -name '*.c')
EXE := eatmemory
PREFIX := /usr/local
INSTALL_DIR := $(PREFIX)/bin

ifeq ($(shell uname 2>/dev/null), AIX)
gcc -maix64 args/args.c eatmemory.c -o eatmemory
else
$(CC) args/args.c eatmemory.c -o eatmemory
endif
# Default target: Build the eatmemory program
all: $(EXE)

$(EXE): $(SRC)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

install: eatmemory
mkdir -p $(PREFIX)/bin
install -m 0755 eatmemory $(PREFIX)/bin/
# Install the executable to the specified PREFIX directory
install: $(EXE)
mkdir -p $(INSTALL_DIR)
install -m 755 $< $(INSTALL_DIR)

# Clean generated files
clean:
rm -rf *o eatmemory
rm -f $(EXE)

# Display help message
help:
@echo "Usage: make [target] [PREFIX=/your/installation/path]"
@echo "Targets:"
@echo " all (default) - Build the eatmemory program"
@echo " install - Install the executable to PREFIX/bin"
@echo " clean - Remove generated files"
@echo " help - Display this help message"

.PHONY: all install clean help

0 comments on commit 397b15e

Please sign in to comment.