summaryrefslogtreecommitdiffstats
path: root/src/Makefile
blob: 83e8994e4e5656e9c9b7cfd92bb7a90404f9c5ab (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
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/Makefile $
#
# OpenPOWER OnChipController Project
#
# Contributors Listed Below - COPYRIGHT 2014,2016
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
ifndef BASE_OBJDIR
BASE_OBJDIR = $(abspath ../obj)
endif

ifndef BASE_SRCDIR
BASE_SRCDIR = $(abspath ./)
endif

OBJDIR = $(BASE_OBJDIR)$(SUB_OBJDIR)
SRCDIR = $(BASE_SRCDIR)$(SUB_SRCDIR)

ifndef PPETRACEPP_DIR
export PPETRACEPP_DIR = $(abspath ppe/tools/ppetracepp)
endif

ifndef PPETOOLS_OBJDIR
export PPETOOLS_OBJDIR = $(abspath ../obj/ppetools)
endif

ifndef TRACEPP_DIR
export TRACEPP_DIR = $(abspath tools/tracepp)
endif

ifndef PK_SRCDIR
export PK_SRCDIR = $(abspath ppe/pk)
endif

THASH	= $(PPETRACEPP_DIR)/tracehash.pl

OCC_405_IMAGE_NAME = occ_405
OCC_GPE0_IMAGE_NAME = occ_gpe0
OCC_GPE1_IMAGE_NAME = occ_gpe1
OCC_BOOTLOADER_DIR_NAME = occBootLoader
OCC_BOOTLOADER_NAME = bootloader
IMAGE_HDR_SCRIPT = imageHdrScript

COMBINE_IMAGE_SUBDIRS = occBootLoader occ_405 occ_gpe0 occ_gpe1
COMBINEIMAGE = $(MAKE) combineImage -C $(dir)
IMAGEFILE = $(OBJDIR)/image.bin

NEEDED_IMAGES = \
     $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(IMAGE_HDR_SCRIPT) \
     $(OBJDIR)/$(OCC_405_IMAGE_NAME)/$(OCC_405_IMAGE_NAME).out \
     $(OBJDIR)/$(OCC_GPE0_IMAGE_NAME)/$(OCC_GPE0_IMAGE_NAME).out \
     $(OBJDIR)/$(OCC_GPE1_IMAGE_NAME)/$(OCC_GPE1_IMAGE_NAME).out \
     $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(OCC_BOOTLOADER_NAME).out \

.PHONY : all
all: ppetools $(NEEDED_IMAGES) combineImage tracehash

.PHONY: ppetools
ppetools: $(PPETOOLS_OBJDIR)/ppetracepp $(PPETOOLS_OBJDIR)/ppe2fsp $(PPETOOLS_OBJDIR)/tracepp

$(PPETOOLS_OBJDIR)/ppetracepp: $(PPETOOLS_OBJDIR)
	g++ -O3 -w -g -I$(PPETRACEPP_DIR)/ $(PPETRACEPP_DIR)/ppetracepp.C -o $(PPETOOLS_OBJDIR)/ppetracepp

$(PPETOOLS_OBJDIR)/ppe2fsp: $(PPETOOLS_OBJDIR)
	gcc -w -g -I./ -I$(PK_SRCDIR)/trace $(PPETRACEPP_DIR)/ppe2fsp.c $(PPETRACEPP_DIR)/ppe2fsp_cmd.c -o $(PPETOOLS_OBJDIR)/ppe2fsp

$(PPETOOLS_OBJDIR):
	mkdir -p $(PPETOOLS_OBJDIR)/

.PHONY : needed_images
needed_images: $(NEEDED_IMAGES)

.PHONY : combineImage
combineImage: $(NEEDED_IMAGES)
	rm -rf $(IMAGEFILE)
	BASE_OBJDIR=$(BASE_OBJDIR) $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(IMAGE_HDR_SCRIPT) \
    $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(OCC_BOOTLOADER_NAME).bin \
	$(OBJDIR)/$(OCC_405_IMAGE_NAME)/$(OCC_405_IMAGE_NAME).bin \
	$(OBJDIR)/$(OCC_GPE0_IMAGE_NAME)/$(OCC_GPE0_IMAGE_NAME).bin \
	$(OBJDIR)/$(OCC_GPE1_IMAGE_NAME)/$(OCC_GPE1_IMAGE_NAME).bin \
    t2 \
	`md5sum $(OBJDIR)/$(OCC_405_IMAGE_NAME)/$(OCC_405_IMAGE_NAME).bin | cut -c 1-4`

#clean the obj directory
.PHONY : clean
clean:
	rm -fr $(OBJDIR)

# Make binary application images
.PHONY : $(OBJDIR)/$(OCC_405_IMAGE_NAME)/$(OCC_405_IMAGE_NAME).out
$(OBJDIR)/$(OCC_405_IMAGE_NAME)/$(OCC_405_IMAGE_NAME).out:
	(cd $(SRCDIR)/$(OCC_405_IMAGE_NAME) && make)

.PHONY : $(OBJDIR)/$(OCC_GPE0_IMAGE_NAME)/$(OCC_GPE0_IMAGE_NAME).out
$(OBJDIR)/$(OCC_GPE0_IMAGE_NAME)/$(OCC_GPE0_IMAGE_NAME).out:
	(cd $(SRCDIR)/$(OCC_GPE0_IMAGE_NAME) && make)

.PHONY : $(OBJDIR)/$(OCC_GPE1_IMAGE_NAME)/$(OCC_GPE1_IMAGE_NAME).out
$(OBJDIR)/$(OCC_GPE1_IMAGE_NAME)/$(OCC_GPE1_IMAGE_NAME).out:
	(cd $(SRCDIR)/$(OCC_GPE1_IMAGE_NAME) && make)

.PHONY : $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(OCC_BOOTLOADER_NAME).out
$(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(OCC_BOOTLOADER_NAME).out $(OBJDIR)/$(OCC_BOOTLOADER_DIR_NAME)/$(IMAGE_HDR_SCRIPT):
	(cd $(SRCDIR)/$(OCC_BOOTLOADER_DIR_NAME) && make)

$(PPETOOLS_OBJDIR)/tracepp:
	(cd $(TRACEPP_DIR) && make)

# collect all of the trace hash files for all OCC images into a single trexStringFile
.PHONY : tracehash
tracehash:
	mkdir -p $(BASE_OBJDIR)
	$(THASH) -c -d $(BASE_OBJDIR) -s $(BASE_OBJDIR)/occStringFile

OpenPOWER on IntegriCloud