Files
paparazzi/conf/Makefile.omap
T
2013-11-27 12:35:49 +01:00

175 lines
6.2 KiB
Makefile

# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2009-2013 The Paparazzi Team
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#
# find compiler toolchain
#
include $(PAPARAZZI_SRC)/conf/Makefile.arm-linux
# Define programs and commands.
# Launch with "make Q=''" to get full command display
Q=@
OPT=3
CSTANDARD = -std=gnu99
CINCS = $(INCLUDES) -I$(PAPARAZZI_SRC)/sw/include
# Compiler flags.
CFLAGS += $(CINCS)
CFLAGS += -O$(OPT) -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=vfp -march=armv7-a
CFLAGS += -fno-short-enums
# CFLAGS += -malignment-traps
CFLAGS += -Wall -Wcast-qual -Wimplicit -Wcast-align
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
#-Wno-unused-result
#CFLAGS += -Wa,-adhlns=$(OBJDIR)/$(notdir $(subst $(suffix $<),.lst,$<))
#CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += -lm
# flags only for C
CFLAGS += -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wmissing-prototypes -Wnested-externs
CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS)
LDFLAGS += -lm
CXXFLAGS = -pipe -O3 -fshow-column -ffast-math -fPIC
CXXFLAGS += -g -ffunction-sections -fdata-sections
CXXFLAGS += -mfloat-abi=softfp -mtune=cortex-a8 -mfpu=vfp -march=armv7-a
CXXFLAGS += -Wall -Wextra
CXXFLAGS += $($(TARGET).CXXFLAGS)
SRC_C_OMAP = $($(TARGET).srcs)
OBJ_C_OMAP = $(SRC_C_OMAP:%.c=$(OBJDIR)/%.o)
SRC_CPP_OMAP = $($(TARGET).cpp_srcs)
OBJ_CPP_OMAP = $(SRC_CPP_OMAP:%.cpp=$(OBJDIR)/%.o)
all: printcommands build
build: $(OBJDIR) elf
$(OBJDIR):
@echo CREATING object dir $(OBJDIR)
@test -d $(OBJDIR) || mkdir -p $(OBJDIR)
elf: $(OBJDIR)/$(TARGET).elf
# Allow modules or other raw makefiles to add actions to the upload
upload_extra:
DRONE = $(PAPARAZZI_HOME)/sw/ext/ardrone2_drivers/ardrone2.py
# Program the device and start it.
load upload program: upload_extra $(OBJDIR)/$(TARGET).elf
$(Q)$(DRONE) insmod $(PAPARAZZI_SRC)/sw/ext/ardrone2_drivers/cdc-acm.ko
$(Q)$(DRONE) upload_paparazzi $(OBJDIR)/$(TARGET).elf $(SUB_DIR)
$(Q)$(DRONE) status
# Program the device and start it.
load2 upload2 program2: $(OBJDIR)/$(TARGET).elf
# Kill the application
-echo "killall -9 $(TARGET).elf" | telnet $(HOST)
# Make the target dir and edit the config
-{ \
echo "mkdir -p $(TARGET_DIR)"; \
echo "if grep -q \"start_paparazzi *= \" /data/config.ini; then sed -i 's/\(start_paparazzi *= *\).*/\\\1$(ARDRONE2_START_PAPARAZZI)/g' /data/config.ini; else echo \"start_paparazzi = $(ARDRONE2_START_PAPARAZZI)\" >> /data/config.ini; fi"; \
echo "if grep -q \"wifi_mode *= \" /data/config.ini; then sed -i 's/\(wifi_mode *= *\).*/\\\1$(ARDRONE2_WIFI_MODE)/g' /data/config.ini; else echo \"wifi_mode = $(ARDRONE2_WIFI_MODE)\" >> /data/config.ini; fi"; \
echo "if grep -q \"ssid_single_player *= \" /data/config.ini; then sed -i 's/\(ssid_single_player *= *\).*/\\\1$(ARDRONE2_SSID)/g' /data/config.ini; else echo \"ssid_single_player = $(ARDRONE2_SSID)\" >> /data/config.ini; fi"; \
echo "if grep -q \"static_ip_address_base *= \" /data/config.ini; then sed -i 's/\(static_ip_address_base *= *\).*/\\\1$(ARDRONE2_IP_ADDRESS_BASE)/g' /data/config.ini; else echo \"static_ip_address_base = $(ARDRONE2_IP_ADDRESS_BASE)\" >> /data/config.ini; fi"; \
echo "if grep -q \"static_ip_address_probe *= \" /data/config.ini; then sed -i 's/\(static_ip_address_probe *= *\).*/\\\1$(ARDRONE2_IP_ADDRESS_PROBE)/g' /data/config.ini; else echo \"static_ip_address_probe = $(ARDRONE2_IP_ADDRESS_PROBE)\" >> /data/config.ini; fi"; \
} | telnet $(HOST)
# Upload the drivers and new application
{ \
echo "binary"; \
echo "put $(PAPARAZZI_SRC)/sw/ext/ardrone2_drivers/cdc-acm.ko /$(SUB_DIR)/cdc-acm.ko"; \
echo "put $(PAPARAZZI_SRC)/sw/ext/ardrone2_drivers/check_update.sh check_update.sh"; \
echo "put $(PAPARAZZI_SRC)/sw/ext/ardrone2_drivers/wifi_setup.sh wifi_setup.sh"; \
echo "put $(OBJDIR)/$(TARGET).elf /$(SUB_DIR)/$(TARGET).elf"; \
echo "quit"; \
} | ftp -n $(HOST)
# Upload the modules and start the application
-{ \
echo "mv /data/video/check_update.sh /bin/"; \
echo "mv /data/video/wifi_setup.sh /bin/"; \
echo "chmod 777 /bin/check_update.sh" \
echo "chmod 777 /bin/wifi_setup.sh" \
echo "insmod $(TARGET_DIR)/cdc-acm.ko"; \
echo "chmod 777 $(TARGET_DIR)/$(TARGET).elf"; \
echo "$(TARGET_DIR)/$(TARGET).elf > /dev/null 2>&1 &"; \
} | telnet $(HOST)
ifeq ($(ARDRONE2_REBOOT),1)
-{ \
echo "reboot"; \
} | telnet $(HOST)
endif
# Link: create ELF output file from object files.
.SECONDARY : $(OBJDIR)/$(TARGET).elf
.PRECIOUS : $(OBJ_C_OMAP) $(OBJ_CPP_OMAP)
%.elf: $(OBJ_C_OMAP) $(OBJ_CPP_OMAP)
@echo LD $@
$(Q)if (expr "$($(TARGET).cpp_srcs)"); \
then $(CXX) $(CXXFLAGS) $(OBJ_CPP_OMAP) $(OBJ_C_OMAP) --output $@ $(LDFLAGS) $($(TARGET).LDFLAGS); \
else $(CC) $(CFLAGS) $(OBJ_C_OMAP) --output $@ $(LDFLAGS) $($(TARGET).LDFLAGS); fi
# Compile: create object files from C source files
$(OBJDIR)/%.o : %.c $(OBJDIR)/../Makefile.ac
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(Q)$(CC) -MMD -c $(CFLAGS) $< -o $@
# Compile: create object files from C++ source files
$(OBJDIR)/%.o : %.cpp $(OBJDIR)/../Makefile.ac
@echo CXX $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(Q)$(CXX) -MMD -c $(CXXFLAGS) $< -o $@
# Listing of phony targets.
.PHONY : all build elf clean clean_list
#
# Dependencies
#
DEPS = $(addprefix $(OBJDIR)/,$($(TARGET).srcs:.c=.d))
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif