LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2004, 04:20 PM   #1
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Make file, dos, linux


Ok. I have a project I am working on that uses the cross platform library "Allegro". My problem is this:

When compiling under linux, I need to use the `allegro-config` script for g++ library paths, etc...

In dos (DJGPP) however, I need to manually do this.

Ontop of this difference, in DJGPP, the C++ compiler is called gpp, and on linux its called g++, how do I add different OS sections to my Makefile???

Makefile-linux:
Code:
SOURCES = 	source/main.cpp \
		source/screen.cpp \
		source/game.cpp \
		source/editor.cpp \
		source/spriteeditor.cpp \
		source/sprite.cpp \
		source/file.cpp \
		source/gstring.cpp \
		source/map.cpp

OBJS		= ${SOURCES:.cpp=.o}
CFLAGS	= -O3 -Iinclude/ -I. `allegro-config --cflags`
LIBS		= -lm `allegro-config --libs`
CC		= g++
PACKAGE	= game

all : ${OBJS}
	${CC} ${CFLAGS} -o ${PACKAGE} ${OBJS} ${LIBS}

.cpp.o:
	${CC} ${CFLAGS} -c $< -o ${<:.cpp=.o}

clean :
	rm -fr *.o
	rm -fr source/*.o

# end of file
Makefile-dos:
Code:
SOURCES = 	source/main.cpp \
		source/screen.cpp \
		source/game.cpp \
		source/editor.cpp \
		source/spriteeditor.cpp \
		source/sprite.cpp \
		source/file.cpp \
		source/gstring.cpp \
		source/map.cpp

OBJS		= ${SOURCES:.cpp=.o}
CFLAGS	= -O3 -Iinclude/ -I. -LC:\DJGPP\ALLEGRO\LIBS\DJGPP -IC:\DJGPP\ALLEGRO\INCLUDE
LIBS		= -lm -lalleg
CC		= gpp
PACKAGE	= game.exe

all : ${OBJS}
	${CC} ${CFLAGS} -o ${PACKAGE} ${OBJS} ${LIBS}

.cpp.o:
	${CC} ${CFLAGS} -c $< -o ${<:.cpp=.o}

clean :
	rm -fr *.o
	rm -fr source/*.o

# end of file
How do I make one make file that does both DJGPP and Linux???
 
Old 05-29-2004, 11:36 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
There are many alternatives, but I *strongly* urge you to simply set up a separate build directory with a separate makefile (or equivalent) for each different "platform".

EXAMPLE:
[src]
project1/
widget1/
src/
dos/
linux/
aix
widget2/
src/
dos/
linux/
...
[/src/
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux file extension vs Dos file Extension? manaa Linux - Newbie 6 02-12-2009 04:19 PM
How to make alias of 'ls' in winxp/dos servnov General 4 11-04-2004 08:39 PM
converting text file from linux to ms dos Berhanie Linux - Newbie 4 12-24-2003 10:54 PM
Can I make a Redhat 8 bootdisk through Windows or DOS? milkmood Linux - Newbie 3 08-14-2003 10:08 AM
Like MS-DOS batch file but for Linux? rverlander Programming 2 06-23-2002 02:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration