summaryrefslogtreecommitdiff
blob: 38e9b36fa2b3d3fe4d228d0fe97a10ff69e09fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
From: Julian Ospald <hasufell@gentoo.org>
Date: Sat Feb  2 01:16:21 UTC 2013
Subject: build system

	respect CC/CXX etc and CFLAGS/CXXFLAGS/LDFLAGS

--- eduke32_20130201-3453/Makefile
+++ eduke32_20130201-3453/Makefile
@@ -311,10 +311,10 @@
 endif
 
 COMPILER=$(CC) $(OURCONLYFLAGS)
-LINKER=$(L_CC)
+LINKER=$(L_CC) $(OURCFLAGS) $(OURCONLYFLAGS)
 ifneq ($(CPLUSPLUS),0)
     COMPILER=$(CXX) $(OURCXXFLAGS)
-    LINKER=$(L_CXX)
+    LINKER=$(L_CXX) $(OURCXXFLAGS)
 endif
 
 ifeq ($(PRETTY_OUTPUT),1)
--- eduke32_20130201-3453/Makefile.common
+++ eduke32_20130201-3453/Makefile.common
@@ -10,13 +10,14 @@
 
 # Tools
 CROSS=
-CC=$(CROSS)gcc
-CXX=$(CROSS)g++
-AS=$(CROSS)nasm
-AR=$(CROSS)ar
-RC=$(CROSS)windres
-RANLIB=$(CROSS)ranlib
-STRIP=$(CROSS)strip
+CC ?= $(CROSS)gcc
+CXX ?= $(CROSS)g++
+AS ?= $(CROSS)nasm
+AR ?= $(CROSS)ar
+RC ?= $(CROSS)windres
+RANLIB ?= $(CROSS)ranlib
+STRIP ?= $(CROSS)strip
+PKG_CONFIG ?= pkgconfig
 
 L_CC=$(CC)
 L_CXX=$(CXX)
@@ -164,7 +165,6 @@
 #  FORCEWARNINGS - 1 = do not disable any compiler warnings within the source
 #  KRANDDEBUG - 1 = include logging of krand() calls for debugging the demo system
 #  EFENCE  - 1 = compile with Electric Fence for malloc() debugging
-#  OPTLEVEL	- 0..3 = GCC optimization strategy
 #  LTO - 1 = enable link-time optimization, for GCC 4.5 and up
 #
 CPLUSPLUS?=0
@@ -178,13 +178,6 @@
 PROFILER?=0
 MUDFLAP?=0
 
-# Select the default optimization level for release and debug builds.
-ifeq ($(RELEASE),0)
-    OPTLEVEL?=0
-else
-    OPTLEVEL?=2
-endif
-
 ifeq ($(RELEASE),0)
     override STRIP=
 endif
@@ -293,10 +286,9 @@
 
 # compiler flags etc.
 BASECFLAGS=
-BASECONLYFLAGS=-Wimplicit -Wdeclaration-after-statement
-BASECXXFLAGS= -fno-exceptions -fno-rtti -fpermissive -Wno-write-strings
-BASEASFLAGS=-s #-g
-BASELDFLAGS=
+BASECONLYFLAGS = $(CFLAGS) -std=gnu89 -Wimplicit -Wdeclaration-after-statement
+BASECXXFLAGS = $(CXXFLAGS) -fno-exceptions -fno-rtti -fpermissive -Wno-write-strings -Wno-narrowing
+BASELDFLAGS = $(LDFLAGS)
 
 
 ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
@@ -330,19 +322,6 @@
 endif
 
 
-ifneq ($(RELEASE)$(DEBUGANYWAY),10)
-    # debug build or DEBUGANYWAY=1 --> -g flag
-    ifneq (0,$(CLANG))
-        debug=-g
-    else ifeq ($(PLATFORM), WII)
-        debug=-g
-    else
-        debug=-ggdb
-    endif
-endif
-
-debug+= -O$(OPTLEVEL)
-
 # See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
 # for a list of possible UBSan options.
 # Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer
@@ -458,7 +437,7 @@
 
 #### Lunatic development
 # LuaJIT standalone interpreter executable:
-LUAJIT:=luajit
+LUAJIT:=$(shell command -v luajit || command -v luajit-2 || command -v luajit-2.0)
 # Options to "luajit -b" for synthesis. Since it runs on Linux, we need to tell
 # the native LuaJIT to emit PE object files.
 ifneq ($(SYNTHESIS),0)
@@ -487,7 +466,8 @@
     ifeq ($(PLATFORM),WINDOWS)
         BASELIBS+= -lluajit
     else
-        BASELIBS+= -lluajit-5.1
+        BASECOMMONFLAGS+= $(shell $(PKG_CONFIG) --cflags luajit 2>/dev/null || $(PKG_CONFIG) --cflags luajit-2.0)
+        BASELIBS+= $(shell $(PKG_CONFIG) --libs luajit 2>/dev/null || $(PKG_CONFIG) --libs luajit-2.0)
     endif
 endif
 
--- eduke32_20130201-3453/build/Makefile
+++ eduke32_20130201-3453/build/Makefile
@@ -167,13 +167,15 @@
 OURCOMMONFLAGS+= $(BUILDCOMMONFLAGS)
 
 COMPILER=$(CC) $(OURCONLYFLAGS)
-LINKER=$(L_CC)
+LINKER=$(L_CC) $(OURCFLAGS) $(OURCONLYFLAGS)
 ifneq ($(CPLUSPLUS),0)
     COMPILER=$(CXX) $(OURCXXFLAGS)
-    LINKER=$(L_CXX)
+    LINKER=$(L_CXX) $(OURCXXFLAGS)
 endif
 
-.SILENT:
+ifeq ($(PRETTY_OUTPUT),1)
+ .SILENT:
+endif
 .PHONY: clean cleanutils veryclean all utils dxutils sdlutils printutils printsdlutils printdxutils enginelib editorlib
 
 # TARGETS
@@ -266,7 +268,7 @@
 	if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS) -I$(SDLROOT)/include -I$(SDLROOT)/include/SDL; then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
 arttool$(EXESUFFIX): $(OBJ)/arttool.$o $(UTILADDOBJS)
 	$(ONESTEP_STATUS)
-	if $(L_CXX) -o $@ $^ $(OURLDFLAGS) $(STATICSTDCPP) $(STDCPPLIB) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
+	if $(L_CXX) $(OURCXXFLAGS) -o $@ $^ $(OURLDFLAGS) $(STATICSTDCPP) $(STDCPPLIB) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
 givedepth$(EXESUFFIX): $(OBJ)/givedepth.$o $(UTILADDOBJS)
 	$(ONESTEP_STATUS)
 	if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi