Android.mk 编译我的 receivetest.so
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE :=libpcan
LOCAL_SRC_FILES :=libpcan.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE :=common
LOCAL_SRC_FILES := common.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE :=receivetest
LOCAL_SRC_FILES := receivetest.c
LOCAL_STATIC_LIBRARIES:=common
LOCAL_SHARED_LIBRARIES:=libpcan
include $(BUILD_SHARED_LIBRARY)
编译 pcan.so.0.6 的外部 Makefile 相当长:
CC := arm-linux-androideabi-gcc
SRC = src
INC = -I. -I../driver
FILES = $(SRC)/libpcan.c
DBG = -g
RT = NO_RT
ifeq ($(RT), XENOMAI)
# Define flags for XENOMAI installation only
#
USB = NO_USB_SUPPORT
PCC = NO_PCCARD_SUPPORT
INC = -I. -I../driver -I/usr/xenomai/include
SKIN = xeno
RT_DIR ?= /usr/xenomai
RT_CONFIG ?= $(RT_DIR)/bin/xeno-config
RT_LIB_DIR ?= $(shell $(RT_CONFIG) --library-dir) -Wl,-rpath $(shell $(RT_CONFIG) --library-dir)
RT_CFLAGS ?= $(shell $(RT_CONFIG) --$(SKIN)-cflags)
endif
ifeq ($(RT), RTAI)
# Define flags for RTAI installation only
#
USB = NO_USB_SUPPORT
PCC = NO_PCCARD_SUPPORT
INC = -I. -I../driver -I/usr/realtime/include
SKIN = lxrt
RT_DIR ?= /usr/realtime
RT_CONFIG ?= $(RT_DIR)/bin/rtai-config
RT_LIB_DIR ?= $(shell $(RT_CONFIG) --library-dir) -Wl,-rpath $(shell $(RT_CONFIG) --library-dir)
RT_CFLAGS ?= $(shell $(RT_CONFIG) --$(SKIN)-cflags)
endif
ifeq ($(HOSTTYPE),x86_64)
LIBPATH = /usr/lib64
else
LIBPATH = /usr/lib
endif
INCPATH = /usr/include
LDNAME = libpcan.so
SONAME = $(LDNAME).0
TARGET = $(SONAME).6
ifneq ($(RT), NO_RT)
CFLAGS = -fPIC -shared -O2 -Wall -Wl,-soname,$(SONAME) -lc $(INC) -D$(RT) $(RT_CFLAGS) -L$(RT_LIB_DIR) -lrtdm
else
CFLAGS = -fPIC -shared -O2 -Wall -Wl,-soname,$(SONAME) -lc $(INC) -D$(RT)
endif
all: $(TARGET)
$(TARGET) : $(FILES)
# ln -sf ../driver/pcan.h pcan.h
$(CC) $(FILES) $(CFLAGS) -o $(TARGET)
ln -sf $(TARGET) $(LDNAME)
clean:
rm -f $(SRC)/*~ $(SRC)/*.o *~ *.so.*
install:
mkdir -p $(DESTDIR)$(LIBPATH)
cp $(TARGET) $(DESTDIR)$(LIBPATH)/$(TARGET)
ln -sf $(DESTDIR)$(LIBPATH)/$(TARGET) $(DESTDIR)$(LIBPATH)/$(SONAME)
ln -sf $(DESTDIR)$(LIBPATH)/$(SONAME) $(DESTDIR)$(LIBPATH)/$(LDNAME)
mkdir -p $(DESTDIR)$(INCPATH)
cp libpcan.h $(DESTDIR)$(INCPATH)/libpcan.h
chmod 644 $(DESTDIR)$(INCPATH)/libpcan.h
ifeq ($(DESTDIR),)
/sbin/ldconfig
endif
uninstall:
@-rm -f $(DESTDIR)$(LIBPATH)/$(TARGET)
@-rm -f $(DESTDIR)$(LIBPATH)/$(SONAME) $(DESTDIR)$(LIBPATH)/$(LDNAME)
@-rm -f $(DESTDIR)$(INCPATH)/libpcan.h
ifeq ($(DESTDIR),)
/sbin/ldconfig
endif
由于 RT = NO_RT 只考虑 ifeq NO_RT 重要的部分。