forked from cdhooper/amiga_devtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (68 loc) · 2.37 KB
/
Makefile
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
#
# Makefile to build devtest for AmigaOS/68k using Bebbo's GCC cross-compiler.
#
VER ?= 1.6c
PROG := devtest
OBJDIR := objs
SRCS := devtest.c
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
CC := m68k-amigaos-gcc
CFLAGS := -Wall -Wextra -Wno-pointer-sign -fomit-frame-pointer
CFLAGS += -Wno-strict-aliasing
CFLAGS += -Wpedantic -Wno-overflow
# clib2 crashes on exit under Kickstart 2.x
LDFLAGS := -Xlinker -Map=$(OBJDIR)/[email protected] -Wa,-a > $(OBJDIR)/[email protected] -fomit-frame-pointer -lgcc -lc -lamiga -mcrt=clib2
# -noixemul generates significantly larger binaries, but KS 2.x is supported
#LDFLAGS := -Xlinker -Map=$(OBJDIR)/[email protected] -Wa,-a > $(OBJDIR)/[email protected] -fomit-frame-pointer -lgcc -lc -lamiga -noixemul
#CFLAGS += -flto
#LDFLAGS += -flto
#VER := $(PROG)_$(shell awk '/char[[:space:]]*\*version =/{print $$7}' devtest.c)
PROGVER := $(PROG)_$(VER)
CFLAGS += -Os -DVER=\"$(VER)\"
#CFLAGS += -g
# If verbose is specified with no other targets, then build everything
ifeq ($(MAKECMDGOALS),verbose)
verbose: all
endif
ifeq (,$(filter verbose timed, $(MAKECMDGOALS)))
QUIET := @
else
QUIET :=
endif
ifeq (, $(shell which $(CC) 2>/dev/null ))
$(error "No $(CC) in PATH: maybe do PATH=$$PATH:/opt/amiga/bin")
endif
all: $(PROG)
define DEPEND_SRC
# The following line creates a rule for an object file to depend on a
# given source file.
$(patsubst %,$(OBJDIR)/%,$(filter-out $(OBJDIR)/%,$(basename $(1)).o)) $(filter $(OBJDIR)/%,$(basename $(1)).o): $(1)
endef
$(foreach SRCFILE,$(SRCS),$(eval $(call DEPEND_SRC,$(SRCFILE))))
$(OBJS): Makefile | $(OBJDIR)
@echo Building $@
$(QUIET)$(CC) $(CFLAGS) -c $(filter %.c,$^) -o $@
$(PROG): $(OBJS)
@echo Building $@
$(QUIET)$(CC) $(OBJS) $(LDFLAGS) -o $@
$(OBJDIR):
mkdir -p $@
zip:
@echo Building $(PROGVER).zip
$(QUIET)rm -rf $(PROG).zip $(PROGVER)
$(QUIET)mkdir $(PROGVER)
$(QUIET)cp -p $(PROG) README.md $(PROGVER)/
$(QUIET)zip -rq $(PROGVER).zip $(PROGVER)
$(QUIET)rm -rf $(PROGVER)
lha:
@echo Building $(PROGVER).lha
$(QUIET)rm -rf $(PROG).zip $(PROGVER)
$(QUIET)mkdir $(PROGVER)
$(QUIET)cp -p $(PROG) README.md $(PROGVER)/
$(QUIET)lha -aq2 $(PROGVER).lha $(PROGVER)
$(QUIET)rm -rf $(PROGVER)
clean:
rm -f $(OBJS) $(OBJDIR)/*.map $(OBJDIR)/*.lst
FLINT_FILE=flexelint.lnt
flint:
flexelint -v -w3 -I/opt/amiga/m68k-amigaos/ndk-include -I/opt/amiga/m68k-amigaos/sys-include -I/opt/amiga/m68k-amigaos/clib2/include flexelint.lnt $(SRCS)