Skip to content

Instantly share code, notes, and snippets.

@Tiim
Created April 4, 2019 06:51
Show Gist options
  • Save Tiim/f1766d71fd785bdd988b31d7167bab39 to your computer and use it in GitHub Desktop.
Save Tiim/f1766d71fd785bdd988b31d7167bab39 to your computer and use it in GitHub Desktop.
Makefile that compiles every source file to a executable in the bin dir. Conserves data structure.
CC = gcc
OBJDIR = bin
exec = udp/server udp/client tcp/server tcp/client
.PHONY: all clean
all: $(OBJDIR) $(exec)
clean:
rm -r $(OBJDIR)
$(OBJDIR):
mkdir -p $(OBJDIR)
$(exec): %: %.c
mkdir -p $(dir ${OBJDIR}/$@)
$(CC) -o $(OBJDIR)/$@ $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment