Skip to content

Instantly share code, notes, and snippets.

@erfg12
Created August 16, 2021 18:08
Show Gist options
  • Save erfg12/6d6852df7d69e589f308371d2cc0b9af to your computer and use it in GitHub Desktop.
Save erfg12/6d6852df7d69e589f308371d2cc0b9af to your computer and use it in GitHub Desktop.
C GCC makefile
# [Windows] Install MinGW (https://sourceforge.net/projects/mingw), add C:\MinGW\bin to Environment Variables PATH. Run command mingw32-make
# [MacOS] https://discussions.apple.com/thread/5250041
# [Ubuntu] "sudo apt install build-essential"
EXECUTABLE = main
CC = "gcc"
LDFLAGS = -lgdi32
src = $(wildcard *.c)
obj = $(src:.c=.o)
all: myprog
myprog: $(obj)
$(CC) -o $(EXECUTABLE) $^ $(LDFLAGS)
.PHONY: clean
clean:
del $(obj) $(EXECUTABLE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment