Skip to content

Commit 80886b7

Browse files
Append to ERLC_FLAGS with override for autodetects
Use override ERLC_FLAGS += -D<...> instead of this (without override) ERLC_FLAGS += -D<...> ...but do it only for features that are auto-detected from what the current Erlang supports. These defintions are often used to indicate that some feature is missing, for example when using an older version of Erlang. The "override" makes it possible to specify additional ERLC_FLAGS on the command line and still get any auto-detected definitions, like this: make ERLC_FLAGS=-Dmy_flag=x and (on an older Erlang) it might then compile with: erlc -Dmy_flag=x -DNO_HAVE_ERL20_STR_FUNCTIONS=true gpb_some_file.erl
1 parent fbda672 commit 80886b7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ endif
9696
endif
9797

9898

99-
ERLC_FLAGS += -Wall +debug_info -I$(incdir)
99+
ERLC_FLAGS ?= -Wall +debug_info
100+
override ERLC_FLAGS += -I$(incdir)
100101

101102
ERL_BATCH_FLAGS = +B -noshell -noinput
102103

@@ -131,7 +132,7 @@ plt = $(GPB_PREFIX).gpb-$(OTP_MAJOR_MINOR).plt
131132

132133

133134
ifdef NO_HAVE_MAPS
134-
ERLC_FLAGS += -DNO_HAVE_MAPS=true
135+
override ERLC_FLAGS += -DNO_HAVE_MAPS=true
135136
else
136137
## attempt to auto-detect
137138
ERLVM_SUPPORTS_MAPS := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
@@ -142,12 +143,12 @@ ERLVM_SUPPORTS_MAPS := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
142143
receive after 10 -> ok end.' \
143144
-s erlang halt)
144145
ifeq ($(ERLVM_SUPPORTS_MAPS),false)
145-
ERLC_FLAGS += -DNO_HAVE_MAPS=true
146+
override ERLC_FLAGS += -DNO_HAVE_MAPS=true
146147
endif
147148
endif
148149

149150
ifdef NO_HAVE_RAND
150-
ERLC_FLAGS += -DNO_HAVE_RAND=true
151+
override ERLC_FLAGS += -DNO_HAVE_RAND=true
151152
else
152153
## attempt to auto-detect
153154
ERL_HAS_RAND := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
@@ -158,12 +159,12 @@ ERL_HAS_RAND := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
158159
receive after 10 -> ok end.' \
159160
-s erlang halt)
160161
ifeq ($(ERL_HAS_RAND),false)
161-
ERLC_FLAGS += -DNO_HAVE_RAND=true
162+
override ERLC_FLAGS += -DNO_HAVE_RAND=true
162163
endif
163164
endif
164165

165166
ifdef NO_HAVE_ERL20_STR_FUNCTIONS
166-
ERLC_FLAGS += -DNO_HAVE_ERL20_STR_FUNCTIONS=true
167+
override ERLC_FLAGS += -DNO_HAVE_ERL20_STR_FUNCTIONS=true
167168
else
168169
## attempt to auto-detect
169170
ERL_HAS_ERL20_STR_FUNCTIONS := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
@@ -174,7 +175,7 @@ ERL_HAS_ERL20_STR_FUNCTIONS := $(shell $(ERL) $(ERL_BATCH_FLAGS) -eval ' \
174175
receive after 10 -> ok end.' \
175176
-s erlang halt)
176177
ifeq ($(ERL_HAS_ERL20_STR_FUNCTIONS),false)
177-
ERLC_FLAGS += -DNO_HAVE_ERL20_STR_FUNCTIONS=true
178+
override ERLC_FLAGS += -DNO_HAVE_ERL20_STR_FUNCTIONS=true
178179
endif
179180
endif
180181

0 commit comments

Comments
 (0)