多文件多目录 Makefile文件编写

多文件多目录的Makefile文件编写

文件目录为:

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}
                                                                                                                                                                                            

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值