Skip to content

Instantly share code, notes, and snippets.

@lordofwizard
Last active November 25, 2022 04:15
Show Gist options
  • Save lordofwizard/7680c58e41c8fa5232377d920cd154ec to your computer and use it in GitHub Desktop.
Save lordofwizard/7680c58e41c8fa5232377d920cd154ec to your computer and use it in GitHub Desktop.
A Basic Template for SDL Application that will be used in all of my projects throughout CG...!

Basic implementation of Makefile

note there are certain things you should know before starting

  1. You need the proper directory structure i.e (src/ bin/ obj/ Makefile assets/ bin/assets/)
    Read the Make file if you don't get it.. lol
CPP=g++
CPPFLAGS=-g -Wall $(shell sdl2-config --cflags)
LDFLAGS=$(shell sdl2-config --libs)

SRC=src
OBJ=obj
SRCS=$(wildcard $(SRC)/*.cpp)
OBJS=$(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(SRCS))
HDRS=$(wildcard $(SRC)/*.h)
BIN=program

all:	$(BIN)

$(BIN): $(OBJS) $(OBJ)
	$(CPP) $(CPPFLAGS) $(OBJS) -o $@ $(LDFLAGS)
	
$(OBJ)/%.o: $(SRC)/%.cpp $(OBJ)
	$(CPP) $(CPPFLAGS) -c $< -o $@

$(OBJ):
	mkdir -p $@

clean:
	$(RM) -r $(OBJ)
	$(RM) $(BIN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment