Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save sailfish009/6ea7f75e89b03a016f75b85bb24ca486 to your computer and use it in GitHub Desktop.
Simple Makefile for Library
TARGET ?= libbar.so
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 := -L/usr/lib -lstdc++ -lm -shared -Wl,-soname,$(TARGET)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -std=c++11 -fPIC
$(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