SHARE
TWEET

makefile

tdxcn Aug 23rd, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # file      Makefile
  2. # copyright Copyright (c) 2014 Toradex AG
  3. #           [Software License Agreement]
  4. # author    $Author$
  5. # version   $Rev$
  6. # date      $Date$
  7. # brief     a simple makefile to (cross) compile.
  8. #           uses the openembedded provided sysroot and toolchain
  9. # target    linux on Colibri T20 / Colibri T30 / Colibri VF50 / Colibri VF61 / Apalis T30 / Apalis IMX6Q/D
  10. # caveats   -
  11.  
  12. ##############################################################################
  13. # Setup your project settings
  14. ##############################################################################
  15.  
  16. # Set the input source files, the binary name and used libraries to link
  17. SRCS = io.o
  18. PROG := io
  19. LIBS = -lm -lpthread
  20.  
  21. # Set arch flags
  22. ARCH_CFLAGS = -march=armv7-a -fno-tree-vectorize -mthumb-interwork -mfloat-abi=hard
  23.  
  24. ifeq ($(MACHINE), colibri-t20)
  25.   ARCH_FLAGS += -mfpu=vfpv3-d16 -mtune=cortex-a9
  26. else ifeq ($(MACHINE), colibri-t30)
  27.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a9
  28. else ifeq ($(MACHINE), colibri-vf)
  29.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a5
  30. else ifeq ($(MACHINE), apalis-t30)
  31.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a9
  32. else ifeq ($(MACHINE), apalis-imx6)
  33.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a9
  34.   CFLAGS += -DAPALIS_IMX6
  35. else ifeq ($(MACHINE), colibri-imx6)
  36.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a9
  37.   CFLAGS += -DCOLIBRI_IMX6
  38. else ifeq ($(MACHINE), colibri-imx7)
  39.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a7
  40.   CFLAGS += -DCOLIBRI_IMX7
  41. else ifeq ($(MACHINE), apalis-tk1)
  42.   ARCH_FLAGS += -mfpu=neon -mtune=cortex-a15
  43.   CFLAGS += -DAPALIS_TK1
  44. else
  45.   $(error MACHINE is not set to a valid target)
  46. endif
  47.  
  48. # Set flags to the compiler and linker
  49. CFLAGS += -O2 -g -Wall -DNV_IS_LDK=1 $(ARCH_CFLAGS) `$(PKG-CONFIG) --cflags libsoc` --sysroot=$(OECORE_TARGET_SYSROOT) -I$(OECORE_TARGET_SYSROOT)/include
  50. #LDFLAGS += $(OECORE_TARGET_SYSROOT)/lib/libsoc.a
  51. LDFLAGS += `$(PKG-CONFIG) --libs libsoc`
  52.  
  53. ##############################################################################
  54. # Setup your build environment
  55. ##############################################################################
  56.  
  57. # Set the path to the oe built sysroot and
  58. # Set the prefix for the cross compiler
  59. OECORE_NATIVE_SYSROOT ?= /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/
  60. OECORE_TARGET_SYSROOT ?= /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/
  61. CROSS_COMPILE ?= $(OECORE_NATIVE_SYSROOT)/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-
  62.  
  63. ##############################################################################
  64. # The rest of the Makefile usually needs no change
  65. ##############################################################################
  66.  
  67. # Set differencies between native and cross compilation
  68. ifneq ($(strip $(CROSS_COMPILE)),)
  69.   LDFLAGS += -L$(OECORE_TARGET_SYSROOT)/usr/lib -Wl,-rpath-link,$(OECORE_TARGET_SYSROOT)/usr/lib -L$(OECORE_TARGET_SYSROOT)/lib -Wl,-rpath-link,$(OECORE_TARGET_SYSROOT)/lib
  70.   BIN_POSTFIX =
  71.   PKG-CONFIG = export PKG_CONFIG_SYSROOT_DIR=$(OECORE_TARGET_SYSROOT); \
  72.                export PKG_CONFIG_PATH=$(OECORE_TARGET_SYSROOT)/lib/pkgconfig/; \
  73.                $(OECORE_NATIVE_SYSROOT)/usr/bin/pkg-config
  74. else
  75. # Native compile
  76.   PKG-CONFIG = pkg-config
  77.   ARCH_CFLAGS =
  78. # Append .x86 to the object files and binaries, so that native and cross builds can live side by side
  79.   BIN_POSTFIX = .x86
  80. endif
  81.  
  82. # Toolchain binaries
  83. CC = $(CROSS_COMPILE)gcc
  84. LD = $(CROSS_COMPILE)ld
  85. STRIP = $(CROSS_COMPILE)strip
  86. RM = rm -f
  87.  
  88. # Sets the output filename and object files
  89. PROG := $(PROG)$(BIN_POSTFIX)
  90. OBJS = $(SRCS:.c=$(BIN_POSTFIX).o)
  91. DEPS = $(OBJS:.o=.o.d)
  92.  
  93. # pull in dependency info for *existing* .o files
  94. -include $(DEPS)
  95.  
  96. .DEFAULT_GOAL := all
  97.  
  98. all: $(PROG)
  99.  
  100. $(PROG): $(OBJS) Makefile
  101.     $(CC) $(CFLAGS) $(OBJS) $(LIBS) $(LDFLAGS) -o $@
  102.     $(STRIP) $@
  103.  
  104. %$(BIN_POSTFIX).o: %.c
  105.     $(CC) -c $(CFLAGS) -o $@ $<
  106.     $(CC) -MM $(CFLAGS) $< > $@.d
  107.  
  108. clean:
  109.     $(RM) $(OBJS) $(PROG) $(DEPS)
  110.  
  111. .PHONY: all clean
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top