Jump to content

Makefile


istephen

Recommended Posts

Hi,

I'm just starting writing a bit of code for my midiBox (currently under construction).

I'm working in MacOSX, so converted the batch files to a makefile which seems to work well. I've attatched the makefile I used to compile the analog-toolkit. To compile others, just check the defines at the top match those in make.bat, and set OBJS to match the file list (adding .o on the end). You don't need to include mios_wrapper, or pic18*.o, as the makefile adds them in automatically.

You may need to use gmake, rather than make if you're running this on other platforms.

When I compiled a few things the hex files were SLIGHTLY different to those included in the package. This may be due to a different build of the compiler/assembler, or maybe just some config options. I haven't been able to test any compiled apps, as my hardware is still not ready.

hope others find this helpfull.

Ian

p.s. watch out for the tabs - that have become spaces in the html version. If you copy/paste this you'll need to turn any spaces at the start of lines into tabs, otherwise it won't work.

PROJECT=project
MIOS_WRAPPER_DEFINES=-DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f
SDCC_DEFINES=-DDEBUG_MODE=0

OBJS=main.o aout.o midi.o lfo.o eg.o map.o

# === general settings ======================================================
CC=sdcc
CFLAGS=-S -mpic16 -p18F452 --fstack --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2 -pleave-reset-vector ${SDCC_DEFINES}
FIXASM=perl tools/fixasm.pl
GPASM=gpasm -c

${PROJECT}.syx:${PROJECT}.hex
	perl tools/hex2syx.pl ${PROJECT}.hex

${PROJECT}.hex : ${OBJS} pic18f452.o mios_wrapper.o
	gplink -s ${PROJECT}.lkr -m -o ${PROJECT}.hex mios_wrapper.o pic18f452.o ${OBJS}

#=== assemble MIOS SDCC wrapper and device specific setup ==================
mios_wrapper.o : mios_wrapper/mios_wrapper.asm
	${GPASM} ${MIOS_WRAPPER_DEFINES} -I mios_wrapper mios_wrapper/mios_wrapper.asm -o mios_wrapper.o


%.o : %.c

%.asm : %.c
	${CC} ${CFLAGS} $< -o $@
	${FIXASM} $@

%.o : %.asm
	${GPASM} $< -o $@


clean :
	rm -rf *.o *.asm *.lst ${PROJECT}.cod ${PROJECT}.hex ${PROJECT}.syx ${PROJECT}.map

Link to comment
Share on other sites

Thanks for the input!

Due to the crappy support of Makefiles in a windows environment (e.g. GNU make cannot reference external commands without absolute path), I will propably write a makefile generator which generates a simpler make.bat as the one currently used (because it doesn't work under Win98 and WinME), and a Makefile for Unix/Mac

Best Regards, Thorsten.

Link to comment
Share on other sites

Thanks for the input!

Due to the crappy support of Makefiles in a windows environment (e.g. GNU make cannot reference external commands without absolute path), I will propably write a makefile generator which generates a simpler make.bat as the one currently used (because it doesn't work under Win98 and WinME), and a Makefile for Unix/Mac

I have spent about 4 hours trying to get the makefile to work in WinME... and the best I could do, was to find workaround for the problem with having a string defined with an = character in it.  Just split the string in two or three, around the offensive = symbol, and when you execute the strings later on, add the = symbol.

For example,

[tt]

set MIOS_WRAPPER_DEFINES=-DSTACK_HEAD

set MIOS2=0x37f -DSTACK_IRQ_HEAD

set MIOS3=0x33f

%GPASM% %MIOS_WRAPPER_DEFINES%=%MIOS2%=%MIOS3%

[/tt]

Crude, but this works.

Now my problems seem to have become much worse - my system hangs when I run the make.bat file.  Haven't had much time to fight this... would rather solder boards really.

-gerald

Link to comment
Share on other sites

I've implemented the makefile generator, which should help to make the build process compatible to Unix and all Windows versions.

It's now part of following packages:

http://www.ucapps.de/mios/sdcc_skeleton_v1_0b.zip

http://www.ucapps.de/mios/midibox_mm_v2_0b.zip

http://www.ucapps.de/mios/analog_toolbox_v1_1b.zip

Ian/Pilo: could you please test the Makefile under Mac/Linux?

Gerald: could you please check it with your windows version?

Best Regards, Thorsten.

Link to comment
Share on other sites

due to a copy error I released the wrong version of mkmk.pl - it's corrected in the *b.zip release (links above are modified)

Note also that the C wrapper contains a bugfix for the MIOS_TIMER_Init() and _Reinit() function - don't use the old wrapper anymore

Best Regards, Thorsten.

Link to comment
Share on other sites

I've implemented the makefile generator, which should help to make the build process compatible to Unix and all Windows versions.

Gerald: could you please check it with your windows version?

I tried it - but something terrible is happening, I believe with SDCC - I keep getting general protection faults, and other errors that crash my computer HARD.  I was getting these errors with the previous version of the makefile.bat, and I suspect it is something about windoze ME.  I'd love to keep fighting with this, but I worry about corrupting my hard-disk with so many hard-boots.  Maybe I should make a DOS boot disk, and try to run it without windows in the background?

-gerald

Link to comment
Share on other sites

  • 4 months later...

hum ... maybe there's a huge lack of very important information inside my head, but I couldn't do anything with this "OS X"-Makefile. So I converted the existing makefile.bat from the 1.0.c skeleton into a bash-script for os x:

#! /bin/bash

# MAKEFILE FOR BASH
# ASSEMBLING / LINKING SDCC / GPASM / PIC
# FOR MIDIBOX ->> www.ucapps.de <<-

# setting up main vars
PROJECT='project';

# assembling
echo '*** BUILDING & LINKING' $PROJECT '************************************************';
echo 'Setting up _output directory...'
mkdir _output;
echo 'Assembling MIOS SDCC wrapper...'
gpasm -c -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I mios_wrapper mios_wrapper/mios_wrapper.asm -o _output/mios_wrapper.o

# building
echo 'Building the project files...'
echo 'Compiling pic18f452.c'
sdcc -S -mpic16 -p18F452 --fstack --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2 -pleave-reset-vector -DDEBUG_MODE=0 pic18f452.c -o _output/pic18f452.asm

./tools/fixasm.pl _output/pic18f452.asm
gpasm -c _output/pic18f452.asm -o _output/pic18f452.o

# compiling
echo 'Compiling main.c'
sdcc -S -mpic16 -p18F452 --fstack --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2 -pleave-reset-vector -DDEBUG_MODE=0 main.c -o _output/main.asm

./tools/fixasm.pl _output/main.asm
gpasm -c _output/main.asm -o _output/main.o

# linking
echo 'Linking '$PROJECT
gplink -s project.lkr -m -o $PROJECT.hex _output/*.o

# converting
echo 'Converting '$PROJECT'.syx to '$PROJECT'.hex'
./tools/hex2syx.pl $PROJECT.hex

# done!
echo 'Done! ------------------------------------------------------------------------';

here is the same post along with some more instructions

I hope this is to some use for someone.

If this isn't the 'right' way, please feel free to correct things, at least this is simply working without the need of having VPC and PC-Stuff installed...

regards,

Michael

Link to comment
Share on other sites

Hi Michael,

thanks for your contribution, good to hear that it works in principle with the Mac.

Well, the problem with your static make.sh script is, that it won't be automatically enhanced if additional source files are added to the project. Thats the reason, why I've implemented a makefile generator, which generates a "Makefile" for Unix, and a "make.bat" for DOS.

-> see tools/mkmk.pl and "MAKEFILE.SPEC"

I would propose to get use of this generator in order to guarantee the compatibility with complex C application (it would also be more newbie-friendly)

There are two ways: either the mkmk.pl script generates a make.sh file for MacOSX, or we are trying to improve the generated Makefile, so that it runs under Linux and MacOSX

Did you try out the Makefile? "make -f Makefile" should also work on the Mac, no?

Best Regards, Thorsten.

Link to comment
Share on other sites

Hi Thorsten,

"make -f Makefile"

The *nix makefile must have slipped away before my eyes  ???

I just tried calling "Make" in the test-directory and it worked.

Dunno, maybe the root of all evil was that I had the SDCC 2.4 for mac -"edition" which did not compile properly...

...and now I got 2.5.4 installed (had no success with 2.5.0)

Nevertheless, I learned a lot about makefiles  ::)

Thanks & regards,

Michael

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...