Skip to content

Instantly share code, notes, and snippets.

@sailfish009
Created September 19, 2017 11:08
Show Gist options
  • Select an option

  • Save sailfish009/b14d689cedb1b60d757ea3eec45f7b85 to your computer and use it in GitHub Desktop.

Select an option

Save sailfish009/b14d689cedb1b60d757ea3eec45f7b85 to your computer and use it in GitHub Desktop.
Simple Makefile for Application
TARGET ?= a.out
SRC_DIRS ?= ./src
INC_DIRS ?= ./include
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)
LDLIBS := -Wl,-rpath=/foo/lib/ -l:libbar.so -L/usr/lib -lstdc++ -L./lib -lbar
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -std=c++11
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS) $(DEPS)
-include $(DEPS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment