-
Notifications
You must be signed in to change notification settings - Fork 139
/
Makefile.libraries
65 lines (58 loc) · 2.63 KB
/
Makefile.libraries
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
# This should be called from the Bela folder, with
# make -f Makefile.libraries LIBRARY=libraryname
# set defaults
CC := clang
CXX := clang++
LIBRARY_CC ?= $(CC)
LIBRARY_CXX ?= $(CXX)
.DEFAULT_GOAL := library
AT?=@
#TODO: these variables should actually be conditional and/or shared with the Base Makefile
# although they are not really needed if this Makefile is called from the main Makefile
BELA_USE_DEFINE:=BELA_USE_RTDM
DEBIAN_VERSION :=stretch
BASE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
DEFAULT_COMMON_FLAGS := -O3 -g -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -ffast-math -fPIC
LIBRARY_CXXFLAGS := $(DEFAULT_COMMON_FLAGS) -std=c++11
LIBRARY_CFLAGS := $(DEFAULT_COMMON_FLAGS) -std=gnu11
#all this Xenomai stuff is just for Midi.h at the moment and requires you to have run the Bela Makefile before
SYSTEM_SPECIFIC_MAKEFILE=/tmp/BelaMakefile.inc
include $(SYSTEM_SPECIFIC_MAKEFILE)
$(SYSTEM_SPECIFIC_MAKEFILE):
make lib
LIBRARY_CPPFLAGS = $(DEFAULT_XENOMAI_CFLAGS) -I$(BASE_DIR) -I$(BASE_DIR)/include -DNDEBUG -D$(BELA_USE_DEFINE) -I$(BASE_DIR)/resources/$(DEBIAN_VERSION)/include -MMD -MP -MT"$(@)" -MF"$(@:%.o=%.d)"
#
# the above default variables may be modified by the Makefile included here:
MKFILE_COMPILE := libraries/$(LIBRARY)/build/Makefile.compile
-include $(MKFILE_COMPILE)
-include libraries/*/build/*.d
LIBRARY_DIR := libraries/$(LIBRARY)
LIBRARY_BUILD_DIR := $(LIBRARY_DIR)/build
LIBRARY_FILES := $(wildcard $(LIBRARY_DIR)/*.c $(LIBRARY_DIR)/*.cpp)
LIBRARY_CPPS := $(wildcard $(LIBRARY_DIR)/*.cpp)
LIBRARY_OBJS :=$(LIBRARY_CPPS:$(LIBRARY_DIR)/%.cpp=$(LIBRARY_DIR)/build/%.o)
LIBRARY_CS := $(wildcard $(LIBRARY_DIR)/*.c)
LIBRARY_OBJS := $(LIBRARY_OBJS) $(LIBRARY_CS:$(LIBRARY_DIR)/%.c=$(LIBRARY_DIR)/build/%.o)
#LIBRARY_OBJS := $(LIBRARY_OBJS) $(LIBRARY_FILES:$(LIBRARY_DIR)/%.c=$(LIBRARY_DIR)/build/%.o)
#$(warning FILES: $(LIBRARY_FILES))
#$(warning OBJS: $(LIBRARY_OBJS))
ifneq (,$(filter all,$(MAKECMDGOALS)))
ALL_LIBRARIES := $(shell ls -d libraries/*)
endif
.PHONY: $(ALL_LIBRARIES)
$(ALL_LIBRARIES):
$(AT) LIB=$(@:libraries/%=%); echo Building library $$LIB; $(MAKE) -f Makefile.libraries LIBRARY=$$LIB --no-print-directory
all: $(ALL_LIBRARIES)
library: $(LIBRARY_OBJS)
clean:
$(AT) rm -rf $(LIBRARY_OBJS)
cleanall:
$(AT) rm -rf libraries/*/build
$(LIBRARY_BUILD_DIR)/%.o: $(LIBRARY_DIR)/%.c
$(AT) $(LIBRARY_CC) -c $< -o $@ $(LIBRARY_CPPFLAGS) $(LIBRARY_CFLAGS)
$(LIBRARY_BUILD_DIR)/%.o: $(LIBRARY_DIR)/%.cpp
$(AT) $(LIBRARY_CXX) -c $< -o $@ $(LIBRARY_CPPFLAGS) $(LIBRARY_CXXFLAGS)
ifneq ($(LIBRARY),)
$(MKFILE_COMPILE):
$(AT) resources/tools/detectlibraries.sh --library $(LIBRARY)
endif