NDK의 Makefile을 사용하지 않는 간단버전의 Makefile, target은 so파일

# tool chain setting
ANDROID_NDK16=c:\andoird\android-ndk-1.6_r1
NDKROOT:=$(shell cygpath -u '$(ANDROID_NDK16)')
SYSROOT:=$(NDKROOT)/build/platforms/android-4/arch-arm
TOOLCHAINDIR:=$(NDKROOT)/build/prebuilt/windows/arm-eabi-4.2.1/bin
CC:=$(TOOLCHAINDIR)/arm-eabi-gcc.exe
CXX:=$(TOOLCHAINDIR)/arm-eabi-g++.exe
AR:=$(TOOLCHAINDIR)/arm-eabi-ar.exe
LD:=$(TOOLCHAINDIR)/arm-eabi-ld.exe

TARGET_LIBGCC := $(shell $(CC) -mthumb-interwork -print-libgcc-file-name)
TARGET_LDLIBS := -Wl,-rpath-link=$(SYSROOT)/usr/lib $(TARGET_LIBGCC)
TARGET_CRTBEGIN_STATIC_O  := $(SYSROOT)/usr/lib/crtbegin_static.o
TARGET_CRTBEGIN_DYNAMIC_O := $(SYSROOT)/usr/lib/crtbegin_dynamic.o
TARGET_CRTEND_O := $(SYSROOT)/usr/lib/crtend_android.o
STDLIBS=c m stdc++
TARGET_SHARED_LIBRARIES:=$(foreach STDLIBS, $(STDLIBS), $(SYSROOT)/usr/lib/lib$(STDLIBS).so)
TARGET_STATIC_LIBRARIES:=$(foreach STDLIBS, $(STDLIBS), $(SYSROOT)/usr/lib/lib$(STDLIBS).a)
INCLUDE:=-I$(SYSROOT)/usr/include

CFLAGS+=-c $(DEFINE) $(INCLUDE) \
    -march=armv5te -mtune=xscale \
    -msoft-float -fpic \
    -mthumb-interwork \
    -ffunction-sections \
    -funwind-tables \
    -fstack-protector \
    -fno-short-enums \
    -fshort-wchar \
    -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
ifeq ($(DEBUG),y)
    CFLAGS+= -O0 -g
else
    CFLAGS+= -O2
endif
LDFLAGS=-nostdlib -Wl,-soname,$(notdir $@) \
    -Wl,-shared,-Bsymbolic \
    -Wl,--no-whole-archive \
    $(TARGET_LDLIBS) \
    -Wl,--whole-archive -o

# source setting
EXCLUDES:=
SRCDIR:=../src \
    ../test/src
CSRCS:=$(foreach SRCDIR, $(SRCDIR), $(filter-out $(EXCLUDES), $(wildcard $(SRCDIR)/*.c)))
OBJS=$(CSRCS:.c=.o)
TARGET=libTest.so

INCLUDE+=
CFLAGS+=
LIBFILES+=

# label
%.o: %.c
    $(CC) $(CFLAGS) -o $@ $<

all: $(TARGET)
   
$(TARGET): $(OBJS)
        $(CC) $(LDFLAGS) $@ $(OBJS) $(LIBFILES)

clean:
    rm $(OBJS) $(TARGET)

저작자 표시 비영리
신고
Posted by NOP 트랙백 0 : 댓글 0

티스토리 툴바