Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Multiplatform makefile for gcc (Developers)

posted by Rugxulo Homepage, Usono, 26.03.2010, 19:35

> > Could someone give me an idea how to detect OS from makefile?
>
> I don't know how GCC handles this, but the FPC (g)makefiles query the
> compiler, which can print host and target OS and CPU.
>
> This also means that the makefile can autoconfigure crosscompiling.

"gcc -dumpmachine" is probably what you mean.

FYI, old DJGPP (GCC 2.6.3 and 2.7.2.3) says "go32" while everything since 2.8.1 says "djgpp". ;-)

P.S. marcov didn't mention, but *BSD doesn't come with GNU make by default, only its own (aka, pmake). I'm a lame coder, but even I did something like this (in "BSDmakefile"):


GCCVER != gcc -dumpversion
UNAME1 != uname -s
UNAME2 != uname -r
UNAME3 != uname -m
UNAME=$(UNAME1)\ $(UNAME2)\ $(UNAME3)
CPU=i686

.if ${GCCVER} == "3.3.3" || ${GCCVER} == "3.3.4" || ${GCCVER} == "3.3.5" || ${GCCVER} == "3.3.6"
MTUNE=-mcpu=$(CPU) -DMTUNE=\"$(CPU)\"
.else
MTUNE=-mtune=$(CPU) -DMTUNE=\"$(CPU)\"
.endif

OPTIMIZE=-O2 -fomit-frame-pointer

CXX=g++
CXXFLAGS=-s -static $(OPTIMIZE) $(MTUNE) -DOS_TARGET=\"$(UNAME)\"

---
Know your limits.h

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 242 users online (0 registered, 242 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum