Commit MetaInfo

Revisionaf215648fa99f5573de5d49320daa7e9ac8a4c02 (tree)
Time2021-01-13 19:19:02
Authoringlorion <homemicro@ingl...>
Commiteringlorion

Log Message

added top-level configure script

Change Summary

Incremental Difference

diff -r ae6e9946c36e -r af215648fa99 README
--- a/README Wed Sep 15 23:52:29 2021 +0100
+++ b/README Wed Jan 13 02:19:02 2021 -0800
@@ -41,11 +41,12 @@
4141
4242 : aptitude install binutils-avr gcc make xa65 libxcb1-dev libc6-dev pkg-config
4343
44-In general, the code can be built by cd'ing into the directory that
45-contains the configure script or the Makefile. In case of a configure
46-script, you can then run ./configure to create the Makefile. When
47-the Makefile is present, you can run make to build the software. make
48-clean will remove generated files except the final targets, and make
49-distclean will remove all generated files.
44+The code can be built from the top-level directory by running:
5045
46+ $ ./configure
47+ $ make
5148
49+The command "make clean" can be used to remove intermediate files that
50+were created during the build, but leave the final build targets in
51+place. The command "make distclean" can be used to remove both the
52+intermediate files and the final build targets.
diff -r ae6e9946c36e -r af215648fa99 apps/micrornd/test.c
--- a/apps/micrornd/test.c Wed Sep 15 23:52:29 2021 +0100
+++ b/apps/micrornd/test.c Wed Jan 13 02:19:02 2021 -0800
@@ -4,11 +4,6 @@
44
55 #define START 0x0400
66
7-static void push(hm1k_state *s, uint8_t value) {
8- s->ram[0x100 + s->s] = value;
9- --s->s;
10-}
11-
127 static void push_return_address(hm1k_state *s, uint16_t addr) {
138 --addr;
149 push(s, addr >> 8);
diff -r ae6e9946c36e -r af215648fa99 configure
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configure Wed Jan 13 02:19:02 2021 -0800
@@ -0,0 +1,155 @@
1+#! /bin/sh
2+
3+detect_xcb() {
4+ have_xcb=true
5+ xcb_cflags=$(pkg-config --cflags xcb)
6+ s=$?
7+ if [ $s -ne 0 ]
8+ then
9+ printf 'Error determining cflags for xcb. Is it installed?\n' >&2
10+ have_xcb=false
11+ return
12+ fi
13+
14+ xcb_libs=$(pkg-config --libs xcb)
15+ s=$?
16+ if [ $s -ne 0 ]
17+ then
18+ printf 'Error determining libs for xcb. Is it installed?\n' >&2
19+ have_xcb=false
20+ fi
21+}
22+
23+cflags=${CFLAGS:--O3}
24+
25+detect_xcb
26+
27+have_xa=true
28+xa=xa
29+$xa --version | grep -q xa65 || have_xa=false
30+
31+tools="cartridge/readcart cartridge/writecart gpios_low memory/readmem \
32+ memory/writemem memory/writerom"
33+
34+targets='emulator/test_ret1'
35+objects='emulator/test_ret1.o tools/gpio.o'
36+
37+for tool in $tools
38+do
39+ targets="$targets tools/$tool"
40+done
41+
42+if [ "$have_xa" = "true" ]
43+then
44+ targets="$targets rom/rom.bin apps/micrornd/test apps/micrornd/test.bin"
45+ for app in donothing emutest micrornd showchars testkeys
46+ do
47+ targets="$targets apps/$app/$app.bin"
48+ objects="$objects apps/micrornd/test.o"
49+ done
50+fi
51+
52+if [ "$have_xcb" = "true" ]
53+then
54+ targets="$targets emulator/hm1000"
55+ objects="$objects emulator/main.o emulator/xcb.o"
56+fi
57+
58+cat > Makefile <<EOF
59+CFLAGS = $cflags
60+
61+XA = $xa
62+
63+TARGETS = $targets
64+OBJECTS = $objects
65+
66+all : \$(TARGETS)
67+
68+clean :
69+ -rm \$(OBJECTS)
70+
71+distclean : clean
72+ -rm \$(TARGETS) Makefile
73+
74+emulator/test_ret1 : emulator/test_ret1.o
75+ \$(CC) \$(CFLAGS) -o emulator/test_ret1 emulator/test_ret1.o
76+
77+emulator/test_ret1.o : emulator/test_ret1.c emulator/hm1000.c emulator/ops.inc
78+ \$(CC) \$(CFLAGS) -c emulator/test_ret1.c -o emulator/test_ret1.o
79+
80+tools/gpio.o : tools/gpio.c tools/gpio.h
81+ \$(CC) \$(CFLAGS) -c tools/gpio.c -o tools/gpio.o
82+
83+EOF
84+
85+for tool in $tools
86+do
87+ cat >>Makefile <<EOF
88+tools/$tool : tools/$tool.c tools/gpio.o
89+ \$(CC) \$(CFLAGS) tools/$tool.c tools/gpio.o -o tools/$tool
90+EOF
91+done
92+
93+if [ "$have_xa" = "true" ]
94+then
95+ cat >>Makefile <<EOF
96+apps/donothing/donothing.bin : apps/donothing/donothing.s
97+ \$(XA) -M -bt 768 apps/donothing/donothing.s -o apps/donothing/donothing.bin
98+
99+apps/micrornd/micrornd.bin : apps/micrornd/micrornd.s apps/micrornd/micrornd_code.inc apps/micrornd/micrornd_data.inc
100+ \$(XA) -Iapps/micrornd -M -bt 57344 apps/micrornd/micrornd.s -o apps/micrornd/micrornd.bin
101+
102+apps/micrornd/test : apps/micrornd/test.o apps/micrornd/test.bin
103+ \$(CC) \$(CFLAGS) apps/micrornd/test.o -o apps/micrornd/test
104+
105+apps/micrornd/test.bin : apps/micrornd/test.s apps/micrornd/micrornd_code.inc apps/micrornd/micrornd_data.inc
106+ \$(XA) -Iapps/micrornd -M -bt 1024 apps/micrornd/test.s -o apps/micrornd/test.bin
107+
108+apps/micrornd/test.o : apps/micrornd/test.c emulator/hm1000.h emulator/hm1000.c
109+ \$(CC) \$(CFLAGS) -Iemulator -c apps/micrornd/test.c -o apps/micrornd/test.o
110+
111+rom/rom.bin : rom/rom.s rom/8x8font.inc
112+ \$(XA) -Irom -M -bt 57344 rom/rom.s -o rom/rom.bin
113+
114+EOF
115+
116+ for app in emutest showchars testkeys
117+ do
118+ cat >>Makefile <<EOF
119+apps/$app/$app.bin : apps/$app/$app.s
120+ \$(XA) -M -bt 57344 apps/$app/$app.s -o apps/$app/$app.bin
121+
122+EOF
123+ done
124+fi
125+
126+if [ "$have_xcb" = "true" ]
127+then
128+ cat >>Makefile <<EOF
129+emulator/hm1000 : emulator/main.o emulator/xcb.o
130+ \$(CC) \$(CFLAGS) $xcb_cflags emulator/main.o emulator/xcb.o -o emulator/hm1000 $xcb_libs
131+
132+emulator/main.o : emulator/main.c emulator/hm1000.c emulator/hm1000.h emulator/ops.inc emulator/xcb.h
133+ \$(CC) \$(CFLAGS) $xcb_cflags -c emulator/main.c -o emulator/main.o
134+
135+emulator/xcb.o : emulator/xcb.c emulator/xcb.h
136+ \$(CC) \$(CFLAGS) $xcb_cflags -c emulator/xcb.c -o emulator/xcb.o
137+
138+EOF
139+fi
140+
141+cat >>Makefile <<EOF
142+.PHONY : all clean distclean
143+EOF
144+
145+if [ "$have_xa" != "true" ]
146+then
147+ echo "6502 assembler not detected. Assembly code cannot be used."
148+fi
149+
150+if [ "$have_xcb" != "true" ]
151+then
152+ echo "xcb not detected. emulator/hm1000 cannot be built."
153+fi
154+
155+echo "configure done. Type 'make' to build."
Show on old repository browser