compiler updates
[sacl.git] / common.mk
blobd64eb1b3f1ca8dfa8f824ccc4d12cdd46f00c479
1 ##
2 # Variables included by all Makefiles.
3 ##
5 ## Directory definitions
7 libdir = $(saclroot)/lib
8 mobiusdir = $(saclroot)/src/mobius
9 pluginsdir = $(saclroot)/src/plugins
10 testdir = $(saclroot)/tests
12 prefix = /usr/local
13 datadir = $(prefix)/share/sacl
14 exec_prefix = $(prefix)/bin
15 execname = sacl
16 includedir = $(prefix)/include
17 mandir = $(prefix)/share/man
18 man1dir = $(mandir)/man1
19 infodir = $(prefix)/info
20 lispdir = $(prefix)/share/emacs/site-lisp
21 DEVNULL := /dev/null
23 ## Build modes. Set on command line using QUIET=1, DEBUG=1 or PROFILE=1
25 ifndef QUIETNESS
26 QUIETNESS := -q
27 endif
29 ifdef QUIET
30 VERBOSE := 0
31 SILENT := @
32 SILENT_ERRORS := 2> $(DEVNULL)
33 LIBTOOL_FLAGS += --silent
34 endif
36 ifdef DEBUG
37 MODE := debug
38 COPTFLAGS += -g
39 LDFLAGS += -g
40 CFLAGS += -DSACL_BUILD_TYPE="\"Debug\""
41 else
42 ifdef PROFILE
43 MODE += profiled
44 COPTFLAGS += -pg -g -O2 -fprofile-arcs -ftest-coverage
45 LDFLAGS += -pg -g -fprofile-arcs -ftest-coverage
46 CFLAGS += -DSACL_BUILD_TYPE="\"Profile\""
47 else
48 MODE := optimized
49 CFLAGS += -DSACL_BUILD_TYPE="\"Optimized\""
50 COPTFLAGS += -O2
51 endif
52 endif
54 ## All required executables
56 CC := gcc
57 CPP := g++
58 CP := cp -f
59 LIBTOOL ?= libtool
60 ECHO := echo
61 WGET := wget -q --cache=off
62 SECHO := @$(ECHO)
63 INSTALL := install
64 TAR := tar
65 GZIP := gzip
66 ETAGS := etags
67 EMACS := emacs
69 ## Platform independent definitions
71 INCLUDES +=
72 #CFLAGS += -DSACL_DATADIR=$(datadir) -D_POSIX_SOURCE=200112L -D_POSIX_C_SOURCE=200112L
73 CFLAGS += -DSACL_DATADIR=$(datadir) -D_XOPEN_SOURCE=600 --std=c++0x
74 CFLAGS += $(COPTFLAGS) -Wall -Wno-unknown-pragmas $(EXTRACFLAGS) $(INCLUDES)
75 # include -pedantic later fixme
77 ## Determine the host system's byte order.
78 ## This creates a temporary test executable in the $(saclroot) directory
79 ## since we can guarantee write permissions there on all platforms.
81 BYTE_ORDER_FN := $(saclroot)/byteorder
82 BYTE_ORDER_SRC := "int main(){union{long l;char c[sizeof(long)];}u;u.l=1;return(u.c[sizeof(long)-1]==1);}"
83 BYTE_ORDER := $(shell echo $(BYTE_ORDER_SRC) > $(BYTE_ORDER_FN).c)
84 BYTE_ORDER := $(shell $(CC) -o $(BYTE_ORDER_FN) $(BYTE_ORDER_FN).c)
85 BYTE_ORDER := $(shell $(BYTE_ORDER_FN); echo $$?)
86 BYTE_ORDER_ := $(shell $(RM) $(BYTE_ORDER_FN).* $(BYTE_ORDER_FN) 1>&2)
87 ifeq ($(BYTE_ORDER),0)
88 BYTE_ORDER := LITTLE_ENDIAN
89 BYTE_ORDER_PREFIX := little
90 LITTLE_ENDIAN_SACL := True
91 else
92 BYTE_ORDER := BIG_ENDIAN
93 BYTE_ORDER_PREFIX := big
94 LITTLE_ENDIAN_SACL := False
95 endif
97 ## Default variables
99 PLATFORM := unix
100 CCVERSION := $(shell $(CC) -dumpversion)
101 LDFLAGS :=
102 LIBS := #-lm -ldl
103 HOST_SYSTEM := $(shell uname -s)
104 LIB_SO_EXT := .so
105 INSTALL_MODE := -m 644
106 CPU_TYPE := `uname -m`
108 COMPILERDIR := $(saclroot)/src/compiler
111 ## Determine CPU type
113 ## TODO: Sparc detection for SunOS?
114 ## TODO: Base CPU type on real information, not just generic OS variant
116 ## CPU-type specific overrides. Any of the variables above may be changed here.
118 ifdef ARCH
119 CFLAGS += -m$(ARCH)
120 endif
122 ifdef VERSION
123 CFLAGS += -DVERSION="\"$(VERSION)\""
124 endif
126 ifdef WORD_SIZE
127 CFLAGS += -m$(WORD_SIZE)
128 CFLAGS += -D_FILE_OFFSET_BITS=$(WORD_SIZE)
129 endif
132 ## Platform specific overrides. Any of the variables above may be changed here.
135 ifeq ($(findstring CYGWIN,$(HOST_SYSTEM)), CYGWIN)
136 PLATFORM := windows
137 LDFLAGS += -no-undefined
138 LIBS := -lm
139 LIB_SO_EXT := .dll
140 # DEVNULL := NUL # Required if using cmd.exe and not bash.
141 endif
143 ifeq ($(HOST_SYSTEM), Darwin)
144 # LIBTOOL := MACOSX_DEPLOYMENT_TARGET=10.3 glibtool
145 LIBTOOL := glibtool
146 PLUGINS := cocoa-windows.so
147 endif
149 ifeq ($(HOST_SYSTEM), DragonFly)
150 LIBS := -lm
151 endif
153 ifeq ($(HOST_SYSTEM), FreeBSD)
154 LIBS := -lm -lc_r
155 LIBTOOL := libtool13
156 endif
158 ifeq ($(HOST_SYSTEM), HP-UX)
159 LIBS := -lm
160 # -ldld
161 LIB_SO_EXT := .sl
162 endif
164 ifeq ($(HOST_SYSTEM), Linux)
165 LIBS := -lm
166 # -ldl
167 endif
169 ifeq ($(findstring MINGW,$(HOST_SYSTEM)), MINGW)
170 PLATFORM := windows
171 LIBS := -lm
172 endif
174 ifeq ($(HOST_SYSTEM), NetBSD)
175 LIBS := -lm
176 endif
178 PLUGINS := $(subst .so,$(LIB_SO_EXT), $(PLUGINS))