Linux Genesis Dev Setup
Moderator: BigEvilCorporation
I've compared the new makefile to the old. The new makefile isn't even building the boot/ directory for me...I found this out after I cleaned all the object files in boot/ and it would no longer compile, claiming it couldn't find rom_head.o or sega.o. Replacing it with the original makefile made it compile (but of course with the wrong link order). I'm not really familiar with make at all so I'm not entirely sure how to fix this, nor am I sure where the link order even is in the Makefile.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Makefiles can be simplicity itself, or dreadfully complex. I prefer simple makefiles over the alternative. I made a thread on understanding and making simple makefiles like you'd want on MD/32X games. You can find it here:
http://www.sega-16.com/forum/showthread ... -makefiles
http://www.sega-16.com/forum/showthread ... -makefiles
I have just successfully built the toolchain on a 64 bit Arch distro using this script. Thanks @kubilus1 and @Chilly Willy. I had some problems because Arch uses texinfo version 5.1, and this version fails while building documentation from .texi files (I have suffered this problem also building e.g. mspgcc). I had to modify some of them. If anyone is interested, I can try generating a patch file.
There is a think I'm curious about. I read some time ago that older versions of GCC generate better (i.e. faster) code for the 68000 because latest GCC versions are optimized for more modern processor architectures, like ARM. How much truth is there in this statement? Should I try building a 3.7.x version? I also saw the thread about upgrading to 4.7.0. Is it worth the effort?
There is a think I'm curious about. I read some time ago that older versions of GCC generate better (i.e. faster) code for the 68000 because latest GCC versions are optimized for more modern processor architectures, like ARM. How much truth is there in this statement? Should I try building a 3.7.x version? I also saw the thread about upgrading to 4.7.0. Is it worth the effort?
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
The older versions DO generate faster code, but I don't think it's worth trying to use the older gcc for two reasons: first, many things are geared towards the latest gcc, so using an old gcc means having to rewrite code targeting the older gcc; and second, if you REALLY need fast code, for something like a 7.7 MHz 68000, you should be using assembly language instead of C. Find the 1% of the code that uses 75% of the CPU time and convert just that to assembly. Recompiling the entire project with an older version instead of targeting the specific areas with assembly is the lazy way to optimize rather than the proper way.
I have just tried building the rotating cube sample, without success. It looks like the toolchain doesn't generate correct roms, dgen complains about "no valid ROM found", and it looks like the ROM header is not OK:
If I look at the pre-built ROM included in SGDK samples, the header looks OK and the ROM works:
Weird...
Code: Select all
$ cp -r /opt/toolchains/gen/skeleton/* ./
$ make
m68k-elf-gcc -m68000 -Wall -O2 -c -fomit-frame-pointer -I. -I/opt/toolchains/gen//m68k-elf/include -I/opt/toolchains/gen//m68k-elf/m68k-elf/include -Isrc -Ires -c meshs.c -o meshs.o
In file included from /opt/toolchains/gen//m68k-elf/include/genesis.h:12:0,
from meshs.c:1:
/opt/toolchains/gen//m68k-elf/include/memory.h:187:6: warning: conflicting types for built-in function 'memset'
/opt/toolchains/gen//m68k-elf/include/memory.h:230:6: warning: conflicting types for built-in function 'memcpy'
m68k-elf-gcc -m68000 -Wall -O2 -c -fomit-frame-pointer -I. -I/opt/toolchains/gen//m68k-elf/include -I/opt/toolchains/gen//m68k-elf/m68k-elf/include -Isrc -Ires -c main.c -o main.o
In file included from /opt/toolchains/gen//m68k-elf/include/genesis.h:12:0,
from main.c:1:
/opt/toolchains/gen//m68k-elf/include/memory.h:187:6: warning: conflicting types for built-in function 'memset'
/opt/toolchains/gen//m68k-elf/include/memory.h:230:6: warning: conflicting types for built-in function 'memcpy'
main.c: In function 'main':
main.c:66:13: warning: unused variable 'i'
m68k-elf-gcc -o out.elf -T /opt/toolchains/gen//ldscripts/sgdk.ld -Wl,-Map=output.map -nostdlib boot/rom_head.o boot/sega.o /opt/toolchains/gen//m68k-elf/lib/libmd.a /opt/toolchains/gen//m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a /opt/toolchains/gen//m68k-elf/m68k-elf/lib/libc.a meshs.o main.o -L/opt/toolchains/gen//m68k-elf/lib -L/opt/toolchains/gen//m68k-elf/lib/gcc/m68k-elf/4.5.2 -L/opt/toolchains/gen//m68k-elf/m68k-elf/lib -lmd -lc -lgcc -lnosys -lm
m68k-elf-objcopy -O binary out.elf temp.bin
dd if=temp.bin of=out.bin bs=8K conv=sync
8+1 records in
9+0 records out
73728 bytes (74 kB) copied, 0.00026432 s, 279 MB/s
rm meshs.o main.o out.elf
$ dgen out.bin
video: 640x464, 32 bpp (4 Bpp), 60Hz
sound: 22050Hz, 705 samples, buffer: 14564 bytes
out.bin: no valid ROM found.
$ head out.bin | hexdump -C
00000000 00 ff fe 00 00 00 02 00 00 00 02 a6 00 00 02 b8 |................|
00000010 00 00 02 ca 00 00 02 dc 00 00 02 ee 00 00 03 00 |................|
00000020 00 00 03 12 00 00 03 24 00 00 03 36 00 00 03 36 |.......$...6...6|
00000030 00 00 03 48 00 00 03 48 00 00 03 48 00 00 03 48 |...H...H...H...H|
*
00000060 00 00 03 48 00 00 03 5a 00 00 03 6c 00 00 03 5a |...H...Z...l...Z|
00000070 00 00 03 7e 00 00 03 5a 00 00 03 90 00 00 03 5a |...~...Z.......Z|
00000080 00 00 03 5a 00 00 03 5a 00 00 03 5a 00 00 03 5a |...Z...Z...Z...Z|
*
00000100 00 02 00 04 00 00 00 01 00 00 00 00 00 00 00 34 |...............4|
00000110 00 00 21 54 00 00 00 00 00 34 00 20 00 01 00 28 |..!T.....4. ...(|
00000120 00 06 00 03 00 00 00 01 00 00 20 00 00 00 00 00 |.......... .....|
00000130 00 00 00 00 00 00 01 18 00 00 01 18 00 00 00 05 |................|
00000140 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 |.. .............|
00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200 4a b9 00 a1 00 08 66 06 4a 79 00 a1 00 0c 66 48 |J.....f.Jy....fH|
00000210 46 fc 27 00 4b fa 00 28 4c 9d 00 e0 4c dd 1f 00 |F.'.K..(L...L...|
00000220 10 29 ef 01 02 00 00 0f 67 08 23 7c 53 45 47 41 |.)......g.#|SEGA|
00000230 2f 00 30 14 70 00 2c 40 4e 66 4e fa 00 2a 80 00 |/.0.p.,@NfN..*..|
00000240 3f ff 01 00 00 a0 00 00 00 a1 11 00 00 a1 12 00 |?...............|
00000250 00 c0 00 00 00 c0 00 04 3e 7c 00 00 46 fc 23 00 |........>|..F.#.|
00000260 4e f9 00 00 07 9a 41 f9 00 ff 00 00 70 00 32 3c |N.....A.....p.2<|
00000270 3f ff 20 c0 51 c9 ff fc 41 f9 00 01 0a 40 43 f9 |?. .Q...A....@C.|
00000280 00 ff 00 00 20 3c 00 00 00 04 e2 88 67 00 00 0a |.... <......g...|
00000290 53 40 32 d8 51 c8 ff fc 3e 7c 00 00 46 fc 23 00 |S@2.Q...>|..F.#.|
000002a0 4e f9 00 00 06 ee 48 e7 c0 c0 20 79 00 ff 04 2a |N.....H... y...*|
000002b0 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff |N.L...NsH... y..|
000002c0 04 16 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 |..N.L...NsH... y|
000002d0 00 ff 03 ec 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 |....N.L...NsH...|
000002e0 20 79 00 ff 04 06 4e 90 4c df 03 03 4e 73 48 e7 | y....N.L...NsH.|
000002f0 c0 c0 20 79 00 ff 03 f8 4e 90 4c df 03 03 4e 73 |.. y....N.L...Ns|
00000300 48 e7 c0 c0 20 79 00 ff 03 f4 4e 90 4c df 03 03 |H... y....N.L...|
00000310 4e 73 48 e7 c0 c0 20 79 00 ff 04 26 4e 90 4c df |NsH... y...&N.L.|
00000320 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 04 00 4e 90 |..NsH... y....N.|
00000330 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 03 fc |L...NsH... y....|
00000340 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff |N.L...NsH... y..|
00000350 03 f0 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 |..N.L...NsH... y|
00000360 00 ff 04 12 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 |....N.L...NsH...|
00000370 20 79 00 ff 04 0a 4e 90 4c df 03 03 4e 73 48 e7 | y....N.L...NsH.|
00000380 c0 c0 20 79 00 ff 04 2e 4e 90 4c df 03 03 4e 73 |.. y....N.L...Ns|
00000390 48 e7 c0 c0 20 79 00 ff 04 0e 4e 90 4c df 03 03 |H... y....N.L...|
000003a0 4e 73 20 2f 00 04 6a 00 00 04 44 80 22 2f 00 08 |Ns /..j...D."/..|
000003b0 6a 00 00 0a 44 81 0a 2f 00 80 00 04 61 00 00 a6 |j...D../....a...|
000003c0 4a 2f 00 04 6a 00 00 04 44 80 4e 75 20 2f 00 04 |J/..j...D.Nu /..|
000003d0 6a 00 00 04 44 80 22 2f 00 08 6a 00 00 0a 44 81 |j...D."/..j...D.|
000003e0 0a 2f 00 80 00 04 61 00 00 60 4a 2f 00 04 6a 00 |./....a..`J/..j.|
000003f0 00 04 44 80 4e 75 20 2f 00 04 6a 00 00 04 44 80 |..D.Nu /..j...D.|
00000400 22 2f 00 08 6a 00 00 04 44 81 61 00 00 58 20 01 |"/..j...D.a..X .|
00000410 4a 2f 00 04 6a 00 00 04 44 80 4e 75 20 2f 00 04 |J/..j...D.Nu /..|
00000420 22 2f 00 08 61 00 00 3e 4e 75 20 2f 00 04 22 2f |"/..a..>Nu /.."/|
00000430 00 08 61 00 00 14 4e 75 20 2f 00 04 22 2f 00 08 |..a...Nu /.."/..|
00000440 61 00 00 22 20 01 4e 75 24 43 34 01 c4 c0 26 01 |a.." .Nu$C4...&.|
00000450 48 43 c6 c0 48 40 c0 c1 d0 83 48 40 42 40 d0 82 |HC..H@....H@B@..|
00000460 26 0a 4e 75 4a 81 66 00 00 0c 20 3c 80 00 00 00 |&.NuJ.f... <....|
00000470 22 00 4e 75 24 43 b0 81 62 00 00 16 67 00 00 0a |".Nu$C..b...g...|
00000480 22 00 42 80 26 0a |".B.&.|
00000486
Code: Select all
$ head _out/rom.bin | hexdump -C
00000000 00 ff fe 00 00 00 02 00 00 00 02 a2 00 00 02 b4 |................|
00000010 00 00 02 c6 00 00 02 d8 00 00 02 ea 00 00 02 fc |................|
00000020 00 00 03 0e 00 00 03 20 00 00 03 32 00 00 03 32 |....... ...2...2|
00000030 00 00 03 44 00 00 03 44 00 00 03 44 00 00 03 44 |...D...D...D...D|
*
00000060 00 00 03 44 00 00 03 56 00 00 03 68 00 00 03 56 |...D...V...h...V|
00000070 00 00 03 7a 00 00 03 56 00 00 03 8c 00 00 03 56 |...z...V.......V|
00000080 00 00 03 56 00 00 03 56 00 00 03 56 00 00 03 56 |...V...V...V...V|
*
00000100 53 45 47 41 20 4d 45 47 41 20 44 52 49 56 45 20 |SEGA MEGA DRIVE |
00000110 28 43 29 46 4c 45 4d 54 45 41 4d 20 32 30 31 33 |(C)FLEMTEAM 2013|
00000120 53 41 4d 50 4c 45 20 50 52 4f 47 52 41 4d 20 20 |SAMPLE PROGRAM |
00000130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
*
00000150 53 41 4d 50 4c 45 20 50 52 4f 47 52 41 4d 20 20 |SAMPLE PROGRAM |
00000160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
*
00000180 47 4d 20 30 30 30 30 30 30 30 30 2d 30 30 00 00 |GM 00000000-00..|
00000190 4a 44 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |JD |
000001a0 00 00 00 00 00 10 00 00 00 ff 00 00 00 ff ff ff |................|
000001b0 20 20 00 00 00 20 00 00 00 20 01 ff 20 20 20 20 | ... ... .. |
000001c0 20 20 20 20 20 20 20 20 44 45 4d 4f 4e 53 54 52 | DEMONSTR|
000001d0 41 54 49 4f 4e 20 50 52 4f 47 52 41 4d 20 20 20 |ATION PROGRAM |
000001e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
000001f0 4a 55 45 20 20 20 20 20 20 20 20 20 20 20 20 20 |JUE |
00000200 46 fc 27 00 4a b9 00 a1 00 08 66 06 4a 79 00 a1 |F.'.J.....f.Jy..|
00000210 00 0c 66 48 4b fa 00 2c 4c 9d 00 e0 4c dd 1f 00 |..fHK..,L...L...|
00000220 10 29 ef 01 02 00 00 0f 67 08 23 7c 53 45 47 41 |.)......g.#|SEGA|
00000230 2f 00 30 14 70 00 2c 40 4e 66 32 87 34 87 4e fa |/.0.p.,@Nf2.4.N.|
00000240 00 26 80 00 3f ff 01 00 00 a0 00 00 00 a1 11 00 |.&..?...........|
00000250 00 a1 12 00 00 c0 00 00 00 c0 00 04 3e 7c 00 00 |............>|..|
00000260 4e f9 00 00 42 a2 41 f9 00 ff 00 00 70 00 32 3c |N...B.A.....p.2<|
00000270 3f ff 20 c0 51 c9 ff fc 41 f9 00 01 05 ac 43 f9 |?. .Q...A.....C.|
00000280 00 ff 00 00 20 3c 00 00 00 04 e2 88 67 00 00 0a |.... <......g...|
00000290 53 40 32 d8 51 c8 ff fc 3e 7c 00 00 4e f9 00 00 |S@2.Q...>|..N...|
000002a0 41 f8 48 e7 c0 c0 20 79 00 ff 18 9e 4e 90 4c df |A.H... y....N.L.|
000002b0 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 18 8a 4e 90 |..NsH... y....N.|
000002c0 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 18 60 |L...NsH... y...`|
000002d0 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff |N.L...NsH... y..|
000002e0 18 7a 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 |.zN.L...NsH... y|
000002f0 00 ff 18 6c 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 |...lN.L...NsH...|
00000300 20 79 00 ff 18 68 4e 90 4c df 03 03 4e 73 48 e7 | y...hN.L...NsH.|
00000310 c0 c0 20 79 00 ff 18 9a 4e 90 4c df 03 03 4e 73 |.. y....N.L...Ns|
00000320 48 e7 c0 c0 20 79 00 ff 18 74 4e 90 4c df 03 03 |H... y...tN.L...|
00000330 4e 73 48 e7 c0 c0 20 79 00 ff 18 70 4e 90 4c df |NsH... y...pN.L.|
00000340 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 18 64 4e 90 |..NsH... y...dN.|
00000350 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff 18 86 |L...NsH... y....|
00000360 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 00 ff |N.L...NsH... y..|
00000370 18 7e 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 20 79 |.~N.L...NsH... y|
00000380 00 ff 18 a2 4e 90 4c df 03 03 4e 73 48 e7 c0 c0 |....N.L...NsH...|
00000390 20 79 00 ff 18 82 4e 90 4c df 03 03 4e 73 20 2f | y....N.L...Ns /|
000003a0 00 04 6a 00 00 04 44 80 22 2f 00 08 6a 00 00 0a |..j...D."/..j...|
000003b0 44 81 0a 2f 00 80 00 04 61 00 00 a6 4a 2f 00 04 |D../....a...J/..|
000003c0 6a 00 00 04 44 80 4e 75 20 2f 00 04 6a 00 00 04 |j...D.Nu /..j...|
000003d0 44 80 22 2f 00 08 6a 00 00 0a 44 81 0a 2f 00 80 |D."/..j...D../..|
000003e0 00 04 61 00 00 60 4a 2f 00 04 6a 00 00 04 44 80 |..a..`J/..j...D.|
000003f0 4e 75 20 2f 00 04 6a 00 00 04 44 80 22 2f 00 08 |Nu /..j...D."/..|
00000400 6a 00 00 04 44 81 61 00 00 58 20 01 4a 2f 00 04 |j...D.a..X .J/..|
00000410 6a 00 00 04 44 80 4e 75 20 2f 00 04 22 2f 00 08 |j...D.Nu /.."/..|
00000420 61 00 00 3e 4e 75 20 2f 00 04 22 2f 00 08 61 00 |a..>Nu /.."/..a.|
00000430 00 14 4e 75 20 2f 00 04 22 2f 00 08 61 00 00 22 |..Nu /.."/..a.."|
00000440 20 01 4e 75 24 43 34 01 c4 c0 26 01 48 43 c6 c0 | .Nu$C4...&.HC..|
00000450 48 40 c0 c1 d0 83 48 40 42 40 d0 82 26 0a 4e 75 |H@....H@B@..&.Nu|
00000460 4a 81 66 00 00 0c 20 3c 80 00 00 00 22 00 4e 75 |J.f... <....".Nu|
00000470 24 43 b0 81 62 00 00 16 67 00 00 0a 22 00 42 80 |$C..b...g...".B.|
00000480 26 0a 4e 75 70 01 42 81 26 0a 4e 75 0c 81 00 00 |&.Nup.B.&.Nu....|
00000490 00 01 66 00 00 08 42 81 26 0a |..f...B.&.|
0000049a
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Your link command looks wrong compared to the one you have in the sgdk makefile.
SGDK:
Your:
I replaced some path by env var to make it shorter but the point is that you shouldn't link rom_head.o file manually (it is automatically included in sega.s file) else it can't be correctly located.
Also i see you are using many default lib, only libgcc is used in SGDK and you should keep only this one as others may have conflicting methods.
Another point is that it seems you are duplicating lib use command:
SGDK:
Code: Select all
$(CC) -n -T $(GDK)/md.ld -nostdlib out/sega.o @out/cmd_ $(LIB)/libmd.a $(LIB)/libgcc.a -o out/rom.out
Your:
Code: Select all
$(CC) -o out.elf -T /opt/toolchains/gen//ldscripts/sgdk.ld ... -nostdlib boot/rom_head.o boot/sega.o $(LIB)/libmd.a $(LIB)/libgcc.a $(LIB)/libc.a meshs.o main.o -lmd -lc -lgcc -lnosys -lm
Also i see you are using many default lib, only libgcc is used in SGDK and you should keep only this one as others may have conflicting methods.
Another point is that it seems you are duplicating lib use command:
thenboot/rom_head.o boot/sega.o $(LIB)/libmd.a
At end, your link command should be something like that :-lmd
Code: Select all
$(CC) -o out.elf -T /opt/toolchains/gen//ldscripts/sgdk.ld -nostdlib boot/sega.o meshs.o main.o $(LIB)/libmd.a $(LIB)/libgcc.a
I just copied the Makefile inside /opt/toolchains/gen/skeleton, and didn't modify a single line. Isn't this supposed to be the SGDK Makefile? I'm a bit confused.
The linker step in the Makefile is exactly this one:
With variables as follow:
Maybe the Makefile is broken. rom_head.o is linked because rom_head.c is inside the skeleton directory. If I remove it, the makefile complaints about not being able to generate sega.o. Also it looks like $ARCHIVES stuff added to the linker step is redundand, isn't it?
I have tried using makefile.gen from the latest SGKD, but it also didn't work:
It looks like SGDK Makefile is Windows only. Am I doing anything wrong? Could anyone point me to a working Makefile for Linux?
The linker step in the Makefile is exactly this one:
Code: Select all
%.elf: $(OBJS) $(BOOT_RESOURCES)
$(CC) -o $@ $(LINKFLAGS) $(BOOT_RESOURCES) $(ARCHIVES) $(OBJS) $(LIBS)
Code: Select all
BOOTCS=$(wildcard boot/*.c)
BOOTSS=$(wildcard boot/*.s)
BOOTCS+=$(wildcard src/boot/*.c)
BOOTSS+=$(wildcard src/boot/*.s)
BOOT_RESOURCES+=$(BOOTCS:.c=.o)
BOOT_RESOURCES+=$(BOOTSS:.s=.o)
LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/m68k-elf/lib/gcc/m68k-elf/4.5.2 -L$(GENDEV)/m68k-elf/m68k-elf/lib -lmd -lc -lgcc -lnosys -lm
LINKFLAGS = -T $(GENDEV)/ldscripts/sgdk.ld -Wl,-Map=output.map -nostdlib
ARCHIVES = $(GENDEV)/m68k-elf/lib/libmd.a $(GENDEV)/m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a $(GENDEV)/m68k-elf/m68k-elf/lib/libc.a
I have tried using makefile.gen from the latest SGKD, but it also didn't work:
Code: Select all
$ make -f /opt/toolchains/gen/skeleton/makefile.gen
/home/jalon/src/gendev/sgdk/sgdk-read-only/bin/mkdir -p out
make: /home/jalon/src/gendev/sgdk/sgdk-read-only/bin/sh: Command not found
make: *** [out/rom_head.o] Error 127
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Oh sorry you are right, i didn't know the linux version was that far from the windows version in term of makefile :-/ Indeed you cannot use the win version of the makefile...
Honestly there is some stuff that looks really weird in the linux version (as the multiple lib inclusion) but i guess the most weird is that romhead.o is listed before sega.o but i guess this is because your romhead.o also include the interrupt vector address unlike mine.
Honestly there is some stuff that looks really weird in the linux version (as the multiple lib inclusion) but i guess the most weird is that romhead.o is listed before sega.o but i guess this is because your romhead.o also include the interrupt vector address unlike mine.
doragasu wrote:I just copied the Makefile inside /opt/toolchains/gen/skeleton, and didn't modify a single line. Isn't this supposed to be the SGDK Makefile? I'm a bit confused.
The linker step in the Makefile is exactly this one:
With variables as follow:Code: Select all
%.elf: $(OBJS) $(BOOT_RESOURCES) $(CC) -o $@ $(LINKFLAGS) $(BOOT_RESOURCES) $(ARCHIVES) $(OBJS) $(LIBS)
Maybe the Makefile is broken. rom_head.o is linked because rom_head.c is inside the skeleton directory. If I remove it, the makefile complaints about not being able to generate sega.o. Also it looks like $ARCHIVES stuff added to the linker step is redundand, isn't it?Code: Select all
BOOTCS=$(wildcard boot/*.c) BOOTSS=$(wildcard boot/*.s) BOOTCS+=$(wildcard src/boot/*.c) BOOTSS+=$(wildcard src/boot/*.s) BOOT_RESOURCES+=$(BOOTCS:.c=.o) BOOT_RESOURCES+=$(BOOTSS:.s=.o) LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/m68k-elf/lib/gcc/m68k-elf/4.5.2 -L$(GENDEV)/m68k-elf/m68k-elf/lib -lmd -lc -lgcc -lnosys -lm LINKFLAGS = -T $(GENDEV)/ldscripts/sgdk.ld -Wl,-Map=output.map -nostdlib ARCHIVES = $(GENDEV)/m68k-elf/lib/libmd.a $(GENDEV)/m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a $(GENDEV)/m68k-elf/m68k-elf/lib/libc.a
I have tried using makefile.gen from the latest SGKD, but it also didn't work:
It looks like SGDK Makefile is Windows only. Am I doing anything wrong? Could anyone point me to a working Makefile for Linux?Code: Select all
$ make -f /opt/toolchains/gen/skeleton/makefile.gen /home/jalon/src/gendev/sgdk/sgdk-read-only/bin/mkdir -p out make: /home/jalon/src/gendev/sgdk/sgdk-read-only/bin/sh: Command not found make: *** [out/rom_head.o] Error 127
The included Makefile is driving me nuts
I'm trying to modify it. First I commented out the ARCHIVES variable. Now I want to know why each time I make the project, all the .o and .elf files are deleted just after the final dd that copies and pads the ROM.
It's a complete mistery. The only rm in the makefile is inside the clean target. I have tried making clean a .PHONY target, and even commenting it out, but the files are deleted anyway...
EDIT: I haven't solved the "rm" mistery, but continued trying and got this to link:
The linker command looks OK, but I'm still out of luck: output file lacks the header. I have checked and the header is NOT present in boot/sega.o. It is in boot/rom_head.o and boot/rom_head.bin.
ANOTHER EDIT: Adding rom_head.o to the linker step doesn't work. Trying putting it before/after boot/sega.o without success.
AND ANOTHER ONE: Got a sega.o with the header, but it is still missing in the final ROM.
I'm trying to modify it. First I commented out the ARCHIVES variable. Now I want to know why each time I make the project, all the .o and .elf files are deleted just after the final dd that copies and pads the ROM.
It's a complete mistery. The only rm in the makefile is inside the clean target. I have tried making clean a .PHONY target, and even commenting it out, but the files are deleted anyway...
EDIT: I haven't solved the "rm" mistery, but continued trying and got this to link:
Code: Select all
m68k-elf-gcc -o out.elf -T /opt/toolchains/gen/ldscripts/sgdk.ld -Wl,-Map=output.map -nostdlib boot/sega.o meshs.o main.o /opt/toolchains/gen/m68k-elf/lib/libmd.a /opt/toolchains/gen/m68k-elf/lib/gcc/m68k-elf/4.5.2/libgcc.a
m68k-elf-objcopy -O binary out.elf temp.bin
ANOTHER EDIT: Adding rom_head.o to the linker step doesn't work. Trying putting it before/after boot/sega.o without success.
AND ANOTHER ONE: Got a sega.o with the header, but it is still missing in the final ROM.
There were a couple problems. I don't know why I was grabbing rom_head with the boot resources. Also, sega.o was not being generated correctly. This should be fixed now, if you want to update your svn tree.
It's likely that other tweaks might be needed. I'm open to suggestions and input!
Also, the reason your files are being cleaned up is likely from make pruning them. You could set these files as .SECONDARY targets to keep them around.
It's likely that other tweaks might be needed. I'm open to suggestions and input!
Also, the reason your files are being cleaned up is likely from make pruning them. You could set these files as .SECONDARY targets to keep them around.
Ideally, it would be great to be able to just use the same Makefiles for both Windows and Linux development. It seems redundant (and error prone) to maintain two different make files.
One way might be to set some of the variable targets in the makefile.gen file in sgdk with ?= instead of =, that was they can be overridden.
For instance:
SHELL=$(BIN)/sh
RM= $(BIN)/rm
AR= $(BIN)/ar
CC= $(BIN)/gcc
LD= $(BIN)/ld
would be:
SHELL?=$(BIN)/sh
RM?= $(BIN)/rm
AR?= $(BIN)/ar
CC?= $(BIN)/gcc
LD?= $(BIN)/ld
Which I could set and override when calling this in Linux. Just a thought, I might work on a patch sometime soon ....
One way might be to set some of the variable targets in the makefile.gen file in sgdk with ?= instead of =, that was they can be overridden.
For instance:
SHELL=$(BIN)/sh
RM= $(BIN)/rm
AR= $(BIN)/ar
CC= $(BIN)/gcc
LD= $(BIN)/ld
would be:
SHELL?=$(BIN)/sh
RM?= $(BIN)/rm
AR?= $(BIN)/ar
CC?= $(BIN)/gcc
LD?= $(BIN)/ld
Which I could set and override when calling this in Linux. Just a thought, I might work on a patch sometime soon ....