Skip to content

Instantly share code, notes, and snippets.

@activedecay
Last active January 1, 2019 21:56
Show Gist options
  • Save activedecay/78d05a50cf13465819257e87a6124072 to your computer and use it in GitHub Desktop.
Save activedecay/78d05a50cf13465819257e87a6124072 to your computer and use it in GitHub Desktop.
god-like makefile, thanks Beta
# c
# ├── Makefile
# ├── obj
# └── src
# ├── lib.c
# ├── lib.h
# └── server.c
EXE := doit
SRC := src
OBJ := obj
SOURCES := $(wildcard $(SRC)/*.c)
OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES))
.PHONY: all clean
all: $(EXE)
$(EXE): $(OBJECTS)
$(CC) $^ -o $@
$(OBJ)/%.o: $(SRC)/%.c
$(CC) -I$(SRC) -c $< -o $@
clean: $(EXE) $(OBJECTS)
rm $^
@activedecay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment