Created
October 21, 2015 17:28
-
-
Save hosackm/49a43ffb448786926028 to your computer and use it in GitHub Desktop.
Makefile for building objects for each source file. It takes too long too get it working when you start from scratch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=clang | |
LIB= | |
INCLUDES=-Iinclude/ | |
FLAGS=-Wall -Werror -pedantic | |
SOURCES=$(wildcard src/*.c) | |
#OBJECTS=$(SOURCES:.c=.o) # This way works too | |
OBJECTS=$(patsubst %.c, %.o, $(SOURCES)) | |
EXE=executable_name.out | |
all: $(EXE) clean | |
$(EXE): $(OBJECTS) | |
$(CC) $(INCLUDES) -o $@ $^ | |
%.o: %.c | |
$(CC) -c $< $(FLAGS) $(LIB) $(INCLUDES) -o $@ | |
clean: | |
rm -rf src/*.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment