Welcome to makefiletutorial Discussions! #17
chaselambda
started this conversation in
General
Replies: 2 comments 1 reply
-
Thank you for writing this tutorial! |
Beta Was this translation helpful? Give feedback.
1 reply
-
@theicfire thanks! I wrote a nice Makefile for my projects CC = gcc
CFLAGS = -Wall -Werror -g -I$(INCDIR) -MMD -MP
LDFLAGS = -lglfw -lGL -lX11 -lpthread -lXrandr -lXi -ldl
SRCDIR = src
INCDIR = inc
OUTDIR = out
CFILES = $(shell find $(SRCDIR) -name '*.c')
HFILES = $(shell find $(INCDIR) -name '*.h')
OFILES = $(patsubst $(SRCDIR)%, $(OUTDIR)%, $(patsubst %.c, %.o, $(CFILES)))
APPEXE = $(OUTDIR)/exe
$(APPEXE): $(OUTDIR) $(OFILES)
$(CC) $(OFILES) -o $@ $(LDFLAGS)
$(filter $(OUTDIR)/%.o,$(OFILES)): $(OUTDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(OUTDIR):
mkdir -p $(OUTDIR)
.PHONY: clean
clean:
rm -rf $(OUTDIR)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 Welcome!
If you don't want to make an issue but have something to say, here's a great place!
Beta Was this translation helpful? Give feedback.
All reactions