-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.MIPS+nc
64 lines (50 loc) · 2.07 KB
/
Makefile.MIPS+nc
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
.PHONY: all config debug prerelease release wild help
ROOTDIR := $(CURDIR)
include $(ROOTDIR)/src-build/default-config.mk
# WARNING!
# If you want to move to another architecture, you might have to recompile ncurses from sources!
# cross-compiler
ifeq ($(strip $(CROSS_COMPILE)),)
CROSS_COMPILE := /home/striker/bin/cross-compile/openwrt-sdk-18.06.1-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/bin/mips-openwrt-linux-musl-
endif
override CC := $(CROSS_COMPILE)gcc
override DEPDIR := $(ROOTDIR)/src-deps
# whole solution flags
CFLAGS := -ansi -Wextra -pedantic -Wno-unused-parameter
CFLAGS += -march=24kc -mtune=24kc -msoft-float -I$(DEPDIR)/ncurses/include
# link with target libc by toolchain
# it is known for me how to link with target libc, but not ncurses..
# here musl instead of glibc
LDFLAGS := -msoft-float -L$(DEPDIR)/ncurses/lib
# this is a quirk of openwrt mips toolchain
export STAGING_DIR := /tmp
# export ALL variables
export
# TARGETS
all: config
@CONFIG=$(CONFIG) $(MAKE) -$(MKFLG)C $(SRCDIR) projects
# BUILD CONFIGURATIONS
# optimized for tp-link tl-wr1043nd v1 router with openwrt, you can set another one
# To build everything, type `make` or `make debug`, which are equal, or `make release`, or `make wild`
# To build one project, for ex. `cs` in wild configuration, type `CONFIG=wild make cs`
config:
CONFIG := $(shell echo $(CONFIG) | tr A-Z a-z)
ifeq ($(strip $(CONFIG)),wild)
CFLAGS += -O3 -D NDEBUG -D RELEASE -D WILDRELEASE
LDFLAGS += -s
else ifeq ($(strip $(CONFIG)),release)
CFLAGS += -O3 -D NDEBUG -D RELEASE
LDFLAGS += -s
else ifeq ($(strip $(CONFIG)),debug)
CFLAGS += -O0 -ggdb -ffunction-sections -D DEBUG
CFLAGS += -D VALGRIND_SUCKS
# ifeq ($(strip $(CONFIG)),prerelease)
else
CONFIG := prerelease
CFLAGS += -O3 -D NDEBUG -D RELEASE -g
endif
include $(ROOTDIR)/src-build/help.mk
# last resort target, to redirect all lower level targets
# https://www.gnu.org/software/make/manual/html_node/Last-Resort.html
%::
@CONFIG=$(CONFIG) $(MAKE) -$(MKFLG)C $(SRCDIR) $@