Commit 5d540d0a authored by Lucas Russo's avatar Lucas Russo

*Makefile: add "override"" to allow command-line option appending

parent eeb4224a
......@@ -68,57 +68,61 @@ LIBDISPTABLE_DIR = src/libs/libdisptable
LIBBPMCLIENT_DIR = src/libs/libbpmclient
LIBSDBFS_DIR = foreign/libsdbfs
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
ifeq ($(BOARD),afcv3)
ifeq ($(SHRINK_AFCV3_DDR_SIZE),y)
CFLAGS += -D__SHRINK_AFCV3_DDR_SIZE__
CFLAGS_USR += -D__SHRINK_AFCV3_DDR_SIZE__
endif
endif
# Board selection
ifeq ($(BOARD),ml605)
CFLAGS += -D__BOARD_ML605__ -D__WR_SHIFT_FIX__=2
CFLAGS_USR += -D__BOARD_ML605__ -D__WR_SHIFT_FIX__=2
endif
ifeq ($(BOARD),afcv3)
CFLAGS += -D__BOARD_AFCV3__ -D__WR_SHIFT_FIX__=0
CFLAGS_USR += -D__BOARD_AFCV3__ -D__WR_SHIFT_FIX__=0
endif
# Program FMC130M_4CH EEPROM
ifeq ($(FMC130M_4CH_EEPROM_PROGRAM),active)
CFLAGS += -D__FMC130M_4CH_EEPROM_PROGRAM__=1
CFLAGS_USR += -D__FMC130M_4CH_EEPROM_PROGRAM__=1
endif
ifeq ($(FMC130M_4CH_EEPROM_PROGRAM),passive)
CFLAGS += -D__FMC130M_4CH_EEPROM_PROGRAM__=2
CFLAGS_USR += -D__FMC130M_4CH_EEPROM_PROGRAM__=2
endif
# Compile DEV MNGR or not
ifeq ($(WITH_DEV_MNGR),y)
CFLAGS += -D__WITH_DEV_MNGR__
CFLAGS_USR += -D__WITH_DEV_MNGR__
endif
ifeq ($(AFE_RFFE_TYPE),1)
CFLAGS += -D__AFE_RFFE_V1__
CFLAGS_USR += -D__AFE_RFFE_V1__
endif
ifeq ($(AFE_RFFE_TYPE),2)
CFLAGS += -D__AFE_RFFE_V2__
CFLAGS_USR += -D__AFE_RFFE_V2__
endif
# Compile DEVIO Config or not
ifeq ($(WITH_DEVIO_CFG),y)
CFLAGS += -D__WITH_DEVIO_CFG__
CFLAGS_USR += -D__WITH_DEVIO_CFG__
endif
ifneq ($(CFG_DIR),)
CFLAGS += -D__CFG_DIR__=$(CFG_DIR)
CFLAGS_USR += -D__CFG_DIR__=$(CFG_DIR)
endif
ifneq ($(CFG_FILENAME),)
CFLAGS += -D__CFG_FILENAME__=$(CFG_FILENAME)
CFLAGS_USR += -D__CFG_FILENAME__=$(CFG_FILENAME)
endif
# Debug conditional flags
......@@ -194,10 +198,10 @@ INCLUDE_DIRS = $(boards_INCLUDE_DIRS) \
-Iforeign/libsdbfs \
-I/usr/local/include
# Merge all flags.
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output modules
OUT = $(dev_mngr_OUT) $(dev_io_OUT)
......@@ -268,14 +272,14 @@ all: $(PROJECT_LIBS_NAME) cfg $(OUT)
# Output Rule
$(OUT): $$($$@_OBJS) $(revision_OBJS)
$(CC) $(LFLAGS) $(CFLAGS) $(INCLUDE_DIRS) -o $@ $^ $($@_STATIC_LIBS) $(LDFLAGS) $(LIBS) $($@_LIBS) $(PROJECT_LIBS)
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -o $@ $^ $($@_STATIC_LIBS) $(LDFLAGS) $(LIBS) $($@_LIBS) $(PROJECT_LIBS)
# Special rule for the revision object
$(revision_OBJS): $(revision_SRCS)
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -DGIT_REVISION="\"$(GIT_REVISION)\"" \
-DGIT_USER_NAME="\"$(GIT_USER_NAME)\"" \
-DGIT_USER_EMAIL="\"$(GIT_USER_EMAIL)\"" \
-c $< -o $@
-c $< -o $@ $(LDFLAGS)
# Pull in dependency info for *existing* .o files and don't complain if the
# corresponding .d file is not found
......@@ -284,7 +288,7 @@ $(revision_OBJS): $(revision_SRCS)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
......@@ -11,8 +11,12 @@ OBJCOPY ?= $(CROSS_COMPILE)objcopy
SIZE ?= $(CROSS_COMPILE)size
MAKE ?= make
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
LOCAL_MSG_DBG ?= n
DBE_DBG ?= n
......@@ -43,12 +47,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I/usr/local/lib
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
#-Os
LDFLAGS = $(LDFLAGS_PLATFORM)
#-ffunction-sections -fdata-sections -Wl,--gc-sections
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Every .c file will must be a separate example
examples_SRC = $(wildcard *.c)
......@@ -57,7 +59,7 @@ OUT = $(basename $(examples_SRC))
all: $(OUT)
%: %.c
$(CC) $(LFLAGS) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LIBS)
$(CC) $(CFLAGS) $(INCLUDE_DIRS) $^ -o $@ $(LDFLAGS) $(LIBS)
#BAD
clean:
......
......@@ -24,15 +24,19 @@ LIBBPMCLIENT = libbpmclient
# Config variables suitable for creating shared libraries
LIB_VER = $(shell ./version.sh bpm_client)
# General C flags
CFLAGS = -std=gnu99 -O2 -fPIC
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2 -fPIC
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
ifeq ($(BOARD),ml605)
CFLAGS += -D__BOARD_ML605__
CFLAGS_USR += -D__BOARD_ML605__
endif
ifeq ($(BOARD),afcv3)
CFLAGS += -D__BOARD_AFCV3__
CFLAGS_USR += -D__BOARD_AFCV3__
endif
CFLAGS_DEBUG =
......@@ -103,10 +107,10 @@ INCLUDE_DIRS = -I. -Iinclude -I../liberrhand -I../libhutils -I../libdisptable \
-I../../sm_io/modules/afc_diag \
-I/usr/local/include
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output library names
OUT = $(LIBBPMCLIENT)
......@@ -209,7 +213,7 @@ $(revision_OBJS): $(revision_SRCS)
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -DGIT_REVISION="\"$(GIT_REVISION)\"" \
-DGIT_USER_NAME="\"$(GIT_USER_NAME)\"" \
-DGIT_USER_EMAIL="\"$(GIT_USER_EMAIL)\"" \
-c $< -o $@
-c $< -o $@ $(LDFLAGS)
# Pull in dependency info for *existing* .o files and don't complain if the
# corresponding .d file is not found
......@@ -219,7 +223,7 @@ $(revision_OBJS): $(revision_SRCS)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
......@@ -15,8 +15,12 @@ PWD = $(shell pwd)
LIBCONVC = libconvc
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
# To enable this option, use: make ERRHAND_DBG=y
ifneq ($(ERRHAND_DBG),)
......@@ -53,10 +57,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I../liberrhand
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output library names
OUT = $(LIBCONVC)
......@@ -103,7 +107,7 @@ all: $(TARGET_STATIC)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
......@@ -15,8 +15,12 @@ PWD = $(shell pwd)
LIBDISPTABLE = libdisptable
# General C flags
CFLAGS = -std=gnu99 -O2
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
# To enable this option, use: make ERRHAND_DBG=y
ifneq ($(ERRHAND_DBG),)
......@@ -53,10 +57,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I../liberrhand -I../libhutils
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output library names
OUT = $(LIBDISPTABLE)
......@@ -103,7 +107,7 @@ all: $(TARGET_STATIC)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
......@@ -24,8 +24,12 @@ LIB_VER = $(LIB_VER_MAJOR).$(LIB_VER_MINOR).$(LIB_VER_REVISION)
PREFIX ?= /usr/local
export PREFIX
# General C flags
CFLAGS = -std=gnu99 -O2 -fPIC
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2 -fPIC
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
# To enable this option, use: make ERRHAND_DBG=y
ifneq ($(ERRHAND_DBG),)
......@@ -75,10 +79,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I.
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output library names
OUT = $(LIBERRHAND)
......@@ -132,7 +136,7 @@ all: $(TARGET_STATIC) $(TARGET_SHARED_VER)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
......@@ -21,8 +21,12 @@ LIB_VER_MINOR = 0
LIB_VER_REVISION = 0
LIB_VER = $(LIB_VER_MAJOR).$(LIB_VER_MINOR).$(LIB_VER_REVISION)
# General C flags
CFLAGS = -std=gnu99 -O2 -fPIC
# General C/CPP flags
CFLAGS_USR = -std=gnu99 -O2 -fPIC
# We expect tghese variables to be appended to the possible
# command-line options
override CPPFLAGS +=
override CXXFLAGS +=
# To enable this option, use: make ERRHAND_DBG=y
ifneq ($(ERRHAND_DBG),)
......@@ -59,10 +63,10 @@ LFLAGS =
# Include directories
INCLUDE_DIRS = -I. -I../liberrhand
# Merge all flags. Optimize for size (-Os)
CFLAGS += $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG)
LDFLAGS = $(LDFLAGS_PLATFORM)
# Merge all flags. We expect tghese variables to be appended to the possible
# command-line options
override CFLAGS += $(CFLAGS_USR) $(CFLAGS_PLATFORM) $(CFLAGS_DEBUG) $(CPPFLAGS) $(CXXFLAGS)
override LDFLAGS += $(LFLAGS) $(LDFLAGS_PLATFORM)
# Output library names
OUT = $(LIBHUTILS)
......@@ -117,7 +121,7 @@ all: $(TARGET_STATIC) $(TARGET_SHARED_VER)
# Autodependencies generatation by Scott McPeak, November 2001,
# from article "Autodependencies with GNU make"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c $*.c -o $@ $(LDFLAGS)
# create the dependency files "target: pre-requisites"
${CC} -MM $(CFLAGS) $(INCLUDE_DIRS) $*.c > $*.d
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment