Build its shared library
######################################
# makefile shared library
######################################
# set your all envrionment.
CC=g++
CC_FLAGS=-D_FILELINE
SRCS=$(wildcard *.cpp */*.cpp)
# set your all inc and lib
INCS=-I.
LIBS=-lpthread -L.
#make taget lib and relevent obj
TARGET=libxxdk.so
OBJS=$(patsubst %.cpp, %.o, $(SRCS))
#all target
all:$(TARGET)
$(TARGET):$(OBJS)
$(CC) -shared -o $@ $^ $(LIBS)
%.o:%.cpp
$(CC) $(CC_FLAGS) $(INCS) -c -fpic $< -o $@ -g
clean:
rm -rf $(TARGET) $(OBJS)
Compile static library
######################################
# makefile static library
######################################
# set your all envrionment.
CC=g++
AR=ar
CC_FLAGS=-D_FILELINE
SRCS=$(wildcard *.cpp */*.cpp)
# set your all inc and lib
INCS=-I.
LIBS=-lpthread -L.
#make taget lib and relevent obj
TARGET=libxxdk.a
OBJS=$(patsubst %.cpp, %.o, $(SRCS))
#all target
all:$(TARGET)
$(TARGET):$(OBJS)
$(AR) crv $@ $^
%.o:%.cpp
$(CC) $(CC_FLAGS) $(INCS) $(LIBS) -c $< -o $@ -g
.PHONY: clean
clean:
rm -rf $(TARGET) $(OBJS)
Compiled executable file
######################################
# makefile executable
######################################
# set your all envrionment.
CC=g++
CC_FLAGS=-D_FILELINE
SRCS=$(wildcard *.cpp */*.cpp)
# set your all inc and lib
INCS=-I.
LIBS=-lpthread -L.
#make taget lib and relevent obj
TARGET=xxdk
OBJS=$(patsubst %.cpp, %.o, $(SRCS))
#all target
all:$(TARGET)
$(TARGET):$(OBJS)
$(CC) -o $@ $^
%.o:%.cpp
$(CC) $(CC_FLAGS) $(INCS) $(LIBS) -c $< -o $@ -g
.PHONY: clean
clean:
rm -rf $(TARGET) $(OBJS)