-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
executable file
·666 lines (512 loc) · 23.9 KB
/
Makefile
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
################################################
#
# Makefile to Manage QuartusII/QSys Design
#
# Copyright Altera (c) 2014
# All Rights Reserved
#
################################################
SHELL := /bin/bash
.SUFFIXES: # Delete the default suffixes
include mks/default.mk
################################################
# Configuration
DL := downloads
HTTP_PROXY := sj-proxy:8080
HTTPS_PROXY := sj-proxy:8080
# Source
TCL_SOURCE = $(wildcard scripts/*.tcl)
QUARTUS_HDL_SOURCE = $(wildcard src/*.v) $(wildcard src/*.vhd) $(wildcard src/*.sv)
QUARTUS_MISC_SOURCE = $(wildcard src/*.stp) $(wildcard src/*.sdc)
PROJECT_ASSIGN_SCRIPTS = $(filter scripts/create_ghrd_quartus_%.tcl,$(TCL_SOURCE))
QSYS_ADD_COMP_TCLS := $(sort $(wildcard scripts/qsys_add_*.tcl))
#UBOOT_PATCHES = patches/soc_workshop_uboot_patch.patch patches/soc_workshop_uboot_patch_2.patch
#LINUX_BRANCH ?= socfpga-3.10-ltsi
LINUX_BRANCH ?= socfpga-4.1-ltsi
UBOOT_PATCHES = $(sort $(wildcard patches/u-boot/*.patch))
LINUX_PATCHES = $(sort $(wildcard patches/$(LINUX_BRANCH)/*.patch))
DTS_COMMON = board_info/hps_common_board_info.xml
DTS_BOARD_INFOS = $(wildcard board_info/board_info_*.xml)
# Board revisions
REVISION_LIST = $(patsubst create_ghrd_quartus_%,%,$(basename $(notdir $(PROJECT_ASSIGN_SCRIPTS))))
QUARTUS_DEFAULT_REVISION_FILE = \
$(if \
$(filter create_ghrd_quartus_$(PROJECT_NAME).tcl,$(notdir $(PROJECT_ASSIGN_SCRIPTS))), \
create_ghrd_quartus_$(PROJECT_NAME).tcl, \
$(firstword $(PROJECT_ASSIGN_SCRIPTS)))
QUARTUS_DEFAULT_REVISION = $(patsubst create_ghrd_quartus_%, \
%, \
$(basename $(notdir $(QUARTUS_DEFAULT_REVISION_FILE))))
SCRIPT_DIR = utils
# Project specific settings
PROJECT_NAME = soc_workshop_system
QSYS_BASE_NAME = soc_system
TOP_LEVEL_ENTITY = ghrd_top
QSYS_HPS_INST_NAME = hps_0
PRELOADER_DISABLE_WATCHDOG = 1
PRELOADER_FAT_SUPPORT = 1
# Board specific preloader extra args
PRELOADER_EXTRA_ARGS_ALTERA_CV_SOC = --set spl.boot.SDRAM_SCRUBBING true
PRELOADER_EXTRA_ARGS_ALTERA_AV_SOC = --set spl.boot.SDRAM_SCRUBBING true
PRELOADER_EXTRA_ARGS_CRITICALLINK_MITYSOM_DEVKIT = --set spl.boot.SDRAM_SCRUBBING true
#SW Config
ARCH := arm
CROSS_COMPILE := arm-linux-gnueabihf-
TOOLCHAIN_DIR := $(CURDIR)/toolchain
TOOLCHAIN_SOURCE := gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz
TOOLCHAIN_SOURCE_TAR := gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar
TOOLCHAIN_SOURCE_PACKAGE := "http://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/arm-linux-gnueabihf/$(TOOLCHAIN_SOURCE)"
# Kernel Config
# This corresponds to socfpga-4.1-ltsi
REPO_HASH := "c816eac2b585ced0418ae9d11565825b9489e0c6"
LNX_SOURCE_PACKAGE := "https://github.com/altera-opensource/linux-socfpga/tarball/$(REPO_HASH)"
#LNX_SOURCE_PACKAGE := "https://github.com/altera-opensource/linux-socfpga/tarball/$(LINUX_BRANCH)"
#LNX_SOURCE_PACKAGE := "http://rocketboards.org/gitweb/?p=linux-socfpga.git;a=snapshot;h=refs/heads/$(LINUX_BRANCH);sf=tgz"
#LNX_SOURCE_PACKAGE := "http://rocketboards.org/gitweb/?p=linux-socfpga.git;a=snapshot;h=refs/heads/socfpga-3.10-ltsi;sf=tgz"
#LNX_SOURCE_PACKAGE := "http://rocketboards.org/gitweb/?p=linux-socfpga.git;a=snapshot;h=refs/heads/socfpga-3.17;sf=tgz"
LINUX_DEFCONFIG_TARGET = socfpga_custom_defconfig
LINUX_DEFCONFIG := $(wildcard linux.defconfig.$(LINUX_BRANCH))
LINUX_MAKE_TARGET := zImage
KBUILD_BUILD_VERSION=$(shell /bin/date "+%Y-%m-%d---%H-%M-%S")
#LNX_DEPS = linux.patches linux.dodefconfig toolchain.extract buildroot.build
LNX_DEPS = linux.patch linux.dodefconfig toolchain.extract rootfs.cpio.gz | logs
# Buildroot Config
BUILDROOT_DEFCONFIG_TARGET = br_custom_defconfig
BUILDROOT_DEFCONFIG := $(wildcard buildroot.defconfig)
BUSYBOX_CONFIG_FILE := $(wildcard $(CURDIR)/buildroot_busybox.config)
# NB: IF Buildroot is updated, the busybox-menuconfig stuff needs to be changed with an updated path.
#BR_SOURCE_PACKAGE := "http://buildroot.uclibc.org/downloads/buildroot-2014.08.tar.gz"
#BR_SOURCE_PACKAGE := "http://buildroot.uclibc.org/downloads/buildroot-2014.11.tar.gz"
#BR_SOURCE_PACKAGE := "http://buildroot.uclibc.org/downloads/buildroot-2015.11.tar.gz"
BR_SOURCE_PACKAGE := "http://buildroot.uclibc.org/downloads/buildroot-2016.02.tar.gz"
# AR_FILTER_OUT := downloads
# initial save file list
AR_REGEX += ip readme.txt mks
AR_REGEX += scripts
AR_REGEX += $(SCRIPT_DIR)
AR_REGEX += patches
AR_REGEX += board_info
AR_REGEX += hdl_src
AR_REGEX += sw_src
AR_REGEX += utils
AR_REGEX += overlay_template
AR_REGEX += devicetrees
AR_REGEX += downloads
AR_REGEX += *.defconfig.*
AR_REGEX += *.config
AR_REGEX += build.sh
AR_REGEX += arc_build.sh
AR_REGEX += boot.script
AR_REGEX += buildroot.defconfig
AR_REGEX += target_tests
AR_REGEX += WS1-IntroToSoC
AR_REGEX += WS2-IntroToLinux
AR_REGEX += WS3-DevelopingDrivers
AR_REGEX += CREATE_ALL_SD_CARD_COMPRESSED_IMAGES.sh
AR_REGEX += create_pre_only_sd_card_images.sh
AR_REGEX += create_sd_card_images.sh
AR_REGEX += PREFIX_SD_CARD_IMAGES.sh
AR_REGEX += create_sd_card_images_sudo.sh
################################################
.PHONY: default
default: help
################################################
################################################
.PHONY: all
all: sd-fat
################################################
# DEPS
define create_deps
CREATE_PROJECT_STAMP_$1 := $(call get_stamp_target_hw,$1.create_project)
CREATE_PROJECT_DEPS_$1 := scripts/create_ghrd_quartus_$1.tcl | logs
QUARTUS_STAMP_$1 := $(call get_stamp_target_hw,$1.quartus)
PRELOADER_GEN_STAMP_$1 := $(call get_stamp_target_hw,$1.preloader_gen)
PRELOADER_FIXUP_STAMP_$1 := $(call get_stamp_target_hw,$1.preloader_fixup)
PRELOADER_STAMP_$1 := $(call get_stamp_target_hw,$1.preloader)
UBOOT_STAMP_$1 := $(call get_stamp_target_hw,$1.uboot)
DTS_STAMP_$1 := $(call get_stamp_target,$1.dts)
DTB_STAMP_$1 := $(call get_stamp_target,$1.dtb)
QSYS_STAMP_$1 := $(call get_stamp_target_hw,$1.qsys_compile)
QSYS_GEN_STAMP_$1 := $(call get_stamp_target_hw,$1.qsys_gen)
QSYS_ADD_ALL_COMP_STAMP_$1 := $(call get_stamp_target_hw,$1.qsys_add_all_comp)
#QSYS_ADD_COMP_STAMP_$1 := $(foreach t,$(QSYS_ADD_COMP_TCLS),$(call get_stamp_target_hw,$1.$t))
QSYS_RUN_ADD_COMPS_$1 = $(foreach t,$(QSYS_ADD_COMP_TCLS),$(call get_stamp_target_hw,$1.$(notdir $t)))
QSYS_PIN_ASSIGNMENTS_STAMP_$1 := $$(call get_stamp_target_hw,$1.quartus_pin_assignments)
QUARTUS_DEPS_$1 += $$(QUARTUS_PROJECT_STAMP_$1) $(QUARTUS_HDL_SOURCE) $(QUARTUS_MISC_SOURCE)
QUARTUS_DEPS_$1 += $$(CREATE_PROJECT_STAMP_$1)
QUARTUS_DEPS_$1 += $$(QSYS_PIN_ASSIGNMENTS_STAMP_$1) $$(QSYS_STAMP_$1)
PRELOADER_GEN_DEPS_$1 += $$(QUARTUS_STAMP_$1)
PRELOADER_FIXUP_DEPS_$1 += $$(PRELOADER_GEN_STAMP_$1)
PRELOADER_DEPS_$1 += $$(PRELOADER_FIXUP_STAMP_$1)
# QSYS_DEPS_$1 := $$(QSYS_GEN_STAMP_$1)
QSYS_DEPS_$1 += $1/$(QSYS_BASE_NAME).qsys $1/addon_components.ipx
QSYS_GEN_DEPS_$1 += $$(CREATE_PROJECT_STAMP_$1)
# QSYS_GEN_DEPS_$1 += scripts/create_ghrd_qsys.tcl scripts/devkit_hps_configurations.tcl
QSYS_GEN_DEPS_$1 += scripts/create_ghrd_qsys_$1.tcl scripts/qsys_default_components.tcl
QSYS_GEN_DEPS_$1 += $(QSYS_ADD_COMP_TCLS)
QSYS_GEN_DEPS_$1 += $1/addon_components.ipx
#only support one custom board xml
#DTS_BOARDINFO_$1 := $(firstword $(filter $1, $(DTS_BOARD_INFOS)))
DTS_BOARDINFO_$1 := board_info/board_info_$1.xml
DTS_DEPS_$1 += $$(DTS_BOARDINFO_$1) $(DTS_COMMON) $$(QSYS_STAMP_$1)
DTB_DEPS_$1 += $$(DTS_BOARDINFO_$1) $(DTS_COMMON) $$(QSYS_STAMP_$1)
QUARTUS_QPF_$1 := $1/$1.qpf
QUARTUS_QSF_$1 := $1/$1.qsf
QUARTUS_SOF_$1 := $1/output_files/$1.sof
QUARTUS_RBF_$1 := $1/output_files/$1.rbf
QUARTUS_JDI_$1 := $1/output_files/$1.jdi
QSYS_FILE_$1 := $1/$(QSYS_BASE_NAME).qsys
QSYS_SOPCINFO_$1 := $1/$(QSYS_BASE_NAME).sopcinfo
DEVICE_TREE_SOURCE_$1 := $1/$(QSYS_BASE_NAME).dts
DEVICE_TREE_BLOB_$1 := $1/$(QSYS_BASE_NAME).dtb
#QSYS_SOPCINFO_$1 := $(patsubst $1/%.qsys,$1/%.sopcinfo,$$(QSYS_FILE_$1))
#DEVICE_TREE_SOURCE_$1 := $(patsubst $1/%.sopcinfo,$1/%.dts,$$(QSYS_SOPCINFO_$1))
#DEVICE_TREE_BLOB_$1 := $(patsubst $1/%.sopcinfo,$1/%.dtb,$$(QSYS_SOPCINFO_$1))
AR_FILES += $$(QUARTUS_RBF_$1) $$(QUARTUS_SOF_$1)
AR_FILES += $$(QSYS_SOPCINFO_$1) $$(QSYS_FILE_$1)
AR_REGEX += $1/$(QSYS_BASE_NAME)/*.svd
AR_FILES += $$(DEVICE_TREE_SOURCE_$1)
AR_FILES += $$(DEVICE_TREE_BLOB_$1)
AR_FILES += $1/preloader/uboot-socfpga/u-boot.img
AR_FILES += $1/preloader/preloader-mkpimage.bin
AR_FILES += $1/u-boot.img
AR_FILES += $1/preloader-mkpimage.bin
#AR_FILES += $1/boot.script $1/u-boot.scr
ALL_DEPS_$1 += $$(QUARTUS_RBF_$1) $$(QUARTUS_SOF_$1) $$(QUARTUS_JDI_$1)
ALL_DEPS_$1 += $1/u-boot.img $1/preloader-mkpimage.bin
ALL_DEPS_$1 += $$(QUARTUS_JDI_$1) $$(QSYS_SOPCINFO_$1) $$(QSYS_FILE_$1)
ALL_DEPS_$1 += $1/hps_isw_handoff $1/$1.qpf $1/$1.qsf
SD_FAT_$1 += $$(ALL_DEPS_$1)
SD_FAT_$1 += $$(DEVICE_TREE_SOURCE_$1) $$(DEVICE_TREE_BLOB_$1)
SD_FAT_$1 += boot.script u-boot.scr
SD_FAT_$1 += hdl_src
#SD_FAT_$1 += board_info
SD_FAT_$1 += ip
SD_FAT_$1 += target_tests
SD_FAT_$1 += WS1-IntroToSoC
SD_FAT_$1 += WS2-IntroToLinux
SD_FAT_$1 += WS2-IntroToLinux/rootfs.cpio.gz
SD_FAT_$1 += WS2-IntroToLinux/devicetrees/$1.dts
SD_FAT_$1 += WS3-DevelopingDrivers
SD_FAT_$1 += WS3-DevelopingDrivers/ws3_lab_environment.src
SD_FAT_$1 += WS3-DevelopingDrivers/$(LINUX_DEFCONFIG)
SD_FAT_$1 += WS3-DevelopingDrivers/example_drivers.tgz
.PHONY:$1.all
$1.all: $$(ALL_DEPS_$1)
HELP_TARGETS += $1.all
$1.all.HELP := Build Quartus / preloader / uboot / devicetree / boot scripts for $1 board
#tar file target per project just 4 kicks.
HELP_TARGETS += sd_fat_$1.tar.gz
sd_fat_$1.tar.gz.HELP := Tar of SDCard's FAT filesystem contents for $1
sd_fat_$1.tar.gz: $$(SD_FAT_$1) zImage.$(LINUX_BRANCH)
$(RM) $@
$(TAR) -czf $$@ $$^ zImage.*
endef
$(foreach r,$(REVISION_LIST),$(eval $(call create_deps,$r)))
AR_FILES += boot.script u-boot.scr
include mks/qsys.mk mks/quartus.mk mks/preloader_uboot.mk mks/devicetree.mk
include mks/bootscript.mk mks/kernel.mk mks/buildroot.mk mks/overlay.mk
include mks/arc.mk
################################################
################################################
# Toolchain
.PHONY: toolchain.get
toolchain.get: $(DL)/$(TOOLCHAIN_SOURCE)
$(DL)/$(TOOLCHAIN_SOURCE):
$(MKDIR) $(DL)
wget -O $@ $(TOOLCHAIN_SOURCE_PACKAGE)
$(DL)/$(TOOLCHAIN_SOURCE_TAR): $(DL)/$(TOOLCHAIN_SOURCE)
$(CAT) $< | $(XZ) -d > $@
.PHONY: toolchain.extract
toolchain.extract: $(call get_stamp_target,toolchain.extract)
$(call get_stamp_target,toolchain.extract): $(DL)/$(TOOLCHAIN_SOURCE_TAR)
$(RM) $(TOOLCHAIN_DIR)
$(MKDIR) $(TOOLCHAIN_DIR)
$(TAR) -xvf $< --strip-components 1 -C $(TOOLCHAIN_DIR)
$(stamp_target)
################################################
################################################
# All projects stuff
#define create_project
#.PHONY: create_project-$1
#create_project-$1: $$(QSYS_GEN_STAMP_$1) $$(CREATE_PROJECT_STAMP_$1)
#HELP_TARGETS_$1 += create_project-$1
#create_project-$1.HELP := Create all files for $1 project
#endef
#$(foreach r,$(REVISION_LIST),$(eval $(call create_project,$r)))
.PHONY: create_all_projects
create_all_projects: $(foreach r,$(REVISION_LIST),$r.create_project)
HELP_TARGETS += create_all_projects
create_all_projects.HELP := Create all quartus projects
.PHONY: create_all_qsys
create_all_qsys: $(foreach r,$(REVISION_LIST),qsys_generate_qsys-$r)
HELP_TARGETS += create_all_qsys
create_all_qsys.HELP := Create all qsys files
.PHONY: compile_all_projects
compile_all_projects: $(foreach r,$(REVISION_LIST),$r.all)
HELP_TARGETS += compile_all_projects
compile_all_projects.HELP := Compile all quartus projects
################################################
################################################
SD_FAT_TGZ := sd_fat.$(KBUILD_BUILD_VERSION).tar.gz
SD_FAT_TGZ_DEPS += $(foreach r,$(REVISION_LIST),$(ALL_DEPS_$r))
SD_FAT_TGZ_DEPS += $(foreach r,$(REVISION_LIST),$(DEVICE_TREE_SOURCE_$r) $(DEVICE_TREE_BLOB_$r))
SD_FAT_TGZ_DEPS += zImage.$(LINUX_BRANCH)
SD_FAT_TGZ_DEPS += boot.script u-boot.scr
SD_FAT_TGZ_DEPS += hdl_src
#SD_FAT_TGZ_DEPS += board_info
SD_FAT_TGZ_DEPS += ip
SD_FAT_TGZ_DEPS += patches
SD_FAT_TGZ_DEPS += target_tests
SD_FAT_TGZ_DEPS += WS1-IntroToSoC
SD_FAT_TGZ_DEPS += WS2-IntroToLinux
SD_FAT_TGZ_DEPS += WS3-DevelopingDrivers
SD_FAT_TGZ_DEPS += WS3-DevelopingDrivers/ws3_lab_environment.src
SD_FAT_TGZ_DEPS += WS3-DevelopingDrivers/$(LINUX_DEFCONFIG)
SD_FAT_TGZ_DEPS += WS3-DevelopingDrivers/example_drivers.tgz
SD_FAT_TGZ_DEPS += WS2-IntroToLinux/rootfs.cpio.gz
SD_FAT_TGZ_DEPS += WS2-IntroToLinux/patches.tgz
SD_FAT_TGZ_DEPS += WS2-IntroToLinux/ws2_lab_environment.src
SD_FAT_TGZ_DEPS += WS2-IntroToLinux/$(LINUX_DEFCONFIG)
SD_FAT_TGZ_DEPS += $(foreach r,$(REVISION_LIST),WS2-IntroToLinux/devicetrees/$r.dts)
$(SD_FAT_TGZ): $(SD_FAT_TGZ_DEPS)
@$(RM) $@
@$(MKDIR) $(@D)
$(TAR) -czf $@ $^ zImage.*
QUARTUS_OUT_TGZ := quartus_out.tar.gz
QUARTUS_OUT_TGZ_DEPS += $(ALL_QUARTUS_RBF) $(ALL_QUARTUS_SOF)
$(QUARTUS_OUT_TGZ): $(QUARTUS_OUT_TGZ_DEPS)
@$(RM) $@
@$(MKDIR) $(@D)
$(TAR) -czf $@ $^
HELP_TARGETS += sd-fat
sd-fat.HELP := Generate tar file with contents for sdcard fat partition
.PHONY: sd-fat
sd-fat: $(SD_FAT_TGZ)
AR_FILES += $(wildcard $(SD_FAT_TGZ))
SCRUB_CLEAN_FILES += $(SD_FAT_TGZ)
################################################
################################################
# Clean-up and Archive
AR_TIMESTAMP := $(if $(SOCEDS_VERSION),$(subst .,_,$(SOCEDS_VERSION))_)$(subst $(SPACE),,$(shell $(DATE) +%m%d%Y_%k%M%S))
AR_DIR := tgz
AR_FILE := $(AR_DIR)/soc_workshop_$(AR_TIMESTAMP).tar.gz
AR_FILES += $(filter-out $(AR_FILTER_OUT),$(wildcard $(AR_REGEX)))
CLEAN_FILES += $(filter-out $(AR_DIR) $(AR_FILES),$(wildcard *))
HELP_TARGETS += tgz
tgz.HELP := Create a tarball with the barebones source files that comprise this design
.PHONY: tarball tgz
tarball tgz: $(AR_FILE)
$(AR_FILE):
@$(MKDIR) $(@D)
@$(if $(wildcard $(@D)/*.tar.gz),$(MKDIR) $(@D)/.archive;$(MV) $(@D)/*.tar.gz $(@D)/.archive)
@$(ECHO) "Generating $@..."
@$(TAR) -czf $@ $(wildcard $(AR_FILES))
SCRUB_CLEAN_FILES += $(CLEAN_FILES)
HELP_TARGETS += scrub_clean
scrub_clean.HELP := Restore design to its barebones state
.PHONY: scrub scrub_clean
scrub scrub_clean:
$(MAKE) -C sw_src clean
$(if $(strip $(wildcard $(SCRUB_CLEAN_FILES))),$(RM) $(wildcard $(SCRUB_CLEAN_FILES)),@$(ECHO) "You're already as clean as it gets!")
.PHONY: test_scrub_clean
test_scrub_clean:
$(if $(strip $(wildcard $(SCRUB_CLEAN_FILES))),$(ECHO) $(wildcard $(SCRUB_CLEAN_FILES)),@$(ECHO) "You're already as clean as it gets!")
.PHONY: tgz_scrub_clean
tgz_scrub_clean:
$(FIND) $(SOFTWARE_DIR) \( -name '*.o' -o -name '.depend*' -o -name '*.d' -o -name '*.dep' \) -delete || true
$(MAKE) tgz AR_FILE=$(AR_FILE)
$(MAKE) -s scrub_clean
$(TAR) -xzf $(AR_FILE)
HELP_TARGETS += clean_all_sw
clean_all_sw,HELP := Clean sw build stuff (not uboot), dont touch quartus outputs
.PHONY: clean_all_sw
clean_all_sw:
$(RM) overlay/ buildroot/ zImage* rootfs.* sd_card.* sd_fat_* $(LINUX_BRANCH)/ toolchain/
$(MAKE) -C sw_src clean
echo $(RM) stamp/
################################################
################################################
# Download everything
HELP_TARGETS += downloads
downloads.HELP := Download toolchain, kernel, and buildroot + required buildroot packages
.PHONY: downloads
downloads: toolchain.get buildroot.get linux.get buildroot.downloads coreutils.get tar.get
HELP_TARGETS += downloads_clean
downloads_clean.HELP := Clean downloads directory
.PHONY: downloads_clean
downloads_clean:
$(RM) $(DL)/*
################################################
logs:
$(MKDIR) logs
################################################
# Utils
.PHONY: setup_sw_env
setup_sw_env: toolchain.extract linux.dodefconfig buildroot.dodefconfig
HELP_TARGETS += setup_sw_env
setup_sw_env.HELP := Setup SW build environment
.PHONY: enable_signaltap
HELP_TARGETS += enable_signaltap
enable_signaltap.HELP := Enable SignalTap in project create scripts
enable_signaltap:
sed -i '/ENABLE_SIGNALTAP/c set_global_assignment -name ENABLE_SIGNALTAP ON' scripts/create_ghrd_quartus_*.tcl
.PHONY: disable_signaltap
HELP_TARGETS += disable_signaltap
disable_signaltap.HELP := Disable SignalTap in project create scripts
disable_signaltap:
sed -i '/ENABLE_SIGNALTAP/c set_global_assignment -name ENABLE_SIGNALTAP OFF' scripts/create_ghrd_quartus_*.tcl
################################################
# WorkShop outputs
WS2_OUTPUT_DEPS += WS2-IntroToLinux/rootfs.cpio.gz
WS2_OUTPUT_DEPS += $(foreach r,$(REVISION_LIST),WS2-IntroToLinux/devicetrees/$r.dts)
WS2_OUTPUT_DEPS += WS2-IntroToLinux/ws2_lab_environment.src
WS2_OUTPUT_DEPS += WS2-IntroToLinux/patches.tgz
WS2-IntroToLinux/devicetrees/%.dts: devicetrees/%.dts
$(MKDIR) WS2-IntroToLinux/devicetrees
$(CP) $< $@
WS2-IntroToLinux/rootfs.cpio.gz: rootfs.cpio.gz
$(CP) $< $@
WS2-IntroToLinux/ws2_lab_environment.src: linux.build
$(ECHO) "TOOLCHAIN_SOURCE=$(TOOLCHAIN_SOURCE)" > $@
$(ECHO) "TOOLCHAIN_SOURCE_TAR=$(TOOLCHAIN_SOURCE_TAR)" >> $@
$(ECHO) "TOOLCHAIN_SOURCE_PACKAGE=$(TOOLCHAIN_SOURCE_PACKAGE)" >> $@
$(ECHO) "KBUILD_BUILD_VERSION=\"$(KBUILD_BUILD_VERSION)\"" >> $@
$(ECHO) "LINUX_BRANCH=$(LINUX_BRANCH)" >> $@
$(ECHO) "LINUX_DEFCONFIG_TARGET=$(LINUX_DEFCONFIG_TARGET)" >> $@
$(ECHO) "LINUX_DEFCONFIG=$(LINUX_DEFCONFIG)" >> $@
$(ECHO) "LNX_SOURCE_PACKAGE=$(LNX_SOURCE_PACKAGE)" >> $@
WS2-IntroToLinux/patches.tgz: patches/$(LINUX_BRANCH)/*.patch
$(TAR) -czvf $@ $<
WS2-IntroToLinux/$(LINUX_DEFCONFIG): linux.build
$(CP) $(LINUX_DEFCONFIG) $@
.PHONE: ws2_output
ws2_output: $(WS2_OUTPUT_DEPS)
WS3_OUTPUT_DEPS += WS3-DevelopingDrivers/ws3_lab_environment.src
WS3_OUTPUT_DEPS += WS3-DevelopingDrivers/$(LINUX_DEFCONFIG)
WS3_OUTPUT_DEPS += WS3-DevelopingDrivers/example_drivers.tgz
WS3_OUTPUT_DEPS += WS3-DevelopingDrivers/patches.tgz
.PHONY: ws3_output
ws3_output: $(WS3_OUTPUT_DEPS)
WS3-DevelopingDrivers/ws3_lab_environment.src: linux.build
$(ECHO) "TOOLCHAIN_SOURCE=$(TOOLCHAIN_SOURCE)" > $@
$(ECHO) "TOOLCHAIN_SOURCE_TAR=$(TOOLCHAIN_SOURCE_TAR)" >> $@
$(ECHO) "TOOLCHAIN_SOURCE_PACKAGE=$(TOOLCHAIN_SOURCE_PACKAGE)" >> $@
$(ECHO) "KBUILD_BUILD_VERSION=\"$(KBUILD_BUILD_VERSION)\"" >> $@
$(ECHO) "LINUX_BRANCH=$(LINUX_BRANCH)" >> $@
$(ECHO) "LINUX_DEFCONFIG_TARGET=$(LINUX_DEFCONFIG_TARGET)" >> $@
$(ECHO) "LINUX_DEFCONFIG=$(LINUX_DEFCONFIG)" >> $@
$(ECHO) "LNX_SOURCE_PACKAGE=$(LNX_SOURCE_PACKAGE)" >> $@
WS3-DevelopingDrivers/$(LINUX_DEFCONFIG): linux.build
$(CP) $(LINUX_DEFCONFIG) WS3-DevelopingDrivers/$(LINUX_DEFCONFIG)
WS3-DevelopingDrivers/patches.tgz: patches/$(LINUX_BRANCH)/*.patch
$(TAR) -czvf $@ $<
WS3_DRIVER_SRC_FILES += demo_devmem_app/demo_devmem.c
WS3_DRIVER_SRC_FILES += demo_devmem_app/demo_devmem.h
WS3_DRIVER_SRC_FILES += demo_devmem_app/Makefile
WS3_DRIVER_SRC_FILES += demo_devmem_app/my_altera_avalon_timer_regs.h
WS3_DRIVER_SRC_FILES += demo_devmem_app/my_altera_msgdma_csr_regs.h
WS3_DRIVER_SRC_FILES += demo_devmem_app/my_altera_msgdma_descriptor_regs.h
WS3_DRIVER_SRC_FILES += demo_ioctl_test_app/ioctl_test.c
WS3_DRIVER_SRC_FILES += demo_ioctl_test_app/ioctl_test.h
WS3_DRIVER_SRC_FILES += demo_ioctl_test_app/Makefile
WS3_DRIVER_SRC_FILES += demo_map_test_app/demo_map_test.c
WS3_DRIVER_SRC_FILES += demo_map_test_app/demo_map_test.h
WS3_DRIVER_SRC_FILES += demo_map_test_app/Makefile
WS3_DRIVER_SRC_FILES += demo_map_test_app/my_altera_avalon_timer_regs.h
WS3_DRIVER_SRC_FILES += demo_uio_test_app/demo_uio_test.c
WS3_DRIVER_SRC_FILES += demo_uio_test_app/demo_uio_test.h
WS3_DRIVER_SRC_FILES += demo_uio_test_app/Makefile
WS3_DRIVER_SRC_FILES += demo_uio_test_app/my_altera_avalon_timer_regs.h
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_01.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_01t.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_02.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_03.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_04.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_05.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_05t.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_06.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_07.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_08.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_09.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_10.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_11.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_11.h
WS3_DRIVER_SRC_FILES += driver_modules/demo_module_11t.c
WS3_DRIVER_SRC_FILES += driver_modules/demo_module.h
WS3_DRIVER_SRC_FILES += driver_modules/Kbuild
WS3_DRIVER_SRC_FILES += driver_modules/Makefile
WS3_DRIVER_SRC_FILES += driver_modules/my_altera_avalon_fifo_regs.h
WS3_DRIVER_SRC_FILES += driver_modules/my_altera_avalon_timer_regs.h
WS3_DRIVER_SRC_FILES += driver_modules/my_altera_msgdma_csr_regs.h
WS3_DRIVER_SRC_FILES += driver_modules/my_altera_msgdma_descriptor_regs.h
WS3-DevelopingDrivers/example_drivers.tgz: linux.build
$(RM) $@
$(TAR) -czf $@ -C sw_src $(WS3_DRIVER_SRC_FILES)
################################################
# Help system
.PHONY: help
help: help-init help-targets help-fini
.PHONY: help-revisions
help-revisions: help-revisions-init help-revisions-list help-revisions-fini help-revision-target
.PHONY: help-revs
help-revs: help-revisions-init help-revisions-list help-revisions-fini help-revision-target-short
HELP_TARGETS_X := $(patsubst %,help-%,$(sort $(HELP_TARGETS)))
HELP_TARGET_REVISION_X := $(foreach r,$(REVISION_LIST),$(patsubst %,help_rev-%,$(sort $(HELP_TARGETS_$r))))
HELP_TARGET_REVISION_SHORT_X := $(sort $(patsubst $(firstword $(REVISION_LIST)).%,help_rev-REVISIONNAME.%,$(filter-out $(firstword $(REVISION_LIST)),$(HELP_TARGETS_$(firstword $(REVISION_LIST))))))
$(foreach h,$(filter-out $(firstword $(REVISION_LIST)),$(HELP_TARGETS_$(firstword $(REVISION_LIST)))),$(eval $(patsubst %-$(firstword $(REVISION_LIST)),%-REVISIONNAME,$h).HELP := $(subst $(firstword $(REVISION_LIST)),REVISIONNAME,$($h.HELP))))
HELP_REVISION_LIST := $(patsubst %,rev_list-%,$(sort $(REVISION_LIST)))
#cheat, put help at the end
HELP_TARGETS_X += help-help-revisions
help-revisions.HELP := Displays Revision specific Target Help
HELP_TARGETS_X += help-help-revs
help-revs.HELP := Displays Short Revision specific Target Help
HELP_TARGETS_X += help-help
help.HELP := Displays this info (i.e. the available targets)
.PHONY: $(HELP_TARGETS_X)
help-targets: $(HELP_TARGETS_X)
$(HELP_TARGETS_X): help-%:
@$(ECHO) "*********************"
@$(ECHO) "* Target: $*"
@$(ECHO) "* $($*.HELP)"
.PHONY: help-init
help-init:
@$(ECHO) "*****************************************"
@$(ECHO) "* *"
@$(ECHO) "* Manage QuartusII/QSys design *"
@$(ECHO) "* *"
@$(ECHO) "* Copyright (c) 2014 *"
@$(ECHO) "* All Rights Reserved *"
@$(ECHO) "* *"
@$(ECHO) "*****************************************"
@$(ECHO) ""
.PHONY: help-revisions-init
help-revisions-init:
@$(ECHO) ""
@$(ECHO) "*****************************************"
@$(ECHO) "* *"
@$(ECHO) "* Revision specific Targets *"
@$(ECHO) "* target-REVISIONNAME *"
@$(ECHO) "* *"
@$(ECHO) "* Available Revisions: *"
.PHONY: $(HELP_REVISION_LIST)
help-revisions-list: $(HELP_REVISION_LIST)
$(HELP_REVISION_LIST): rev_list-%:
@$(ECHO) "* -> $*"
.PHONY: help-revisions-fini
help-revisions-fini:
@$(ECHO) "* *"
@$(ECHO) "*****************************************"
@$(ECHO) ""
.PHONY: $(HELP_TARGET_REVISION_X)
.PHONY: $(HELP_TARGET_REVISION_SHORT_X)
help-revision-target: $(HELP_TARGET_REVISION_X)
help-revision-target-short: $(HELP_TARGET_REVISION_SHORT_X)
$(HELP_TARGET_REVISION_X) $(HELP_TARGET_REVISION_SHORT_X): help_rev-%:
@$(ECHO) "*********************"
@$(ECHO) "* Target: $*"
@$(ECHO) "* $($*.HELP)"
.PHONY: help-fini
help-fini:
@$(ECHO) "*********************"
################################################