[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Generate Custom Compiler / Build Rules?
From: |
Xochitl Lunde |
Subject: |
Generate Custom Compiler / Build Rules? |
Date: |
Thu, 10 Sep 2009 14:27:31 -0500 |
Automake community:
I would be very thankful for any advice on the following:
I have an embedded platform for which I override all the make rules by
writing the make rules by hand in Makefile.am. I have tested this out,
and it works great, but because we have many unit tests, I have to copy
and paste the rules over and over and over as we add unit tests. This
is just getting unweildy if I ever have to adjust the rule a little bit. I
want to figure out how I can have automake create the correct rules for my
embedded platform for each item in bin_PROGRAMS.
It is not a problem for me to modify scripts which are part of the
Automake install, if that is the right solution. We currently use a
customized Cygwin environment to build, and changes to this Cygwin
environment will not affect the rest of my system in any way. I have
looked through the index of autoconf macros, and I don't see anything
directly applicable, and I don't think BUILT_SOURCES is what I am looking
for either.
My rules are copied at the end of the email.
Also, the 3rd party libraries which I am linking have circular
dependencies, and so I end up needing to use the --start-group and
--end-group flags in the linker command line. I haven't been successful
trying to figure out which libraries to list in what order, although I am
getting closer. Automake complains if I put --start-group in
networktest_LDFLAGS or in networktest_LDADD. Is it not possible to use
this flag in Makefile.am without defining custom rules?
And the very last thing, Automake 1.10 complains about the "$(shell pwd)"
in my 'debugfile' definition in Makefile.am, but Automake 1.9.6 handles it
just fine. Which one is confused or how should I write this?
# ---------------------------
# Describing file extensions.
# ---------------------------
EXEEXT=.bin
DEBUG_EXT=.elf
SYM_EXT=.sym
MAP_EXT=.map
# -----------------------------------
# For use in defining makefile rules.
# -----------------------------------
FLASH=-flash
GDB=-gdb
TESTS = \
networktest serializetest inetaddresstest hosttest \
tcplistenertest tcpconnectiontest \
servertest udpservertest tcpservertest networklibtest
bin_PROGRAMS = $(TESTS)
# ------------------------------------
# Unit test of network.h / network.cpp
# ------------------------------------
dist_networktest_SOURCES = \
$(top_srcdir)/../common/tests/network/networktest.cpp \
$(top_srcdir)/../$(ac_power_alert_platform_path)/src/utils/ulongiptosz.cpp
\
$(top_srcdir)/../$(ac_power_alert_platform_path)/tests/main.cpp
# From Makefile.appbuild.ns9215, additional code needs to be compiled.
nodist_networktest_SOURCES= $(ac_netos_dir)/src/bsp/common/appconf_api.c
networktest_INCLUDES = -include
$(top_srcdir)/../common/tests/network/networktest.h
networktest_CXXFLAGS = -W -Wall -Werror --pedantic -O0 -g \
-DTESTCLASS=NetworkTest $(networktest_INCLUDES) \
-Wno-variadic-macros
networktest_LDFLAGS = $(AM_LDFLAGS)
networktest_LDADD = $(LDADD)
# (... )
# ---------------------------------------
# Use the NET OS linker scripts to build.
# ---------------------------------------
LINKER_SCRIPT_DIR=$(ac_netos_dir)/src/bsp/platforms/$(PLATFORM)
LINK_CMD=$(LINKER_SCRIPT_DIR)/image.ld
LINKOPT= -mbig-endian -nostartfiles -mcpu=arm9tdmi
# -----------------------------------------------------------
# Additional objects are required for linking an application.
# -----------------------------------------------------------
NETOS_CUST_OBJS=$(ac_netos_bspdir)/reset.o \
$(ac_netos_libdir)/memcpy.o
# -------------------------------------------------------------
# The startfile is crt0.o. This defines our application start.
# Only crt0.o is needed if your application is C.
# For c++ define the other 4 files. You might otherwise see the
# error: undefined symbol __dso_handle
# -------------------------------------------------------------
STARTFILE=$(ac_netos_dir)/lib/32b/gnu/crt0.o \
$(ac_netos_dir)/lib/32b/gnu/crti.o \
$(ac_netos_dir)/lib/32b/gnu/crtbegin.o \
$(ac_netos_dir)/lib/32b/gnu/crtend.o \
$(ac_netos_dir)/lib/32b/gnu/crtn.o
# ---------------------------------------------------
# Define custom build rules for the executable files.
# These are the definitions for the debug image.
# More rules are needed to initialize the debugger.
# ---------------------------------------------------
networktest$(DEBUG_EXT): $(networktest_OBJECTS)
$(networktest_DEPENDENCIES)
$(CC) -o networktest$(DEBUG_EXT) $(networktest_OBJECTS)
$(LINKOPT) \
-T $(LINK_CMD) $(NETOS_CUST_OBJS) $(STARTFILE)
$(AM_LDFLAGS) $(LDFLAGS) \
-Wl,--start-group $(APP_LIBS) $(LIBS) $(networktest_LDADD)
-Wl,--end-group \
-Wl,--cref,-Map,networktest$(MAP_EXT)
$(NM) -n networktest$(DEBUG_EXT) > networktest$(SYM_EXT)
# ------------------------------------------------------------------
# Define rules to make the *.bin images. This build rule is defined
# in Makefile.appbuild.ns9215 as the target $(IMAGE_WITH_HEADER).
# ------------------------------------------------------------------
networktest$(EXEEXT): networktest$(DEBUG_EXT)
cp networktest$(DEBUG_EXT) networktest-monimage$(DEBUG_EXT)
$(OBJCOPY) -Obinary networktest$(DEBUG_EXT)
networktest$(ac_uncompress_ext)
$(ac_netos_imgcompress) networktest$(ac_uncompress_ext)
networktest$(ac_compress_ext)
$(ac_netos_boothdr) $(ac_netos_imgheader_cfg)
networktest$(ac_compress_ext) networktest$(EXEEXT) $(PLATFORM)
$(ac_netos_l2b_endian)
$(RM) networktest$(ac_compress_ext)
../../$(ac_netos_binpack) $(PLATFORM)
$(ac_netos_ldscripts)/rom.bin networktest$(EXEEXT)
mv rom.bin networktest$(EXEEXT)
mv rom.bin.md5 networktest$(EXEEXT).md5
# ------------------------------------------------------------
# Add the rules to create the GDB debugger files. The debugger
# needs to have the information from each image, and it
# expects that image to be named 'image.elf'
# ------------------------------------------------------------
debugfile=$(shell pwd)/image.elf
currentfile="`cygpath -a -w $(debugfile)`"
gdbinit:
echo $(currentfile) > .currentfile
cp $(ac_netos_dir)/debugger_files/gdb$(PLATFORM).jlink ./.gdbinit
echo source $(ac_netos_dir)/debugger_files/.gdbinit.threadx >>
.gdbinit
echo source $(ac_netos_dir)/debugger_files/.gdbinit.ns9215 >>
.gdbinit
echo source $(ac_netos_dir)/debugger_files/.gdbinit.eclipse >>
.gdbinit
echo "addresses-ns9215" >> .gdbinit
echo "command-info" >> .gdbinit
rm .currentfile
networktest$(GDB): networktest$(DEBUG_EXT)
$(RM) ./image.elf
$(RM) ./.gdbinit
cp networktest.elf image.elf
make gdbinit
echo "Please find the debug image at" $(debugfile)
# ----------------------------------------------
# Create rules to make the images from the file.
# This includes creating rom.bin and image.elf
# from the desired executable targets.
# ----------------------------------------------
releasefile=$(shell pwd)/rom$(EXEEXT)
networktest$(FLASH): networktest$(GDB) networktest$(EXEEXT)
$(RM) ./rom.bin
$(RM) ./rom.bin.md5
mv networktest$(EXEEXT) rom$(EXEEXT)
mv networktest$(EXEEXT).md5 rom$(EXEEXT).md5
echo "Please find the flash image at" $(releasefile)
- Generate Custom Compiler / Build Rules?,
Xochitl Lunde <=