文件目录为:
stu_sys
|-- Makefile
|-- include
| |-- other
| | `-- other.h
| |-- student
| | `-- student.h
| |-- student_public.h
| `-- teacher
| `-- teacher.h
|-- src
| |-- Makefile
| |-- lib
| | |-- Makefile
| | |-- other
| | | `-- other.c
| | |-- student
| | | |-- Makefile
| | | `-- student.c
| | `-- teacher
| | `-- teacher.c
| `-- scli
| |-- Makefile
| |-- other
| | |-- Makefile
| | |-- other
| | |-- other.c
| | `-- other.db
| |-- student
| | |-- Makefile
| | |-- student
| | |-- student.c
| | `-- student.db
| `-- teacher
| |-- Makefile
| |-- teacher
| |-- teacher.c
| `-- teacher.db
`-- target
|-- other
| `-- other
|-- student
| `-- student
`-- teacher
`-- teacher
stu_sys目录中的Makefile文件编写为:
STUDENT = /root/xiangm/stu_sys/src/scli/student/student
TEACHER = /root/xiangm/stu_sys/src/scli/teacher/teacher
OTHER = /root/xiangm/stu_sys/src/scli/other/other
STALLS = /root/xiangm/stu_sys/target/student/
STALLT = /root/xiangm/stu_sys/target/teacher/
STALLO = /root/xiangm/stu_sys/target/other/
ALL:
make -C src
install:
cp $(STUDENT) $(STALLS)
cp $(TEACHER) $(STALLT)
cp $(OTHER) $(STALLO)
~
-----------------------------------------------------------------------------------------------------------------------------------
src目录中的Makefile文件编写为:
SUBDIRS = lib scli
SRC:
make -C scli
~
-----------------------------------------------------------------------------------------------------------------------------------
lib文件目录中的Makefile编写为:
SUBDIRS = student teacher other
release:
for I in $(SUBDIRS); do \
make -C $$I; \
done
~----------------------------------------------------------------------------------------------------------------------------
scli 目录中的Makefile文件编写为:
SUBDIRS = student teacher other
SCLI:
for I in ${SUBDIRS}; do \
make -C $$I || exit 1;\
done
~
-----------------------------------------------------------------------------------------------------------------------------
student目录下编写的Makefile文件为:
STUDENTC = /root/xiangm/stu_sys/src/lib/student/student.c
STUDENTH = /root/xiangm/stu_sys/include/
STUDENTH1 = /root/xiangm/stu_sys/include/student
STUDENT:
gcc -o student student.c ${STUDENTC} -I ${STUDENTH} -I ${STUDENTH1}
--------------------------------------------------------------------------------------------------------------------------------
teacher目录下变编写的Makefile文件为:
TEACHERC = /root/xiangm/stu_sys/src/lib/teacher/teacher.c
TEACHERH = /root/xiangm/stu_sys/include/
TEACHERH1 = /root/xiangm/stu_sys/include/teacher
TEACHER:
gcc -o teacher teacher.c ${TEACHERC} -I ${TEACHERH} -I ${TEACHERH1}
-------------------------------------------------------------------------------------------------------------------------------
OTHERC = /root/xiangm/stu_sys/src/lib/other/other.c
OTHERH = /root/xiangm/stu_sys/include
OTHERH1 = /root/xiangm/stu_sys/include/other
OTHER:
gcc -o other other.c ${OTHERC} -I ${OTHERH} -I ${OTHERH1}