Created
September 19, 2017 11:10
-
-
Save sailfish009/6ea7f75e89b03a016f75b85bb24ca486 to your computer and use it in GitHub Desktop.
Simple Makefile for Library
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
| 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