1 2 NDK_BASE := ../.. 3 4 include $(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 9 SOURCES := hellolibrary.c 10 OBJECTS := $(SOURCES:.c=.o) 11 LIBS := -lc -lm 12 ALIB := $(PREBUILT)/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a 13 14 all: 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 20 staticlib: $(OBJECTS) 21 $(AR) -cr libhello-static.a $(OBJECTS) 22 23 sharedlib: 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 26 hellolibrary-shared.o: hellolibrary.c 27 $(CC) -c -fpic $(INC) -o $@ $^ 28 29 clean: 30 rm -rf *.o libhello-static.a libhello-shared.so 31 32