Merge branch 'master' into radar
[carl9170fw.git] / carlfw / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2
3 project(carl9170.fw)
4
5 include("../extra/sh-elf-linux.cmake")
6 include("../config.cmake")
7
8 set(CARL9170_FW_ELF carl9170.elf)
9 set(CARLFW_CFLAGS_WARNING "-W -Wall -Wextra -Wunreachable-code -Winline -Wlogical-op -Wno-packed-bitfield-compat -Winit-self -Wshadow -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wformat=2 -Wcast-align -Wmissing-format-attribute -Wmissing-prototypes -Wtype-limits -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wdisabled-optimization -Wpointer-arith -Wvolatile-register-var -Waddress -Wbad-function-cast -Wunsafe-loop-optimizations")
10 set(CARLFW_CFLAGS_EXTRA "-mbitops -std=gnu99 -ffunction-sections -Wframe-larger-than=128 -Werror")
11 set(CARLFW_CFLAGS_DEF "-D__CARL9170FW__")
12 if (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS)
13         set(CARLFW_CFLAGS_AGGRESSIVE "-fomit-frame-pointer -fsee -frename-registers -ftree-vectorize -flto -fstrict-volatile-bitfields -fmodulo-sched -fwhole-program")
14 endif (CONFIG_CARL9170FW_AGGRESSIVE_CFLAGS)
15 set(CARLFW_CFLAGS "${CARLFW_CFLAGS_DEF} ${CARLFW_CFLAGS_EXTRA} ${CARLFW_CFLAGS_AGGRESSIVE} ${CARLFW_CFLAGS_WARNING}")
16
17 include_directories (../include/linux ../include/shared ../include include)
18
19 set(carl9170_main_src src/main.c src/wlan.c src/wlanrx.c src/wlantx.c
20                       src/fw.c src/gpio.c src/timer.c src/pattern_generator.c
21                       src/uart.c src/dma.c src/hostif.c src/reboot.S
22                       src/printf.c src/rf.c src/cam.c src/wol.c)
23
24 set(carl9170_lib_src src/memcpy.S src/memset.S src/udivsi3_i4i-Os.S)
25 set(carl9170_usb_src usb/main.c usb/usb.c usb/fifo.c)
26
27 set(carl9170_src ${carl9170_main_src} ${carl9170_lib_src} ${carl9170_usb_src})
28
29 #set_source_files_properties(src/ashlsi3.S PROPERTIES LANGUAGE C)
30 set_source_files_properties(src/memcpy.S PROPERTIES LANGUAGE C)
31 set_source_files_properties(src/memset.S PROPERTIES LANGUAGE C)
32 set_source_files_properties(src/reboot.S PROPERTIES LANGUAGE C)
33 set_source_files_properties(src/udivsi3_i4i-Os.S PROPERTIES LANGUAGE C)
34
35 add_executable(carl9170.elf ${carl9170_src})
36
37 set_target_properties(carl9170.elf PROPERTIES LINKER_LANGUAGE C)
38
39 set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}")
40 set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds")
41
42 add_custom_target(firmware ALL)
43
44 add_custom_command(
45         DEPENDS carl9170.elf
46         COMMAND ${OBJCOPY}
47         ARGS --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc carl9170.elf carl9170.bin
48         TARGET firmware
49         OUTPUTS carl9170.bin)
50
51 add_custom_command(
52         DEPENDS carl9170.elf
53         COMMAND ${OBJCOPY}
54         ARGS --strip-unneeded -O binary -j .fwdsc carl9170.elf carl9170.dsc
55         TARGET firmware
56         OUTPUTS carl9170.dsc)
57
58 add_custom_command(
59         DEPENDS firmware
60         TARGET firmware
61         COMMAND cat
62         ARGS "carl9170.bin" "carl9170.dsc" > "carl9170.fw"
63         DEPENDS carl9170.elf carl9170.bin carl9170.dsc
64         OUTPUTS carl9170.fw)
65
66 SET_DIRECTORY_PROPERTIES(
67         PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "carl9170.fw")