.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
GNU Make question
Old
  (#1)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default GNU Make question - 02-07-2005

I thought this was obvious...but meh
Here is what I want: I simply want to set a macro when the target 'server' is being build. That way a clean ded server can be build.
Here is what I have now, and doesn't work :-/
Code:
server: $(SERVER_OBJS)
	$(CXX) $(CXXFLAGS) -DSTANDALONE -o cube_bot_fbsd-server $(SERVER_OBJS) $(SERVER_LIBS)
For same reason the macro 'STANDALONE' is not set.

Can somebody please help me?
  
Reply With Quote
Re: GNU Make question
Old
  (#2)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: GNU Make question - 03-07-2005

Are you using the right macro?
Because this works for me...

dtest.c
Code:
#include <stdio.h>

int main( void ) {
	#ifdef _SERVER_
	printf( "Server started!\n" );
	#else
	printf( "Client started!\n" );
	#endif

	return 0;
}
Makefile
Code:
CC=gcc
CFLAGS=-O2
CLFILE=client.exe
SVFILE=server.exe

server:
	$(CC) $(CFLAGS) -o $(SVFILE) -D_SERVER_ dtest.c

client:
	$(CC) $(CFLAGS) -o $(CLFILE) dtest.c

clean:
	rm client.exe
	rm server.exe
	rm dtest.o
  
Reply With Quote
Re: GNU Make question
Old
  (#3)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: GNU Make question - 03-07-2005

OK got it to work, thanks

I guess its the way of compiling...it works if I do it simulair to yours:
Code:
server:
	$(CXX) $(CXXFLAGS) -o cube_bot_fbsd-server -DSTANDALONE $(SERVER_FILES) $(SERVER_LIBS)
Where SERVER_FILES are the actual source files instead of the object files.
  
Reply With Quote
Re: GNU Make question
Old
  (#4)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default Re: GNU Make question - 04-07-2005

Not entirely sure if this is right...but I think the defines really only work compiling the source files direct, not on the object files - though header files are sometimes used when linking, so it could have an effect there.
I could be completely wrong - someone please correct me if I am!


mirv the Silly Fish.
  
Reply With Quote
Re: GNU Make question
Old
  (#5)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: GNU Make question - 04-07-2005

I'm not sure about linking header files(never saw that happen), but you're right about the other part. Unfortunaly this way of compiling doesn't leave any .o files and thus you have to recompile everything each time.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com