Multiplatform makefile for gcc (Developers)
> > 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:
- Multiplatform makefile for gcc - RayeR, 26.03.2010, 01:14 (Developers)
- Multiplatform makefile for gcc - Rugxulo, 26.03.2010, 03:56
- Multiplatform makefile for gcc - marcov, 26.03.2010, 14:20
- Multiplatform makefile for gcc - Rugxulo, 26.03.2010, 19:35
- Multiplatform makefile for gcc - RayeR, 29.03.2010, 01:23
- Multiplatform makefile for gcc - Rugxulo, 26.03.2010, 19:35