mid dev 2
This commit is contained in:
38
alarm-snoozer/Makefile
Normal file
38
alarm-snoozer/Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
# Project structure
|
||||
SRCDIR = src
|
||||
BUILDDIR = build
|
||||
TARGET = bin/main
|
||||
|
||||
# Compiler and flags
|
||||
CXX = g++
|
||||
CXXFLAGS = -std=c++11 -Wall -Iinclude
|
||||
LDFLAGS =
|
||||
|
||||
# Find all source files
|
||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||
|
||||
# Generate object file names from source files
|
||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRCS))
|
||||
|
||||
# Default target
|
||||
all: $(TARGET)
|
||||
|
||||
# Link the program
|
||||
$(TARGET): $(OBJS)
|
||||
@mkdir -p $(@D)
|
||||
$(CXX) $(LDFLAGS) -o $@ $^
|
||||
|
||||
# Compile source files into object files
|
||||
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
|
||||
@mkdir -p $(@D)
|
||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
# Clean up
|
||||
clean:
|
||||
rm -rf $(BUILDDIR) bin
|
||||
|
||||
# Run the program
|
||||
run: $(TARGET)
|
||||
./$(TARGET)
|
||||
|
||||
.PHONY: all clean run
|
||||
Reference in New Issue
Block a user