summaryrefslogtreecommitdiff
path: root/recipes/dvsdk/files/Makefile-dsplink-gpp
blob: d9f2f6209a7612fe3bc3347f82182e48f263c99b (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
# Composite Makefile
DIRSEP=/

TI_DSPLINK_RELATIVE_PATH :=../../../../

# include the CURRENTCFG.mk
include $(DSPLINK)$(DIRSEP)config$(DIRSEP)BUILD$(DIRSEP)CURRENTCFG.MK

# Generate the list of sources
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)arch$(DIRSEP)SOURCES
ARCH_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)arch$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)SOURCES
LDRV_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
LDRV_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)ldrv$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)gen$(DIRSEP)SOURCES
GEN_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)gen$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)SOURCES
PMGR_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
PMGR_SOURCES += $(addpreifx $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP)SOURCES
PMGR_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)pmgr$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)SOURCES
OSAL_SOURCES := $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
OSAL_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP)SOURCES
OSAL_SOURCES += $(addprefix $(TI_DSPLINK_RELATIVE_PATH)gpp$(DIRSEP)src$(DIRSEP)osal$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(TI_DSPLINK_GPPOSVERSION)$(DIRSEP),$(SOURCES))

DSPLINK_SOURCES := $(ARCH_SOURCES) $(LDRV_SOURCES) $(GEN_SOURCES) $(OSAL_SOURCES) $(PMGR_SOURCES)
DSPLINK_OBJS    := $(foreach srcFile, $(DSPLINK_SOURCES),$(basename $(srcFile)).o)

# EXTRA_CFLAGS
EXTRA_CFLAGS += $(addprefix -D, $(TI_DSPLINK_GPP_DEFINES))
EXTRA_CFLAGS += $(addprefix -I, $(TI_DSPLINK_GPP_INC_PATH))
EXTRA_CFLAGS += -DEXPORT_SYMTAB
EXTRA_CFLAGS += -DTRACE_KERNEL

ifneq ($(KERNELRELEASE),)
obj-m	:= dsplinkk.o
dsplinkk-objs := $(DSPLINK_OBJS)
else
KDIR    := /path/to/kernel/
PWD	:= $(shell pwd) 
driver:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
endif

clean:
	@echo DSPLINK - cleaning driver, library and samples
	find $(DSPLINK) -name "*.o" -exec rm {} \;
	rm -fr dsplinkk.ko  dsplinkk.mod.c Module.symvers *gpp *.a *.lib

################################################################################################
# USER SIDE
BUILD_CONFIG := ..$(DIRSEP)..$(DIRSEP)..$(DIRSEP)config$(DIRSEP)BUILD
# Generate the list of sources
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)SOURCES
API_SOURCES := $(addprefix $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP),$(SOURCES))
SOURCES :=
include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)SOURCES
API_SOURCES += $(addprefix $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)api$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP),$(SOURCES))

# Update the CFLAG
#CC     = arm-none-linux-gnueabi-gcc
#AR     = arm-none-linux-gnueabi-ar
#LD     = arm-none-linux-gnueabi-ld
ARFLAGS = -rs
LDFLAGS = -r
EXTRA_CFLAGS += $(addprefix -D, $(TI_DSPLINK_GPP_DEFINES)) $(addprefix -I, $(TI_DSPLINK_GPP_INC_PATH))

define CONFIG_template
$(shell cp $(DSPLINK)$(DIRSEP)config$(DIRSEP)all$(DIRSEP)$(1) $(DSPLINK)$(DIRSEP)config$(DIRSEP)BUILD$(DIRSEP))
endef

define PROGRAM_template 
$(basename $(1)).o: $(1)
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $(1) -o $(basename $(1)).o
endef
$(foreach prog,$(API_SOURCES),$(eval $(call PROGRAM_template,$(prog))))
$(foreach prog,$(CONFIG),$(eval $(call CONFIG_template,$(prog))))

DSPLINK_API_OBJS := $(foreach srcFile, $(API_SOURCES),$(basename $(srcFile)).o)

library: $(DSPLINK_API_OBJS)
	@echo DSPLINK - building user library - dsplink.lib
	$(LD) $(LDFLAGS) -o dsplink.lib $(DSPLINK_API_OBJS)
	$(AR) $(ARFLAGS) dsplink.a $(DSPLINK_API_OBJS)

	
######################################### SAMPLES ###################################
SOURCES :=
define SAMPLES_template
ifneq ($(1),message_multi)
$(1): $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(1).c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(1)_os.c
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS) -o $(1)gpp $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(1).c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)$(1)_os.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)main.c dsplink.lib -lpthread
else
$(1): $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)message.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)message_os.c
    $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1) -I$(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS) -o $(1)gpp $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)message.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)message_os.c $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)$(1)$(DIRSEP)$(TI_DSPLINK_GPPOS)$(DIRSEP)main.c dsplink.lib -lpthread
endif
endef

include $(TI_DSPLINK_GPPROOT)$(DIRSEP)src$(DIRSEP)samples$(DIRSEP)DIRS
$(foreach prog,$(DIRS),$(eval $(call SAMPLES_template,$(prog))))

samples: $(foreach prog,$(DIRS),$(prog))

all: driver library samples