APUE Learning Example Source Code
guowenxue
2018-12-20 bc9d93b549ceb23615cf8ebd6773b1cf207cbe68
Add ch7_library makefile
3 files added
71 ■■■■■ changed files
ch7_library/makefile 18 ●●●●● patch | view | raw | blame | history
ch7_library/src/makefile 33 ●●●●● patch | view | raw | blame | history
ch7_library/test/makefile 20 ●●●●● patch | view | raw | blame | history
ch7_library/makefile
New file
@@ -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
ch7_library/src/makefile
New file
@@ -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}.*
ch7_library/test/makefile
New file
@@ -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}