summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorpankunull <panku_null@proton.me>2025-08-30 15:08:10 +0200
committerpankunull <panku_null@proton.me>2025-08-30 15:08:10 +0200
commit297e7abf41ec4be028b0a250c16c1ab800963d32 (patch)
tree9fdd00dc3a67f85f9cd8229caeee750ea22a79c2 /Makefile
parent669fcb0b6be1085064267e817764fbb4f578a675 (diff)
Added feature 'all' (-a/--all) to show all processes running on the machine.
Instead of re-writing a new function, a simple flag was added (x->flag).
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 21 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 4dcc90a..af3c7f7 100644
--- a/Makefile
+++ b/Makefile
@@ -2,21 +2,30 @@
CC = gcc
CFLAGS = -Wall -O2
+# Directories
+SRC_DIR = src
+BIN_DIR = bin
+
# Source and target names
TARGET = chproc
-SRC = $(TARGET).c
-PRE = $(TARGET).i
-ASM = $(TARGET).s
-OBJ = $(TARGET).o
+SRC = $(SRC_DIR)/$(TARGET).c
+PRE = $(BIN_DIR)/$(TARGET).i
+ASM = $(BIN_DIR)/$(TARGET).s
+OBJ = $(BIN_DIR)/$(TARGET).o
+BIN = $(BIN_DIR)/$(TARGET)
# Example argument for test
ARG = --list init
# Default: build executable
-all: $(TARGET)
+all: $(BIN)
+
+# Ensure bin directory exists
+$(BIN_DIR):
+ mkdir -p $(BIN_DIR)
# Stage 1: Preprocess
-$(PRE): $(SRC)
+$(PRE): $(SRC) | $(BIN_DIR)
$(CC) -E $(CFLAGS) $< -o $@
# Stage 2: Compile to assembly
@@ -28,7 +37,7 @@ $(OBJ): $(ASM)
$(CC) -c $(CFLAGS) $< -o $@
# Stage 4: Link object to executable
-$(TARGET): $(OBJ)
+$(BIN): $(OBJ)
$(CC) $(CFLAGS) $< -o $@
# Run tests
@@ -38,7 +47,7 @@ define run_test
printf "%s" "$$name"; \
dots=$$((width - $${#name})); \
for i in $$(seq 1 $$dots); do printf "."; done; \
- ./$(TARGET) $(2) >/dev/null 2>&1; \
+ ./$(BIN) $(2) >/dev/null 2>&1; \
ec=$$?; \
if [ $$ec -eq 0 ] || [ $$ec -eq 2 ]; then \
echo " OK"; \
@@ -48,11 +57,11 @@ define run_test
fi
endef
-test: $(TARGET)
- $(call run_test,$(TARGET) no args,)
- $(call run_test,$(TARGET),$(ARG),)
+test: $(BIN)
+ $(call run_test,$(TARGET),no args)
+ $(call run_test,$(TARGET),$(ARG))
# Clean all generated files
clean:
- rm -v -f $(PRE) $(ASM) $(OBJ) $(TARGET)
+ rm -v -f $(BIN_DIR)/$(TARGET).* $(BIN)