【问题标题】:write dependency rule in makefile for project that use AM_LDFLAGS在 makefile 中为使用 AM_LDFLAGS 的项目编写依赖规则
【发布时间】:2014-12-27 19:06:58
【问题描述】:

我想为我的项目编写依赖规则,因为项目包含 src 目录,src 文件夹包含依赖于 file1.c 的 main.c 和 file1.c 依赖于 file2.c 我有非标准库目录和非标准包含目录 我使用 AM_CFLAGS = /path 来包含目录和 AM_LDFLAGS = lib 目录的路径 我想制定通用依赖规则 我试过玩

depend:
     makedepend $(AM_CFLAGS) $(SRC_DIR) 

但它抱怨它使用的库,所以我想制定通用依赖规则,以便在任何人添加新文件或更改文件中的某些内容时不重写规则

这里是src目录的makefile:

   program_NAME := SRR

    AM_CPPFLAGS = \
       -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
       -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
       -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"


  bin_PROGRAMS = SRR_AutoProject

  program_INCLUDE_DIRS := /usr/bin/SRR__bin

  program_LIBRARY_DIRS := /usr/lib/SRR__lib

  AM_CFLAGS = 

  AM_CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))

  program_lib2 := \
         SRR___wrapper_library__ml \
         srrynarray \
         prhash \
         prhash_pic \
         prhistogram \
         prlistofarrays \
         vreo_wrapper_library 
 AM_LDFLAGS = 

 AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))

 AM_LDFLAGS += $(foreach library,$(program_lib2),-l$(library))

 SRR_AutoProject_SOURCES = \
         main.c \
         file1.c \
         file2.c

  depend: 
     makedepend $(AM_CFLAGS) $(SRR_AutoProject_SOURCES)

根目录的makefile如下图:

    SUBDIRS = src

    SRR_AutoProjectdocdir = ${prefix}/doc/PRDSL_AutoProject
    SRR_AutoProjectdoc_DATA = \
          README\
          COPYING\
          AUTHORS\
          ChangeLog\
          INSTALL\
          NEWS


    INTLTOOL_FILES = intltool-extract.in \
           intltool-merge.in \
           intltool-update.in

    EXTRA_DIST = $(PRDSL_AutoProjectdoc_DATA) \
           $(INTLTOOL_FILES)

      DISTCLEANFILES = intltool-extract \
           intltool-merge \
           intltool-update \
           po/.intltool-merge-cache


     # Remove doc directory on uninstall
      uninstall-local:
           -rm -r $(PRDSL_AutoProjectdocdir)

【问题讨论】:

    标签: c makefile dependencies autotools


    【解决方案1】:
    here is a makedepend rule, extracted from:
    <http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html>
    
    INCLUDES := -I/home/newhall/include  -I../include
    SRCS := $(wildcard:*.c)
    
    .PHONY: depend
    
    depend: $(SRCS)
        makedepend $(INCLUDES) $^
    
    # DO NOT DELETE THIS LINE -- make depend needs it
    

    【讨论】:

    • 谢谢,但是 LDFLAGS 呢?
    猜你喜欢
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    • 2014-01-23
    • 1970-01-01
    相关资源
    最近更新 更多