-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
137 lines (116 loc) · 4.01 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Copyright (C) Teemu Suutari
VPATH := library testing
# possible targets:
# Amiga build with vbcc
# AmigaG build with m68k-amigaos-gcc, requires https://github.com/bebbo/amiga-gcc
# AmigaS build with SAS/C, requires vamos (https://github.com/cnvogelg/amitools) on Linux/MacOS
# * build with clang for testing
TARGET ?= AmigaG
# set vamos if cross compile
ifneq ($(shell uname -s),AmigaOS)
VAMOS = vamos -q --
endif
# because SAS/C has non standard arguments
CFLAGC = -c
CFLAGD = -D
CFLAGO = -o
CFLAGP = -o
ifeq (,$(findstring Amiga,$(TARGET)))
# non Amiga targets
CC = clang
CFLAGS = -g -Wall -Werror -Ilibrary -I.
LDFLAGS =
INTEGRATION_OBJ = archivefs_integration_unix.o
LIB =
else
# Amiga* targets
# too lazy to construct AS for gcc/sas
AS = vasmm68k_mot -Fhunk -I$(INCLUDEOS3) -quiet
ifeq ($(TARGET),AmigaV)
CC = vc
CFLAGS = -Ilibrary -I. -I$(INCLUDEOS3) -sc -O2
CFSPEED = -speed
CFLAGO = -o
CFLAGP = -o
LDFLAGS = -sc -final
MKLIB = $(CC) $(LDFLAGS) -bamigahunk -x -Bstatic -Cvbcc -nostdlib -mrel -lvc -lamiga $(CFLAGP)$@ $^
CCVER = vbccm68k 2>/dev/null | awk '/vbcc V/ { printf " "$$1" "$$2 } /vbcc code/ { printf " "$$4" "$$5 }'
endif
ifeq ($(TARGET),AmigaG)
CC = m68k-amigaos-gcc
CFLAGS = -g -Wall -Ilibrary -I. -O2 -noixemul
CFSPEED = -O3
LDFLAGS = -noixemul
MKLIB = m68k-amigaos-ld $(CFLAGP)$@ $^ -lc --strip-all
CCVER = m68k-amigaos-gcc --version | awk '/m68k/ { printf " "$$0 }'
endif
ifeq ($(TARGET),AmigaS)
CC = $(VAMOS) sc
CFLAGS = Data=FarOnly IdentifierLength=40 IncludeDirectory=library Optimize OptimizerSchedule NoStackCheck NoVersion
CFSPEED = OptimizerTime OptimizerComplexity=10 OptimizerInLocal
CFLAGC =
CFLAGD = Define=
CFLAGO = ObjectName=
CFLAGP = ProgramName=
LDFLAGS = Link SmallData SmallCode
MKLIB = $(VAMOS) slink SmallData SmallCode Quiet Lib lib:sc.lib To $@ From $^
CCVER = $(VAMOS) sc | awk '/^SAS/ { printf " "$$0 }'
endif
ifeq ($(CCVER),)
$(error supported TARGETs are AmigaG, AmigaS, AmigaV)
endif
INTEGRATION_OBJ = archivefs_integration_amiga.o
LIB = WHDLoad.VFS
endif
PROG = test
OBJS = $(addprefix obj/,archivefs_api.o archivefs_common.o archivefs_lha.o archivefs_zip.o \
archivefs_huffman_decoder.o archivefs_lha_decompressor.o archivefs_zip_decompressor.o)
OBJS_TEST = $(addprefix obj/,test.o CRC32.o $(INTEGRATION_OBJ)) $(OBJS)
OBJS_LIB = $(addprefix obj/,archivefs_header.o archivefs_integration_amiga_standalone.o) $(OBJS)
all: $(PROG) $(LIB)
obj:
mkdir $@
obj/%.o: %.S .date .ccver | obj
$(AS) -o $@ $<
obj/archivefs_integration_amiga_standalone.o: archivefs_integration_amiga.c | obj
$(CC) $(CFLAGS) $(CFLAGO)$@ $(CFLAGC) $< $(CFLAGD)ARCHIVEFS_STANDALONE=1
obj/archivefs_huffman_decoder.o: CFLAGS+=$(CFSPEED)
obj/archivefs_lha_decompressor.o: CFLAGS+=$(CFSPEED)
obj/archivefs_zip_decompressor.o: CFLAGS+=$(CFSPEED)
obj/%.o: %.c | obj
$(CC) $(CFLAGS) $(CFLAGO)$@ $(CFLAGC) $<
$(PROG): $(OBJS_TEST)
$(CC) $(LDFLAGS) $(CFLAGP)$@ $^
$(LIB): $(OBJS_LIB)
$(MKLIB)
.date:
date "+(%d.%m.%Y)" | xargs printf > $@
.ccver:
$(CCVER) > $@
.PHONY: all clean .date .ccver
clean:
rm -f $(OBJS_LIB) $(OBJS_TEST) $(PROG) $(LIB) *~ */*~ .date .ccver *.lnk
test -d obj && rmdir obj || true
run_tests: $(PROG)
@./testing/run_test.sh testing/test1.txt
@./testing/run_test.sh testing/test2.txt
@./testing/run_test.sh testing/test3.txt
@./testing/run_test.sh testing/test4.txt
@./testing/run_test.sh testing/test5.txt
@./testing/run_test.sh testing/test6.txt
@./testing/run_test.sh testing/test7.txt
@./testing/run_test.sh testing/test8.txt
@./testing/run_test.sh testing/test9.txt
@./testing/run_test.sh testing/test10.txt
@./testing/run_test.sh testing/test11.txt
@./testing/run_test.sh testing/test12.txt
@./testing/run_test.sh testing/test13.txt
@./testing/run_test.sh testing/test14.txt
@./testing/run_test.sh testing/test15.txt
@./testing/run_test.sh testing/test16.txt
@./testing/run_test.sh testing/test17.txt
@./testing/run_test.sh testing/test18.txt
@./testing/run_test.sh testing/test19.txt
@./testing/run_test.sh testing/test20.txt
@./testing/run_test.sh testing/test21.txt
@./testing/run_test.sh testing/test22.txt