Automake: change implicity make rule to include additional flags

How to add additional flag variables (e.g. CPPFLAGS) that will apply to all makefiles? We are currently using CPPFLAGS, but this should be reserved as a user variable, and I would like to reserve it. I would prefer not to use AM_CPPFLAGS because I would like to reserve this for a specific Makefile.amS. I want something like GLOBAL_CPPFLAGS that I could install in configure.ac and apply it to everything. It would also be nice if there was a way to explicitly ignore the flag.

I think what I need to do is to write my own make rule, but how would I make it available in all subfolders without copying it to each Makefile.am?

+3
source share
3 answers

You are not using it correctly CPPFLAGS. This is a variable. I would do something like this:

In the root directory of the source source, create a file with the name common.amand determine what you need:

## common.am
AM_CPPFLAGS = -DFOO

I know that you said you did not want to use it AM_CPPFLAGS, but listen to me. In your individual subdirectories include $(top_srcdir)/common.amand extend or redefine AM_CPPFLAGSas necessary:

## bar/Makefile.am
include $(top_srcdir)/common.am
AM_CPPFLAGS += -DBAR

If you want to override, use =instead +=:

## baz/Makefile.am
include $(top_srcdir)/common.am
AM_CPPFLAGS = -DBAZ
+4
source

I think you answered your question: you will need to copy a new rule into each make file.

+1
source

CPPFLAGS - , , , . , - configure.ac:

GLOBAL_CPPFLAGS = "- DSOMETHING"

...

CPPFLAGS = "$ CPPFLAGS $ GLOBAL_CPPFLAGS"

and you must be installed.

0
source

Source: https://habr.com/ru/post/1769013/


All Articles