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 25th November 2008
taylor_venable taylor_venable is offline
Real Name: Taylor Venable
Security Programmer
 
Join Date: Jun 2008
Location: Indiana, USA
Posts: 6
Default (Net|Open)BSD Make: implicit C header dependencies

Using BSD Make (specifically, I'm doing this on OpenBSD) I can use the wonderful incantation:

Code:
.SUFFIXES:	.o .cc

.cc.o:
	g++ -g -Wall -c ${.IMPSRC}
To compile C or C++ source to object files from corresponding source. But there's no dependency on the header files, which can obviously be somewhat important. Is there a quick and easy way to put the corresponding header file into this equation too?

I realize that normally alpha.h depends on beta.h and so forth, and that these special dependencies can be done the "normal" way with Make, so I am curious about the generic case that every .cc (C++ source) file depends on the .hh (C++ header) file of the same name.

Thanks for any tips.
__________________
How many shells could Shell sort sort if Shell sort could sort shells?
Reply With Quote
  #2   (View Single Post)  
Old 25th November 2008
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

I am not 100% sure what are you trying to accomplish but you should start by reading bsd.ports.mk. Normally compiler optimization for software which one tries to port to OpenBSD is done by careful reading of the output of

Code:
make build
and then properly adjusting /usr/obj/portname/Makefile (or config.mk) file and generating patches.

I am not coding on regular basis so I would have hard time to help you further with compiler optimization. If you are trying to code new application using gcc on OpenBSD you should probably read man pages for gcc. There are quite a few knobs that you can turn of and on. (I also do not use C++ as it is against my religion).
If you are trying just to port software to OpenBSD start by reading documentation from OpenBSD web-site. In particular you can find magic point presentation how to create an elementary port but your question is little bit deeper than that.

Last edited by Oko; 25th November 2008 at 03:49 AM.
Reply With Quote
  #3   (View Single Post)  
Old 25th November 2008
taylor_venable taylor_venable is offline
Real Name: Taylor Venable
Security Programmer
 
Join Date: Jun 2008
Location: Indiana, USA
Posts: 6
Default

Quote:
Originally Posted by Oko View Post
I am not 100% sure what are you trying to accomplish
Thanks for the reply. Here's an example:
Code:
*.cc:	*.hh
This ensures that every .cc file depends on every .hh file so when a header gets touched, it forces everything depending on a .cc file to get rebuilt. The downside of course is that I can touch and make a header out of nothing and every object gets rebuilt for no reason. I'm looking for a way to say that a specific .cc file depends on the .hh file with the same name (i.e. foo.cc depends on foo.hh, bar.cc depends on bar.hh, and so on) to the effect that when I modify foo.hh then foo.o gets rebuilt. I know about mkdep, which basically does this plus more, but I was looking for a way to do it in make. Half out of curiosity, half because it may be useful for other things that mkdep doesn't understand.

Also, I should note this isn't for anything in Ports or the rest of the system, but I'll check out the system make files for ideas.
__________________
How many shells could Shell sort sort if Shell sort could sort shells?
Reply With Quote
  #4   (View Single Post)  
Old 25th November 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

Quote:
Originally Posted by taylor_venable View Post
... so I am curious about the generic case that every .cc (C++ source) file depends on the .hh (C++ header) file of the same name.
you could use:

Code:
.SUFFIXES:	.o .cc

.cc.o:
	g++ -g -Wall -c ${.IMPSRC}

*.o: $*.hh

Last edited by ephemera; 25th November 2008 at 04:38 PM.
Reply With Quote
Reply

Tags
make

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
cannot open cloning pty l2fl2f FreeBSD General 2 10th December 2008 07:30 PM
Apache: problem with rewritten content-type header Malakim General software and network 2 3rd December 2008 07:51 PM
How to handle conflicting port dependencies? Aux FreeBSD Ports and Packages 2 29th September 2008 06:44 AM
how to check package dependencies? bsdnewbie999 OpenBSD Packages and Ports 5 31st July 2008 04:05 AM
Missing header file(s) in source tree phatfish FreeBSD Installation and Upgrading 8 4th May 2008 08:40 PM


All times are GMT. The time now is 10:34 AM.


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