aboutsummaryrefslogtreecommitdiffstats
path: root/Maintenance/makefile
blob: 5ac04e8c20cbc538c78b8b5a060ab6f59b42aa6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#
#             LUFA Library
#     Copyright (C) Dean Camera, 2012.
#
#  dean [at] fourwalledcubicle [dot] com
#           www.lufa-lib.org
#

# Maintenance scripts not required by general LUFA users, used for project development purposes.


# Path to the root of the LUFA tree
LUFA_ROOT := ../

all:

# Update all Doxygen configuration files to the latest Doxygen version - force Markdown support to be disabled
upgrade-doxygen:
	@echo Upgrading Doxygen.conf files...
	@for doxygen_conf in `find $(LUFA_ROOT) -name Doxygen.conf`; do                                       \
	  doxygen -u $$doxygen_conf;                                                                          \
	  sed "s/MARKDOWN_SUPPORT *= *YES/MARKDOWN_SUPPORT       = NO/1" $$doxygen_conf > $$doxygen_conf.new; \
	  sed "s/DISABLE_INDEX *= *NO/DISABLE_INDEX       = YES/1" $$doxygen_conf.new > $$doxygen_conf.new2;  \
	  mv -u $$doxygen_conf.new2 $$doxygen_conf;                                                           \
	  rm $$doxygen_conf.new;                                                                              \
	done;
	@echo Doxygen configuration update complete.

# Generate AVR Studio 4 project files for each project from a template
make-as4-projects:
	@echo Creating AVR Studio 4 project files for Demos...
	@for project_makefile in `find $(LUFA_ROOT)/Demos $(LUFA_ROOT)/Projects $(LUFA_ROOT)/Bootloaders -name makefile*`; do \
	  target_name=`grep "TARGET *=" $$project_makefile | cut -d'=' -f2 | sed 's/ //g'`; \
	  target_folder=`dirname $$project_makefile`;                                   \
	  as4_date=`date "+%-e-%b-%Y %-H:%-M:%-S"`;                                     \
	                                                                                \
	  if ( test -n "$$target_name" ); then                                          \
	    echo Creating AS4 project for project $$target_name;                        \
	                                                                                \
	    source_files="<OTHERFILE>`basename $$project_makefile`<\/OTHERFILE>";       \
	    gcc_source_files="";                                                        \
	    for c_source_file in `find $$target_folder -name *.c`; do                   \
	      source_filename=`basename $$c_source_file`;                               \
	                                                                                \
	      source_files="$$source_files<SOURCEFILE>$$source_filename<\/SOURCEFILE>"; \
	      gcc_source_files="$$gcc_source_files<Name>$$source_filename<\/Name>";     \
	    done;                                                                       \
	    for c_header_file in `find $$target_folder -name *.h`; do                   \
	      source_filename=`basename $$c_header_file`;                               \
	                                                                                \
	      source_files="$$source_files<HEADERFILE>$$source_filename<\/HEADERFILE>"; \
	      gcc_source_files="$$gcc_source_files<Name>$$source_filename<\/Name>";     \
	    done;                                                                       \
	    for assembly_file in `find $$target_folder -name *.S`; do                   \
	      source_filename=`basename $$assembly_file`;                               \
	                                                                                \
	      source_files="$$source_files<OTHERFILE>$$source_filename<\/OTHERFILE>";   \
	      gcc_source_files="$$gcc_source_files<Name>$$source_filename<\/Name>";     \
	    done;                                                                       \
	                                                                                \
	    sed "s/%TARGET%/$$target_name/g" AS4Template.aps > $$target_folder/$$target_name.aps.new;                                     \
	    sed "s/%CREATED%/$$as4_date/g" $$target_folder/$$target_name.aps.new > $$target_folder/$$target_name.aps.new2;                \
	    sed "s/%FILE_LIST%/$$source_files/g" $$target_folder/$$target_name.aps.new2 > $$target_folder/$$target_name.aps.new3;         \
	    sed "s/%GCC_FILE_LIST%/$$gcc_source_files/g" $$target_folder/$$target_name.aps.new3 > $$target_folder/$$target_name.aps.new4; \
	    mv $$target_folder/$$target_name.aps.new4 $$target_folder/$$target_name.aps;                                                  \
	    rm $$target_folder/$$target_name.aps.new $$target_folder/$$target_name.aps.new2 $$target_folder/$$target_name.aps.new3;       \
	  fi; \
	done;
	@echo AVR Studio 4 project generation complete.

