Created
July 26, 2013 20:51
-
-
Save collinprice/6092141 to your computer and use it in GitHub Desktop.
Generic C++ Makefile that needs to include C sources.
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 = gcc | |
CXX = g++ | |
CXXFLAGS = -c -Wall -Wextra -pedantic | |
CCFLAGS = -c | |
LDFLAGS = -lpthread | |
CPP_SRC = main.cpp | |
CPP_SRC_OBJS = $(CPP_SRC:.cpp=.o) | |
CC_SRC = lib.c | |
CC_SRC_OBJS = $(CC_SRC:.c=.o) | |
EXECUTABLE = main | |
all: $(SOURCES) $(EXECUTABLE) | |
$(EXECUTABLE): $(CPP_SRC_OBJS) $(CC_SRC_OBJS) | |
$(CXX) $(CPP_SRC_OBJS) $(CC_SRC_OBJS) -o $@ $(LDFLAGS) | |
.cpp.o: | |
$(CXX) $(CXXFLAGS) $< -o $@ | |
.c.o: | |
$(CC) $(CCFLAGS) $< -o $@ | |
clean: | |
rm -rf $(CPP_SRC_OBJS) $(CC_SRC_OBJS) $(EXECUTABLE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment