I have seen this makefiles and also able to create my own make files but the case i want is not into this makefiles.
below are my two makefile.
1. for creating support for a target xyz
include $(TOPDIR)/rules.mk
PKG_NAME:=xyz
PKG_RELEASE:=1
PKG_VERSION:=2
TARGET_LIBS = -Wl,-Bstatic -lpthread
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
TITLE:= xyz
DEPENDS:=@TARGET_ramips_rt305x_a||@TARGET_ramips_rt305x_b +libpthread +librt
endef
define Package/$(PKG_NAME)/description
This is a sample program for make
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
mkdir -p $(PKG_BUILD_DIR)/obj $(PKG_BUILD_DIR)/bin
endef
define Package/$(PKG_NAME)/Build/Configure
endef
define Package/$(PKG_NAME)/Build/Compile
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LIBS="$(TARGET_LIBS)" \
$(MAKE) -C $(PKG_BUILD_DIR) $(PKG_NAME)
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/$(PKG_NAME) $(1)/usr/bin/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
2nd make file is the makefile to compile the target
PKG_RELEASE:=0
PKG_VERSION:=2
IDIR=./inc
ODIR=./obj
BIN=./bin
SRC=./src
TARGET=xyz
CC=gcc
CFLAGS=-I$(IDIR) -lpthread -lrt -lm
DFLAGS=-DABC -DDEBUG
_SRC := $(shell ls $(SRC))
_DEPS := $(shell ls $(IDIR))
DEPS=$(_DEPS:%=$(IDIR)/%)
_OBJS=$(_SRC:%.c=%.o)
OBJS=$(_OBJS:%=$(ODIR)/%)
$(ODIR)/%.o: $(SRC)/%.c $(DEPS)
$(CC) -c -Wall -o $@ $< $(CFLAGS) $(DFLAGS)
$(BIN)/$(TARGET): $(OBJS)
$(CC) -Wall -o $@ $^ $(CFLAGS) $(DFLAGS)
all: $(BIN)/$(TARGET)
clean:
rm -rf $(BIN)/$(TARGET) $(ODIR)/*
My concern is that in second makefile
if TARGET_ramips_rt305x_a is set to y then DFLAGS=-DABC -DDEBUG has to be set before compiling
if TARGET_ramips_rt305x_b is set to y then DFLAGS=-DBCD -DDEBUG has to be set before compiling
How can i do this?