-
Notifications
You must be signed in to change notification settings - Fork 1
/
atto.mk
75 lines (62 loc) · 1.68 KB
/
atto.mk
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
.SUFFIXES:
.DEFAULT:
MAKEFLAGS += -r --no-print-directory
BUILDDIR ?= build
CC ?= cc
CFLAGS += -Wall -Wextra -Werror -I$(ATTO_BASEDIR)/include -I$(ATTO_BASEDIR)/src
ifeq ($(DEBUG), 1)
CONFIG = dbg
CFLAGS += -O0 -ggdb3
else
CONFIG = rel
CFLAGS += -O3
endif
ifeq ($(RASPBERRY), 1)
PLATFORM = pi
ifeq ($(CROSS), 1)
RPI_ROOT ?= $(HOME)/opt/raspberry-pi
RPI_TOOLS ?= $(RPI_ROOT)/tools
RPI_TOOLCHAIN ?= gcc-linaro-arm-linux-gnueabihf-raspbian-x64
RPI_TOOLCHAINDIR ?= $(RPI_TOOLS)/arm-bcm2708/$(RPI_TOOLCHAIN)
RPI_FIRMWARE ?= $(RPI_ROOT)/firmware
RPI_VCDIR ?= $(RPI_FIRMWARE)/hardfp/opt/vc
CC = $(RPI_TOOLCHAINDIR)/bin/arm-linux-gnueabihf-gcc
COMPILER = gcc
else
RPI_VCDIR ?= /opt/vc
CC ?= cc
endif
CFLAGS += -I$(RPI_VCDIR)/include -I$(RPI_VCDIR)/include/interface/vcos/pthreads
CFLAGS += -I$(RPI_VCDIR)/include/interface/vmcs_host/linux -DATTO_PLATFORM_RPI
LIBS += -lbrcmGLESv2 -lbrcmEGL -lbcm_host -lvchiq_arm -lvcos -L$(RPI_VCDIR)/lib -lrt -lm -pthread
ATTO_SOURCES += \
$(ATTO_BASEDIR)/src/app_linux.c \
$(ATTO_BASEDIR)/src/app_rpi.c
else
PLATFORM = linux-x11
COMPILER ?= $(CC)
CC ?= cc
CFLAGS += -pedantic
LIBS += -lX11 -lXfixes -lGL -lm -pthread
ifeq ($(EGL), 1)
CFLAGS += -DATTO_EGL=1
LIBS += -lEGL
endif
ATTO_SOURCES += \
$(ATTO_BASEDIR)/src/app_linux.c \
$(ATTO_BASEDIR)/src/app_x11.c
endif
DEPFLAGS = -MMD -MP
COMPILE.c = $(CC) -std=gnu99 $(CFLAGS) $(DEPFLAGS) -MT $@ -MF $@.d
OBJDIR ?= $(BUILDDIR)/$(PLATFORM)-$(CONFIG)
$(OBJDIR)/%.c.o: %.c
@mkdir -p $(dir $@)
$(COMPILE.c) -c $< -o $@
# TODO how to handle ../
ATTO_OBJS = $(ATTO_SOURCES:%=$(OBJDIR)/%.o)
ATTO_DEPS = $(ATTO_OBJS:%=%.d)
-include $(ATTO_DEPS)
all:
clean:
rm -rf build
.PHONY: all clean