Created
April 4, 2023 15:59
-
-
Save abiiranathan/e43dd1540c9c7e2727c70cc7d20dad8b to your computer and use it in GitHub Desktop.
Same make file to simply compile and run C projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = gcc | |
CFLAGS = -Wall -Wextra -std=c11 -O2 | |
LDFLAGS = -lcurl -ljansson -ldotenv | |
SRCDIR = src | |
OBJDIR = obj | |
BINDIR = bin | |
DATADIR = data | |
SRC = $(wildcard $(SRCDIR)/*.c) | |
OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o) | |
EXECUTABLE = $(BINDIR)/ghsearch | |
.PHONY: all clean | |
all: $(EXECUTABLE) | |
$(EXECUTABLE): $(OBJ) | |
$(CC) $^ -o $@ $(LDFLAGS) | |
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(BINDIR) $(DATADIR) | |
$(CC) -c $< -o $@ $(CFLAGS) | |
$(OBJDIR) $(BINDIR) $(DATADIR): | |
mkdir -p $@ | |
clean: | |
rm -rf $(OBJDIR) $(BINDIR) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment