Last active
December 3, 2023 06:17
-
-
Save garlic0x1/4ef856572e7303c3a2fe3e53b0de9471 to your computer and use it in GitHub Desktop.
C Makefile
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
## | |
# 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