Skip to content

Instantly share code, notes, and snippets.

@JakubGrobelny
Created August 15, 2018 00:07
Show Gist options
  • Save JakubGrobelny/8f3a61b138308b171a0dc4c204414686 to your computer and use it in GitHub Desktop.
Save JakubGrobelny/8f3a61b138308b171a0dc4c204414686 to your computer and use it in GitHub Desktop.
Makefile
COMPILER = # FILL # compiler
FLAGS = # FILL # compiler flags
LIBS = # FILL # linked libraries
TARGET = # FILL # name (and path) of the executable
# to use with .cpp change *.c to *.cpp
SRC = $(shell find src -name "*.c")
OBJ = $(patsubst src/%.c, build/%.o, $(SRC))
DEP = $(OBJ:%.o=%.d)
$(TARGET) : $(OBJ)
$(RM) -rf bin
@mkdir -p bin
$(COMPILER) $(FLAGS) -o $(TARGET) $(OBJ) $(LIBS)
-include $(DEP)
build/%.o : src/%.c
@mkdir -p build
@mkdir -p $(dir $@)
$(COMPILER) $(FLAGS) -MMD -c $< -o $@ $(LIBS)
clean:
$(RM) -rf build bin
.PHONY: clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment