Skip to content

Commit 44fc648

Browse files
authored
Merge pull request #2 from Ghost0mega:makefile-init
basic make
2 parents fad0b22 + f02465d commit 44fc648

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Simple GNU Makefile for the project
2+
3+
CC := gcc
4+
CFLAGS := -std=C99 -Wall -Wextra -O2 -g
5+
LDFLAGS :=
6+
7+
SRCDIR := src
8+
BUILDDIR := build
9+
BINDIR := bin
10+
TARGET := htop-clone
11+
12+
SRCS := $(wildcard $(SRCDIR)/*.c)
13+
OBJS := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRCS))
14+
15+
.PHONY: all clean run
16+
17+
all: $(BINDIR)/$(TARGET)
18+
19+
$(BINDIR)/$(TARGET): $(OBJS) | $(BINDIR)
20+
$(CC) $(LDFLAGS) -o $@ $(OBJS)
21+
22+
$(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
23+
$(CC) $(CFLAGS) -c -o $@ $<
24+
25+
$(BUILDDIR) $(BINDIR):
26+
mkdir -p $@
27+
28+
clean:
29+
rm -rf $(BUILDDIR) $(BINDIR)
30+
31+
run: all
32+
./$(BINDIR)/$(TARGET)

bin/htop-clone

16.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)