From bc9d93b549ceb23615cf8ebd6773b1cf207cbe68 Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Thu, 20 Dec 2018 15:53:38 +0800 Subject: [PATCH] Add ch7_library makefile --- ch7_library/src/makefile | 33 ++++++++++++++++ ch7_library/makefile | 18 +++++++++ ch7_library/test/makefile | 20 ++++++++++ 3 files changed, 71 insertions(+), 0 deletions(-) diff --git a/ch7_library/makefile b/ch7_library/makefile new file mode 100644 index 0000000..6b7f9c6 --- /dev/null +++ b/ch7_library/makefile @@ -0,0 +1,18 @@ + +all: + @echo "Start compile library..." + make -C src + @echo "Start compile test program..." + make -C test + +run: + @echo "Start run test program..." + make run -C test + +clean: + make clean -C src + make clean -C test + +distclean: clean + rm -f lib/*.a + rm -f lib/*.so diff --git a/ch7_library/src/makefile b/ch7_library/src/makefile new file mode 100644 index 0000000..2305d13 --- /dev/null +++ b/ch7_library/src/makefile @@ -0,0 +1,33 @@ + +LIBNAME=mycrypto +INSTPATH=`pwd`/../lib/ + +CC=gcc +AR=ar + +all: dynamic_lib static_lib + @make clear + @make install + +dynamic_lib: + ${CC} -shared -fPIC *.c -o lib${LIBNAME}.so + +static_lib: + ${CC} -c *.c + ${AR} -rcs lib${LIBNAME}.a *.o + +install: + cp -rf lib${LIBNAME}.* ${INSTPATH} + cp -rf *.h ${INSTPATH} + +uninstall: + rm -f ${INSTPATH}/lib${LIBNAME}.* + rm -f ${INSTPATH}/*.h + +clear: + rm -f *.o + +clean: clean + rm -f lib${LIBNAME}.* + + diff --git a/ch7_library/test/makefile b/ch7_library/test/makefile new file mode 100644 index 0000000..11facab --- /dev/null +++ b/ch7_library/test/makefile @@ -0,0 +1,20 @@ +APPNAME=test +LIBPATH=`pwd`/../lib/ + +CFLAGS+=-I${LIBPATH} +LDFLAGS+=-L${LIBPATH} +LDFLAGS+=-static + +CC=gcc + +all: + ${CC} ${CFLAGS} main.c -o ${APPNAME} ${LDFLAGS} -lmycrypto + +clean: + rm -f ${APPNAME} + +run: + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:LIBPATH + ./${APPNAME} + + -- Gitblit v1.9.1