1 2NDK_BASE := ../.. 3 4include $(NDK_BASE)/config/config.mk 5 6# Assumes PREBUILT is defined to point to the correct flavor of the prebuilt 7# directory in the Android source tree 8 9SOURCES := hellolibrary.c 10OBJECTS := $(SOURCES:.c=.o) 11LIBS := -lc -lm 12ALIB := $(PREBUILT)/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a 13 14all: sharedlib staticlib 15 16# Using shared and static suffixes as these are going in the same directory; 17# typically you would not do this as you would make only one version, 18# but if we don't we'll screw up the linking because of linker defaults. 19 20staticlib: $(OBJECTS) 21 $(AR) -cr libhello-static.a $(OBJECTS) 22 23sharedlib: hellolibrary-shared.o 24 $(CC) -nostdlib -Wl,-soname,libhello-shared.so -Wl,-shared,-Bsymbolic -L$(NDK_BASE)/lib $^ $(LIBS) -o libhello-shared.so -Wl,--no-undefined $(ALIB) 25 26hellolibrary-shared.o: hellolibrary.c 27 $(CC) -c -fpic $(INC) -o $@ $^ 28 29clean: 30 rm -rf *.o libhello-static.a libhello-shared.so 31 32