Last active
July 6, 2024 19:08
-
-
Save sidewinder040/d34605f4bccfd3bf1e137de3d913910b to your computer and use it in GitHub Desktop.
A More Elegant Makefile Example
This file contains hidden or 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
# Compiler | |
CC = gcc | |
# Compiler flags | |
CFLAGS = -Wall -Wextra -pedantic | |
# Source files | |
SRCS = datecode.c date_validator_helper.c main.c | |
# Object files | |
OBJS = $(SRCS:.c=.o) | |
# Target executable | |
TARGET = datecode | |
# Default target | |
all: $(TARGET) | |
# Link object files | |
$(TARGET): $(OBJS) | |
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) | |
# Compile source files | |
%.o: %.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
# Clean up | |
clean: | |
rm -f $(OBJS) $(TARGET) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment