1 ########################################################################## 2 include ${HOME}/src/etc/makefile.${GAPSPLATFORM} 3 include ${HOME}/src/etc/${DB}/makefile.${DB} 4 ########################################################################## 5 DATE=`date +"%Y%m%d%H%M"` 6 BUILDDATETIME=$(DATE) 7 RELEASE_VERSION=4.0.0 8 LIBDIR=${HOME}/lib 9 SHLIBDIR=${HOME}/shlib10 BINDIR=${HOME}/bin11 LIBINCL=${HOME}/libincl12 INCL=${HOME}/incl13 ###########################################################################14 INCLUDE=-I${HOME}/app/agent/incl -I${HOME}/app/batch/incl -I${HOME}/app/app/incl15 APPEH_INCL=include=${HOME}/app/agent/incl include=${HOME}/app/batch/incl include=${HOME}/app/app/incl16 APPLIBDIR=-L${HOME}/app/agent/lib17 ###########################################################################18 DEBUG=${MOS} -DBUILDDATETIME=\"$(BUILDDATETIME)\"19 CC=cc ${OS_CCFLAG}20 VPATH=.libs21 all : SUPDATE.so22 .SUFFIXES: .c .lo23 .c.lo:24 libtool --mode=compile --tag=CC ${CC} -g -O ${DEBUG} ${DBS} ${MOS} ${DB_CCFLAGS} ${CCFLAG} -I$(LIBINCL) -I${INCL} -I$(INCLUDE) -c $<25 SUPDATE.so: SUPDATE.lo26 libtool --mode=link --tag=CC ${CC} ${LDFLAG} -g -O -o $(@:.so=.la) $? -rpath ${SHLIBDIR} -release ${RELEASE_VERSION} -export-dynamic -no-undefined -module -L${LIBDIR} ${DB_LIBS} ${APPLIBDIR} -lsha -lsxml -lhsbase -lgapssfs -lgapssql -ldci -lc27 install-shlib.sh SUPDATE.la ${SHLIBDIR} upd
The above is a MAKEFILE file I have compiled. It's wrong. Haha, it's someone else's.
Let's talk about some of my notes:
1. What is makefile? It specifies the compilation rules of files in a project, including the compilation sequence and how to compile the files.
2. Row 14th has a "-I" or "-- include-Dir" parameter, and make will search for it in the directory specified by this parameter.
3. Line 20th vpath =. libs so that make will find the file in the specified directory. libs if the current directory cannot be found.
4. Row 24th libtool -- mode = compile -- tag = Cc $ {CC}-g-o $ {debug}
This is the use of libtool for compilation to generate output files such as *. O.
5. Row 26th libtool -- mode = link -- tag-rpath $ {shlibdir}
Create a dynamic library. -Generate a dynamic library using rpath and a static library using dynamic.
6. Row 27th install-shlib.sh supdate. La $ {shlibdir} UPD
Install the dynamic library. You can directly compile and execute make later ~
Ah, sorry, you have to add the reference documentation at the end ~~ Http://www.baike.com/wiki/libtool
Get started with makefile