summaryrefslogtreecommitdiffstats
path: root/sbe/sample/Makefile
blob: f986ce8b583cee3ed32d84e6b168a17cfde6c280 (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
#remove this once we have a real compiler
export P2P_ENABLE = 1

#Pull in the definitions that affect all makefiles for this image
include img_defs.mk

#Pull in object file names for the top directory
include topfiles.mk

ifdef P2P_ENABLE
include $(P2P_SRCDIR)/p2pfiles.mk
endif

PK_MAKE_DIR := $(PK_SRCDIR)/$(PPE_TYPE)
OBJS := $(addprefix $(OBJDIR)/, $(TOP_OBJECTS))
PKLIB := $(OBJDIR)/pk/libpk.a

LIB_DIRS = -L$(OBJDIR)/pk #-L$(OBJDIR)/commonlib
LINK_OBJS = $(OBJS) $(PKLIB) #$(COMMONLIB)
LINK_SCRIPT = $(addprefix $(OBJDIR)/, linkscript)

ifdef P2P_ENABLE
P2PLIB := $(OBJDIR)/p2p/libp2p.a
LIB_DIRS += -L$(OBJDIR)/p2p
LINK_OBJS += $(P2PLIB)
endif

#default target is to make a binary application image
#This removes all unecessary headers from the ELF executable
$(OBJDIR)/$(IMAGE_NAME).bin $(OBJDIR)/$(IMAGE_NAME).dis: $(OBJDIR)/$(IMAGE_NAME).out
	$(OBJCOPY) -O binary  $< $(OBJDIR)/$(IMAGE_NAME).bin
	$(OBJDUMP) -S $< > $(OBJDIR)/$(IMAGE_NAME).dis

#create a linked ELF executable
$(OBJDIR)/$(IMAGE_NAME).out: $(LINK_OBJS) $(LINK_SCRIPT)
	$(LD) -e __system_reset -T$(LINK_SCRIPT) -Map $(OBJDIR)/$(IMAGE_NAME).map -Bstatic -o $(OBJDIR)/$(IMAGE_NAME).out $(LIB_DIRS) $(OBJS) -lpk -lp2p #-lcommon

#pass the link command file through the C preprocessor to evaluate macros and remove comments
$(LINK_SCRIPT): link.cmd
	$(CPP) -E -x c++ -P $(DEFS) link.cmd -o $(LINK_SCRIPT)

#Create an obj directory if needed
$(LINK_OBJS) $(OBJS) $(OBJS:.o=.d): | $(OBJDIR)

$(OBJDIR):
	mkdir -p $(OBJDIR)

.PHONY: clean $(PKLIB) $(P2PLIB)

#Build macro-specific kernel code
$(PKLIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(PK_MAKE_DIR)

#Build the code that is common for all processors (PPEs and 405)
#$(COMMONLIB):
#	$(MAKE) -I $(IMAGE_SRCDIR) -C $(COMMONLIB_SRCDIR)

ifdef P2P_ENABLE
$(P2PLIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(P2P_SRCDIR)
endif 

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

#clean the kernel directory first, then the application level clean
clean:
	rm -fr $(OBJDIR)

#Add dependencies to header files
ifneq ($(MAKECMDGOALS),clean)
include $(OBJS:.o=.d) 
endif
OpenPOWER on IntegriCloud