# Make all possible bootloaders for all targets and configurations as set by the BootloaderTest build test
# and store them in a seperate directory called "Bootloaders"
#
# FIXME: Currently ignores the architecture when deciding on F_USB choices; when more architectures are
#        avaliable as bootloaders, add some additional entries to the bootloader map for F_USB.
make_bootloaders:
	@echo "build_bootloaders:" > BuildMakefile
	@printf "\t-mkdir Bootloaders 2>/dev/null\n\n" >> BuildMakefile
	
	@while read line;                                         \
	 do                                                       \
	   build_cfg=`echo $$line | grep -v "#" | sed 's/ //g'`;  \
	                                                          \
	   if ( test -n "$$build_cfg" ); then                     \
	     build_bootloader=`echo $$build_cfg | cut -d'=' -f1`; \
		 build_cfg=`echo $$build_cfg | cut -d'=' -f2-`;       \
		                                                      \
	     build_arch=`echo $$build_cfg | cut -d':' -f1`;       \
	     build_mcu=`echo $$build_cfg | cut -d':' -f2`;        \
	     build_board=`echo $$build_cfg | cut -d':' -f3`;      \
	     build_flashsize=`echo $$build_cfg | cut -d':' -f4`;  \
	     build_bootsize=`echo $$build_cfg | cut -d':' -f5`;   \
	                                                          \
	     printf "Found '%s' with FLASH: %3s KB, BOOT: %3s KB, MCU: %12s / %4s, BOARD: %s\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_arch $$build_board; \
	                                                          \
	     printf "\t@echo Building '%s' with FLASH: %3s KB, BOOT: %3s KB, MCU: %12s, F_USB: 8MHz, BOARD: %s\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_board >> BuildMakefile; \
	     printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_ROOT))/Bootloaders/%s/ clean hex F_USB=8000000 ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s DEBUG_LEVEL=0\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize >> BuildMakefile; \
		 printf "\tmv $(patsubst %/,%,$(LUFA_ROOT))/Bootloaders/%s/Bootloader%s.hex Bootloaders/%s-%s-%s-BOARD_%s-BOOT_%sKB_8MHz.hex\n\n" $$build_bootloader $$build_bootloader $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_bootsize >> BuildMakefile; \
	                                                          \
	     printf "\t@echo Building '%s' with FLASH: %3s KB, BOOT: %3s KB, MCU: %12s, F_USB: 16MHz, BOARD: %s\n" $$build_bootloader $$build_flashsize $$build_bootsize $$build_mcu $$build_board >> BuildMakefile; \
	     printf "\t$(MAKE) -C $(patsubst %/,%,$(LUFA_ROOT))/Bootloaders/%s/ clean hex F_USB=16000000 ARCH=%s MCU=%s BOARD=%s FLASH_SIZE_KB=%s BOOT_SECTION_SIZE_KB=%s DEBUG_LEVEL=0\n" $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_flashsize $$build_bootsize >> BuildMakefile; \
		 printf "\tmv $(patsubst %/,%,$(LUFA_ROOT))/Bootloaders/%s/Bootloader%s.hex Bootloaders/%s-%s-%s-BOARD_%s-BOOT_%sKB_16MHz.hex\n\n" $$build_bootloader $$build_bootloader $$build_bootloader $$build_arch $$build_mcu $$build_board $$build_bootsize >> BuildMakefile; \
	   fi;                                                    \
	 done < $(patsubst %/,%,$(LUFA_ROOT))/BuildTests/BootloaderTest/BootloaderDeviceMap.cfg

	 $(MAKE) -f BuildMakefile build_bootloaders
	 cp $(patsubst %/,%,$(LUFA_ROOT))/LUFA/License.txt Bootloaders
	 rm -f BuildMakefile

# Check the working branch documentation, ensure no placeholder values
check-documentation-placeholders:
	@echo Checking for release suitability...
	@if ( grep "XXXXXX" $(patsubst %/,%,$(LUFA_ROOT))/LUFA/DoxygenPages/*.txt > /dev/null ;); then \
	  echo "  ERROR: Doxygen documentation has not been updated for release!";    \
	  exit 1;                                                                     \
	fi;
	@if ( grep "000000" $(patsubst %/,%,$(LUFA_ROOT))/LUFA/Version.h > /dev/null ;); then          \
	  echo "  ERROR: Version header has not been updated for release!";           \
	  exit 1;                                                                     \
	fi;
	@echo Done.

# Validate the working branch - compile all documentation, demos/projects/examples and run build tests
validate-branch:
	$(MAKE) -C $(patsubst %/,%,$(LUFA_ROOT)) doxygen
	$(MAKE) -C $(patsubst %/,%,$(LUFA_ROOT)) all DEBUG_LEVEL=0
	$(MAKE) -C $(patsubst %/,%,$(LUFA_ROOT))/BuildTests all

# Validate the working branch for general release, check for placeholder documentation then build and test everything
validate-release: check-documentation-placeholders validate-branch


.PHONY: all upgrade-doxygen make-as4-projects make_bootloaders check-documentation-placeholders validate-branch