DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 17th December 2016
Funkygoby Funkygoby is offline
Port Guard
 
Join Date: Aug 2015
Posts: 18
Default Simple build system

Hello,
I have lilypond files organised as such transciptions/artist/album/[tune_name].ly or compositions/band/[compo_name].ly. I would like a build system inspired on the port system, it has already been discussed here: http://daemonforums.org/showthread.php?t=9861
Based on this thread, make seems to be the best solution.
Currently, I have a Makefiles in every folder. In Vim, I can run make and build the resulting pdf in the same folder.

This worked as long as you have few scores but today I have hundreds of .pdf, .midi hanging around in those folders built from differents lilypond versions (so not visually consistent).

Time for a more convenient system. I would to like be able to:
-build a whole artist discography
Code:
cd artist && make
-build a specific tune
Code:
cd artist/album && make
-have the resulting files stored in a pdfs folder either with a hierarchy or with names such as artist - album - tune.pdf (tune being the original .ly filename)

I have a little experience with Makefiles for C and Java project. My guess is:
-I need a Makefile in every places I want to be able to run make
-I need to have a "mother-Makefile" for generic rules that is included by all other Makefiles

My issues are that I never really understood recursivity with make. In the case of
Code:
cd artist/ && make
how to tell make to enter every subfolder and read the Makefile.
How to handle the resulting files? My Makefiles are always dirty with this because I move files around from the folder where make is executing which, in my case, happens to be the sub-sub-folder.
Do you have any recommendations? Hint?

Extra question:
While writing a thread, how to highlight command names? or ports? I read the forum "README" but couldn't find a thing about this.
Reply With Quote
  #2   (View Single Post)  
Old 17th December 2016
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,491
Default

I have used make(1) for simple web pages and XML/XSLT transformations, and creating post-install shell command files from small shell min-blocks. I never did a recursive Makefile, but I think something like this should do it ....

Code:
cd subdirA && make
cd subdirB && make
cd subdirC && make
Or a loop using a make .for loop:
Code:
.for

.endfor
You can find some examples of this the bsd.mk directory that is included in most OpenBSD makefiles. (I am on a Linux system right now, so I am not sure that it the right directory name ...)

Although the FreeBSD and OpenBSD versions of make(1) have some differences I learned a lot from PMake — A Tutorial by Adam de Boor. His counsel "Variables are your friend" helped me a very much to do what I wanted to achieve.

For your complicated "making" you also could use make or the shell to generate a customized Makefile and then have it run.

For your target files in one place you could use:

Quote:
.OBJDIR
Path to the directory where targets are built. At startup, make searches for an alternate directory to place target files. make tries to chdir(2) into MAKEOBJDIR (or obj if MAKEOBJDIR is not defined), and sets .OBJDIR accordingly. Should that fail, .OBJDIR is set to .CURDIR.
as described in make(1)
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 4 Weeks Ago
Funkygoby Funkygoby is offline
Port Guard
 
Join Date: Aug 2015
Posts: 18
Default

Hello J65nko,
mentioning the subdirs explicitly is what I did with C projects. With lilypond scores, I ld rather avoird this. When I create a new artist/album, I want to reuse existing Makefiles without bothering with the differents subdirs.
I will try the for loop (didn't know make had loops).

Reading the ports Makefile should have been my first steps... I will start here + man make and come back with the result.
Reply With Quote
  #4   (View Single Post)  
Old 4 Weeks Ago
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,491
Default

Although this is FreeBSD make, an example of a .for ... .endfor loop can be found at http://daemonforums.org/showthread.php?t=8032#post48207

If you create a Transformation rule your Makefiles will even become more simpler.

Good luck
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #5   (View Single Post)  
Old 4 Weeks Ago
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,252
Default

Quote:
Originally Posted by Funkygoby View Post
I would to like be able to:
-build a whole artist discography
...
-build a specific tune
You may want to play with creating different targets within your Makefile's -- target discography create a discography with the command:

$ make discography

...while target tunes performs different functionality via:

$ make tunes
Quote:
When I create a new artist/album, I want to reuse existing Makefiles without bothering with the differents subdirs.
My suggestion is to carefully think through implementing one artist, & then scale up to multiple artists.
Quote:
Reading the ports Makefile should have been my first steps... I will start here + man make and come back with the result.
Looking through some examples of tiered OpenBSD ports may be useful:
  • /usr/ports/devel/jdk
  • /usr/ports/lang/python
...but again, the ports system addresses a more complex set of requirements than what you describe. My suggestion is to start simple & iterate. You will likely not come up with the perfect solution on the first try. Iterating again & again is what programming is all about. Really.
Quote:
While writing a thread, how to highlight command names? or ports? I read the forum "README" but couldn't find a thing about this.
Discussion in the following sticky thread may help:

http://daemonforums.org/showthread.php?t=51

Last edited by ocicat; 4 Weeks Ago at 01:21 AM. Reason: add clarity
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ninja, a replacement for make, in Chrome's build system J65nko News 7 14th February 2011 04:14 AM
Create MS/XP file system so it will be recognized on a XP system. FBSD Guides 0 1st May 2010 06:49 AM
Simple pf ruleset jhp FreeBSD General 2 30th March 2010 02:05 PM
A simple question Mr-Biscuit Off-Topic 1 16th April 2009 04:26 PM
Which file system use to share data on Bsd system? aleunix Other BSD and UNIX/UNIX-like 2 1st June 2008 04:14 PM


All times are GMT. The time now is 04:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick