#!/bin/bash
# 服务器版本 rttys-windows-amd64-3.5.0
# ./build.sh arm-hisiv300-linux
# arm-hisiv300-linux
complex_platform=$1
if [ ! -d "libev" ]; then
# sudo apt install -y libev-dev libssl-dev
git clone https://github.com/enki/libev.git
fi
if [ ! $complex_platform ]; then
echo "please set arm platform"
exit 0
fi
install_dir=$(readlink -f "$(dirname "$0")")/install
echo $install_dir
# complex platform
# eg. arm-linux-gnueabi
cd libev
if [ ! -d "libev/Makefile" ]; then
make distclean
fi
./configure --host=$complex_platform --prefix=$install_dir && make install
cd ..
echo "..................compiler rtty........................."
# cmake . -DCMAKE_C_COMPILER=$complex_platform-gcc -DCMAKE_FIND_ROOT_PATH=$install_dir && make install
make clean
make CROSS_COMPILER=$complex_platform-
option(RTTY_SSL_SUPPORT "SSL support" NOT)
自定义Makefile
CROSS_COMPILER ?= arm-hisiv300-linux-
CXX = $(CROSS_COMPILER)g++
CC = $(CROSS_COMPILER)gcc
STRIP:=$(CROSS_COMPILER)strip
OUTPUT = rtty
#����.h�ļ�·��
INCLUDES := -I ./src
INCLUDES += -I ./src/buffer
INCLUDES += -I ./install/include
#����.so�ļ�·��
LIB_PATH += -L install
LIBS := install/lib/libev.a
CFLAGS += -D_GNU_SOURCE -std=c99 -lutil -lcrypt -lm
# -Werror -Wno-write-strings
DIRS := src
DIRS += src/buffer
SRCS = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.c))
OBJS := $(patsubst %.c, %.o, $(filter %.c, $(SRCS)))
PHONY += all
all: $(OBJS)
@make makeready
$(CXX) $(OS_VERSION) $(CFLAGS) $(SHARED) -o $(OUTPUT) $^ $(LIB_PATH) $(LIBS)
$(STRIP) $(OUTPUT)
#����obj�����·��
PHONY += makeready
makeready:
@echo $(OBJS)
PHONY += clean
clean:
@rm -rf $(OBJS)
$(Q)rm -f $(shell find $(CURDIR) -name "*.d")
.PHONY: $(PHONY)
# 编译规则
%.d: %.cpp
@$(CXX) $(CFLAGS) $(INCLUDES) -MM $< -MT $(basename $@).o -o $(basename $@).d
%.o: %.cpp
@echo "CXX " $@;
@$(CXX) $(CFLAGS) $(INCLUDES) -c $< -o $@
%.d: %.c
@$(CC) $(CFLAGS) $(INCLUDES) -MM $< -MT $(basename $@).o -o $(basename $@).d
%.o: %.c
@echo "CC " $@;
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
-include $(OBJS:.o=.d)