We have slave target board that is based on Freescale HCS1
Microcontroller. This target board is installed in our machines. Up t
now, we have identical source files and common executable for all Thre
machines, Machine1, Machine2, and Machine3.
The following makefile.mk is used to build common executable for all Thre
machines.
#************************************************* ******************************
# Description: This file contains the makefile for the executable
# application for the HCS12 based target.
#
#************************************************* ******************************
# SOFTWARE DEVELOPMEN
TOOLS_____________________________________________ _______
include ..\..\..\..\app\program\relay_module\src\tools.mk
# MODUL
INCLUDES__________________________________________ _____________________
# Include any module-specific build options specifications files here.
#Makefile
MAKEFILE = makefile.mk
FLS_FLAGS = -s -b -v -l
# Module directory name.
MOD_DIR = ..\..\..\..\app\program\relay_module
# Source files directory name.
SRC_DIR = $(MOD_DIR)\src
SRC_EH_DIR = $(MOD_DIR)\src_eh
SRC_APP_NUM_DIR = $(MOD_DIR)\src_app_num
SRC_DIAG_DIR = $(MOD_DIR)\src_diag
SRC_UTILITY_DIR = $(MOD_DIR)\src_utility
SRC_SHUTDOWN_DIR = $(MOD_DIR)\src_shutdown
SRC_CAN_DIR = $(MOD_DIR)\src_can
SRC_KEY_DIR = $(MOD_DIR)\src_keypad
SRC_LIGHT_DIR = $(MOD_DIR)\src_lights
SRC_BATT_DIR = $(MOD_DIR)\src_batt_mngmt
APP_INCL_PATH_1 = $(MOD_DIR)\include
APP_INCL_PATH_2 = $(MOD_DIR)\include_eh
APP_INCL_PATH_3 = $(MOD_DIR)\include_hal
APP_INCL_PATH_4 = $(MOD_DIR)\include_app_num
APP_INCL_PATH_5 = $(MOD_DIR)\include_diag
APP_INCL_PATH_6 = $(MOD_DIR)\include_utility
APP_INCL_PATH_7 = $(MOD_DIR)\include_shutdown
APP_INCL_PATH_8 = $(MOD_DIR)\include_can
APP_INCL_PATH_9 = $(MOD_DIR)\include_keypad
APP_INCL_PATH_10 = $(MOD_DIR)\include_lights
APP_INCL_PATH_11 = $(MOD_DIR)\include_batt_mngmt
# Linker file.
LNK_FILE = $(SRC_DIR)\app.dld
# Filename (minus the extension) of the main target.
TARGET = $(MOD_DIR)\exe\relay_module
# Define all the source files to include.
C_FILES = $(SRC_DIR)\file1.c \
$(SRC_DIR)\file2.c \
$(SRC_EH_DIR)\file3.c \
$(SRC_EH_DIR)\file4.c \
$(SRC_EH_DIR)\file5.c \
$(SRC_EH_DIR)\file6.c \
$(SRC_EH_DIR)\file7.c \
$(SRC_EH_DIR)\file8.c \
$(SRC_EH_DIR)\file9.c \
$(SRC_EH_DIR)\file10.c \
$(SRC_EH_DIR)\file11.c \
$(SRC_EH_DIR)\file12.c \
$(SRC_EH_DIR)\file13.c \
$(SRC_EH_DIR)\file14.c \
$(SRC_EH_DIR)\file15.c \
$(SRC_EH_DIR)\file16.c \
$(SRC_EH_DIR)\file17.c \
$(SRC_EH_DIR)\file18.c \
$(SRC_EH_DIR)\file19.c \
$(SRC_EH_DIR)\file20.c \
$(SRC_EH_DIR)\file21.c \
$(SRC_EH_DIR)\file22.c \
$(SRC_EH_DIR)\file23.c \
$(SRC_EH_DIR)\file24.c \
$(SRC_EH_DIR)\file25.c \
$(SRC_EH_DIR)\file26.c \
$(SRC_EH_DIR)\file27.c \
$(SRC_EH_DIR)\file28.c \
$(SRC_EH_DIR)\file29.c \
$(SRC_EH_DIR)\file30.c \
$(SRC_EH_DIR)\file31.c \
$(SRC_EH_DIR)\file32.c \
$(SRC_EH_DIR)\file33.c \
$(SRC_EH_DIR)\file34.c \
$(SRC_EH_DIR)\file35.c \
$(SRC_EH_DIR)\file36.c \
$(SRC_EH_DIR)\file37.c \
$(SRC_EH_DIR)\file38.c \
$(SRC_EH_DIR)\file39.c \
$(SRC_EH_DIR)\file40.c \
$(SRC_EH_DIR)\file41.c \
$(SRC_EH_DIR)\file42.c \
$(SRC_EH_DIR)\file43.c \
$(SRC_EH_DIR)\file44.c \
$(SRC_EH_DIR)\file45.c \
$(SRC_EH_DIR)\file46.c \
$(SRC_EH_DIR)\file47.c \
$(SRC_EH_DIR)\file48.c \
$(SRC_EH_DIR)\file49.c \
$(SRC_EH_DIR)\file50.c \
$(SRC_EH_DIR)\file51.c \
$(SRC_EH_DIR)\file52.c \
$(SRC_EH_DIR)\file53.c \
$(SRC_EH_DIR)\file54.c \
$(SRC_EH_DIR)\file55.c \
$(SRC_EH_DIR)\file56.c \
$(SRC_EH_DIR)\file57.c \
$(SRC_EH_DIR)\file58.c \
$(SRC_EH_DIR)\file59.c \
$(SRC_EH_DIR)\file60.c \
$(SRC_APP_NUM_DIR)\file61.c \
$(SRC_APP_NUM_DIR)\file62.c \
$(SRC_APP_NUM_DIR)\file63.c \
$(SRC_APP_NUM_DIR)\file64.c \
$(SRC_APP_NUM_DIR)\file65.c \
$(SRC_EH_DIR)\file66.c \
$(SRC_EH_DIR)\file67.c \
$(SRC_EH_DIR)\file68.c \
$(SRC_EH_DIR)\file69.c \
$(SRC_EH_DIR)\file70.c \
$(SRC_EH_DIR)\file71.c \
$(SRC_UTILITY_DIR)\file72.c \
$(SRC_UTILITY_DIR)\file73.c\
$(SRC_CAN_DIR)\file74.c \
$(SRC_CAN_DIR)\file75.c \
$(SRC_DIR)\file76.c \
$(SRC_CAN_DIR)\file77.c \
$(SRC_CAN_DIR)\file78.c \
$(SRC_CAN_DIR)\file79.c \
$(SRC_CAN_DIR)\file80.c \
$(SRC_CAN_DIR)\file81.c \
$(SRC_CAN_DIR)\file82.c \
$(SRC_SHUTDOWN_DIR)\file83.c \
$(SRC_SHUTDOWN_DIR)\file84.c \
$(SRC_DIR)\file85.c \
$(SRC_DIR)\file86.c \
$(SRC_DIR)\file87.c \
$(SRC_DIR)\file88.c \
$(SRC_DIR)\file89.c \
$(SRC_DIR)\file90.c \
$(SRC_DIAG_DIR)\file91.c \
$(SRC_CAN_DIR)\file92.c \
$(SRC_KEY_DIR)\file93.c \
$(SRC_KEY_DIR)\file94.c \
$(SRC_KEY_DIR)\file95.c \
$(SRC_KEY_DIR)\file96.c \
$(SRC_KEY_DIR)\file97.c \
$(SRC_KEY_DIR)\file98.c \
$(SRC_KEY_DIR)\file99.c \
$(SRC_LIGHT_DIR)\file100.c \
$(SRC_LIGHT_DIR)\file101.c \
$(SRC_LIGHT_DIR)\file102.c \
$(SRC_LIGHT_DIR)\file103.c \
$(SRC_LIGHT_DIR)\file104.c \
$(SRC_LIGHT_DIR)\file105.c \
$(SRC_LIGHT_DIR)\file106.c \
$(SRC_BATT_DIR)\file107.c \
$(SRC_BATT_DIR)\file108.c
S_FILES =
# Define object files.
OBJ_FILES = $(C_FILES:.c=.o) $(S_FILES:.s=.o)
PUBLIC_MEMORY_MODEL = \
-phapp_mem_model_cpu12.h
# FLAGS FOR DEVELOPMENT
TOOLS_____________________________________________ ______
# Compiler flags:
# +debug = include debug information in the output
# -d*> = define symbol
# -gdp0 = set the direct page address to 0x00
# -ph* = include header file in every source file
# -i*> = include directory
# +glib = use @far @gpage pointers for standard library functions
# +modd = optimize GPAGE register access for data
# +proto = enforce prototype declaration
# +split = create separate sub-sections for each function
# +warn = enable warnings
# +xe = enable S12XE processors
# HAL_A2M4I2_ = selects A2M4I2 ECM within HAL
# A2M4I2 = selects A2M4I2 ECM within HAL J1939V2
# BLOCK0_fl_ = selects token block type
CCD_FLAGS = $(CCD_BASIC_FLAGS) \
+debug \
$(CF_G_cpu12) \
$(CF_O_cpu12) \
-gdp0 \
-phoel_memory_model.h \
$(PUBLIC_MEMORY_MODEL) \
+glib \
+modd \
+proto \
+split \
+warn \
+xe\
-l\
-dR_IC_MC9S12XE_CPU12 \
-dHAL_A2M4I2_ \
-dA2M4I2 \
-dNDEBUG \
-i..\..\..\..\vob1\hal\include_r \
-i..\..\..\..\vob1\hal\include_r\freescale\mc9s12x \
-i..\..\..\..\vob2\oel\include \
-i..\..\..\..\vob1\proto\boot\public \
-i..\..\..\..\vob1\proto\boot\src\include \
-i..\..\..\..\vob2\oel\include_stos \
-i..\..\..\..\vob1\hal\include \
-i..\..\..\..\vob1\scl\include \
-i$(APP_INCL_PATH_1) \
-i$(APP_INCL_PATH_2) \
-i$(APP_INCL_PATH_3) \
-i$(APP_INCL_PATH_4) \
-i$(APP_INCL_PATH_5) \
-i$(APP_INCL_PATH_6) \
-i$(APP_INCL_PATH_7) \
-i$(APP_INCL_PATH_8) \
-i$(APP_INCL_PATH_9) \
-i$(APP_INCL_PATH_10) \
-i$(APP_INCL_PATH_11)
# Linker flags:
# -l*> = library directory
# -m* = map filename
# -o* = output filename
LNK_FLAGS = -m$(TARGET).map \
-o$(TARGET).x12 \
-l$(SRC_DIR) \
-l..\..\..\..\vob1\dir1\tgt_cxs12x_4.7.9_MC9S12XEST \lib \
-l..\..\..\..\vob1\dir1\tgt_cxs12x_4.7.9_MC9S12XEST \lib \
-l..\..\..\..\vob2\dir2\tgt_cxs12x_4.7.9_MC9S12XEST \lib \
$(LNK_BASIC_FLAGS) \
$(LNK_FILE)
# Absolute assembly lister flags:
LSA_FLAGS =
# Hexa translator flags:
# +h* = S0 header string
# -o* = output filename
HEX_FLAGS = $(HEX_BASIC_FLAGS) \
+h"HDR" \
-o$(TARGET).s19
# TARGET
RULES_____________________________________________ _____________________
# By default, an executable must be built.
.DEFAULT: all
all: $(TARGET).s19
# Rule for creating a Motorola S-record file.
$(TARGET).s19: $(TARGET).x12
@$(ECHO) $(ECHO_FLAGS) Making $@ -- Motorola S-record file...
$(HEX) $(HEX_FLAGS) $(TARGET).x12
@$(ECHO) $(ECHO_FLAGS) ...done.
# Rule for creating a linked object file.
$(TARGET).x12: $(OBJ_FILES) $(LNK_FILE)
@$(ECHO) $(ECHO_FLAGS) Making $@ -- executable object...
$(LNK) $(LNK_FLAGS)
@$(ECHO) $(ECHO_FLAGS) ...done.
@$(ECHO) $(ECHO_FLAGS) Making absolute listing files...
$(LSA) $(LSA_FLAGS) $@
@$(ECHO) $(ECHO_FLAGS) ...done.
# Rules for cleaning out files.
clean:
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.o
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.ls
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.bak
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.la
clobber:
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.map
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.s19
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.x
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.x12
@$(DELETE) $(DELETE_FLAGS) $(MOD_DIR)\*.a
# INFERENCE
RULES_____________________________________________ __________________
# This file assumes that clearmake is run with the -r option so that the
# builtin inference rules are not applied. For insurance, .SUFFIXES is
defined
# twice to eliminate previously defined suffixes.
.SUFFIXES:
.SUFFIXES: .c .s .o
# Rule for creating an object file from a C source file.
.c.o:
@$(ECHO) $(ECHO_FLAGS) Making $@ -- relocatable object file...
$(CCD) $(CCD_FLAGS) $<
@$(ECHO) $(ECHO_FLAGS) ...done.
# Rule for creating an object file from an assembly source file.
.s.o:
@$(ECHO) $(ECHO_FLAGS) Making $@ -- relocatable object file...
$(CCD) $(CCD_FLAGS) $<
@$(ECHO) $(ECHO_FLAGS) ...done.
A software feature exclusive to Machine1 is being developed. Machine2 and
Machine3 will not use this feature. This feature must not exist in
Machine2 and Machine3.
Now, there needs to be one exectuable for Machine1 and different executable
for Machine2 and Machine3. To achieve this, I'm thinking about modifying
the build as follows:
Create makefile_machine1.mk. It'll define a compile time feature flag.
Any source files specific to exclusive feature will be added in
makefile_machine1.mk. All source code for this exclusive feature will have
feature flag around it. Exectuable target also needs to be specified in
this makefile. This makefile will include makefile.mk.
Create makefile_machine2_machine3.mk. It will be empty makefile, only
including makefile.mk.
There will be One set of source files for all Three Machines. If we want
to build for machine1, we'll run makefile_machine1.mk. The built
executable will only be used by machine1.
To build for machine2 and machine3, makefile_machine2_machine3.mk will get
invoked. This build executable will only be used by machine2 and
machine3.
To build for all Three machines, both newly created makefiles will be
invoked to create two separate executables.
Will this work? Is there a better solution? If yes, please provide it.
Thank you!
---------------------------------------
Posted through
http://www.EmbeddedRelated.com