Skip to content

Instantly share code, notes, and snippets.

@SealtielFreak
Created July 19, 2021 16:28
Show Gist options
  • Save SealtielFreak/7bf49e4248c3e6e1d78cc1f5cd7dace6 to your computer and use it in GitHub Desktop.
Save SealtielFreak/7bf49e4248c3e6e1d78cc1f5cd7dace6 to your computer and use it in GitHub Desktop.
Makefile template
CC = g++
CFLAGS = -Wall -std=c++2a -m32 -march=i386
LDFLAGS = -static -static-libstdc++
CLIBS =
SRC = src
OBJ = obj
DEP = include
LIB = lib
SUBDIR = -I$(SRC)/ -I$(DEP)/ -L$(LIB)/
SOURCE := $(wildcard $(SRC)/*/*.cpp)
OBJECTS := $(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(SOURCE))
bin/Program: $(OBJECTS)
$(CC) $^ -o $@ $(CFLAGS) -Os -O3 $(LDFLAGS) $(CLIBS)
bin/Program-d: $(OBJECTS)
$(CC) $^ -o $@ $(CFLAGS) -g $(LDFLAGS) $(CLIBS)
$(OBJ)/%.o: $(SRC)/%.cpp
$(CC) $(SUBDIR) -c $< -o $@
release: bin/Program
debug: bin/Program-d
clean:
rm -rf obj/*.*
.PHONY: bin/Program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment