| |
Burglar
Registered: Dec 2004 Posts: 1031 |
Cross Development using Makefile
Weekend didn't even start for most of you yet, but here it is ;)
Cross Development using Makefile
comments and improvements are of course very welcome.
enjoy and may your build times be short!
make -j16 |
|
| |
Stone
Registered: Oct 2006 Posts: 168 |
I had a quick look and I have one comment: What you refer to as labels are normally called variables, (or even macros by some). Things like $@ and $< are called automatic variables. Using the commonly accepted terms for these things is useful when trying to find further information on the 'net. |
| |
Burglar
Registered: Dec 2004 Posts: 1031 |
Thanks! It's updated ;) |
| |
Hermit
Registered: May 2008 Posts: 208 |
Great to have this kind of topic here. thx for it, must save a lot of googling time for some people.
Might be useful to mention 'for' loops for command-line tools that doesn't support batch processing (if it doesn't affect the purity of the article for 'make'). I'm not sure about CC1541 but I couldn't find a correct batch processing to assemble the SID-Wizard d64 image with executables and examples, so I ended up solving it by 'for' loops lately.
This btw possibly makes the makefile platform-dependent (btw it's already platform-dependent due to slashes/back-slashes I guess, or it might provide bash commands in certain toolchains - e.g.: cmake).
Based on the basic form to iterate through directory:
in linux-bash: for <variable> in <directory/filetype-filter> ; do <commands - if more, they're separated by semicolons> ; done ;
in M$ batch : for %%<variable> in (<directory\filetype-filter>) do (<batch commands to perform)>)
An extract from my current makefiles how I do it (though there might be a better way, dunno):
for sng2swm I use this (bash syntax):
for inputfile in $(EXASWMDIR)/sng-imports/*.sng ; do $(BINARYDIR)/$(SNG-CONVERTER) $$inputfile $${inputfile%.*}.swm.prg $(KUSS) ; done ;
for M$-batch:
for %%i in (%EXASWMDIR%\sng-imports\*.sng) do ( %SNG-CONVERTER% %%i %%~dpni.swm.prg > nul )
for cc1541 I use this (on previously created .d64 file):
for inputfile in $(EXASWMDIR)/*.swm.prg ; do outputfile=$${inputfile##*/} ; \
$(CBMDISK) -attach $@ -write $$inputfile $${outputfile%.*} ; done;
in M$-batch:
for %%i in (%EXASWMDIR%\*.swm.prg) do (
%CBMDISK% -attach %BINARYDIR%\%APPNAME1%-%APPVERSION%-disk.d64 -write %%i %%~ni > nul
)
It is worth to mention the other small tools to enhance readibility:
\ in bash-based makefile performs a line-break
$${..#..%.} commands in bash can be used for string-alterations (e.g. cutting the extension, etc..) - it has simpler form in batch, e.g. %%~ni
I however couldn't find out the proper way to give the dependencies of the files used by the 'for' loops. For instance I used "$(EXASWMDIR)/" as folder-content dependency but it didn't worked in the way I exactly wanted.
Kinda out-of-topic, but I'd be glad to have a Turbo Chameleon 64 programming topic at Codebase64. I tried experimenting with its VGA mode based on its good documentation, but some working source code could always make brainwork easier, e.g. to see what is the preferred order for writing registers...
|
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Looks excellent, Burglar! I have no excuse for not trying it out now. |
| |
Burglar
Registered: Dec 2004 Posts: 1031 |
@Cruzer, great ;) if you run into any problems, gimme a shout.
@Hermit, using for loops like you are, you're just redoing everything
whenever you need to build. Also when it isn't needed.
Let me enhance your sng2swm building:
SNG2SWM=bin/sng2swm
SNGSRC=$(shell find ./sng-imports -name '*.sng')
SWMOBJ=$(SNGSRC:.sng=.swm.prg)
%.swm.prg: %.sng
$(SNG2SWM) $< $@
all: $(SWMOBJ)
clean:
rm -f $(SWMOBJ)
Now, "make all" will convert all .sng files to .swm.prg.
If you modify or add one, then that's the only one that will be converted
when you run "make all" again.
You can now also build in parallel.
The c1541 (thats what you use, cc1541 is a different tool by JackAsser)
issue is more complex as there is only one targetfile with multiple inputfiles.
So for now, I'll just advice to write it out in the Makefile.
Will save some headaches ;) |
| |
Dr.j
Registered: Feb 2003 Posts: 276 |
Hey There Burglar
I am a newcommer in Building shell commands to build files
and i didn't get into the bottom line of this thread.
sorry for the "pain-in-the ass" question:
where can i find this tool "MakeFile" ? didn't see any d/l . or is it a text file we edit ? i always used batch (MS) commands like "XXX.BAT"
and i got old one for compiling from Kickass and run in Winvice , can you show me Batch commands (MS) to
crunch with exomizer and to create/edit file with cc1541
with some info. about the commands ?
|
| |
Shine
Registered: Jul 2012 Posts: 327 |
Hi Alex,
maybe you looking for:
http://gnuwin32.sourceforge.net/packages/make.htm |
| |
Dr.j
Registered: Feb 2003 Posts: 276 |
Thanks Andy :-)
I gonna d/l it soon .
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11114 |
dr.j has brought up an important point .... if you are stuck on windows for some reason, you need a "how to install and use cygwin" tutorial aswell, else even simple stuff like rm -f might not work correctly =)
(and dont even think about using make without a proper bash shell. yes it works for some simple stuff. BUT it will make your head explode once you get to the more advanced stuff, trust me) |
| |
JackAsser
Registered: Jun 2002 Posts: 1989 |
Quote: dr.j has brought up an important point .... if you are stuck on windows for some reason, you need a "how to install and use cygwin" tutorial aswell, else even simple stuff like rm -f might not work correctly =)
(and dont even think about using make without a proper bash shell. yes it works for some simple stuff. BUT it will make your head explode once you get to the more advanced stuff, trust me)
Actually you get quite far by installing nmake from microsoft and then unixtools for windows. But then again cygwin is a more general approach, pity the io-wrapper is so damn slow. |
... 37 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 | 4 | 5 - Next |