Skip to content

Instantly share code, notes, and snippets.

@garlic0x1
Last active December 3, 2023 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garlic0x1/4ef856572e7303c3a2fe3e53b0de9471 to your computer and use it in GitHub Desktop.
Save garlic0x1/4ef856572e7303c3a2fe3e53b0de9471 to your computer and use it in GitHub Desktop.
C Makefile
##
# Project Title
#
# @file
# @version 0.1
CC=gcc
CFLAGS=-g -Wall
PROGNAME=CHANGEME
INSTALLDIR=~/.local/bin
BINDIR=bin
BIN=$(BINDIR)/$(PROGNAME)
SRC=src
OBJ=obj
SRCS=$(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
all: $(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(BIN)
$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@
install: $(BIN)
cp $(BIN) $(INSTALLDIR)/$(PROGNAME)
clean:
rm -r $(BINDIR)/*
rm -r $(OBJ)/*
run: $(BIN)
$(BIN)
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment