File: makefile.qnx

package info (click to toggle)
allegro4 2%3A4.0.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 17,052 kB
  • ctags: 12,972
  • sloc: ansic: 109,525; asm: 16,672; cpp: 3,221; sh: 1,761; makefile: 556; pascal: 105; perl: 73
file content (264 lines) | stat: -rw-r--r-- 7,524 bytes parent folder | download
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#
#  Rules for building the Allegro library with QNX. This file is included
#  by the primary makefile, and should not be used directly.
#
#  The "depend" target uses sed.
#
#  See makefile.all for a list of the available targets.



# -------- define some variables that the primary makefile will use --------

PLATFORM = QNX
OBJ_DIR = obj/qnx/$(VERSION)
LIB_NAME = lib/qnx/lib$(VERSION).a
EXE = 
OBJ = .o
HTML = html

PLATFORM_DIR = obj/qnx

UNIX_TOOLS = 1



# -------- give a sensible default target for make without any args --------

.PHONY: _default

_default: default



# -------- decide what compiler options to use --------

ifdef WARNMODE
   WFLAGS = -Wall -W -Werror -Wno-unused -Wno-multichar -Wno-ctor-dtor-privacy
else
   WFLAGS = -Wall -Wno-unused -Wno-multichar -Wno-ctor-dtor-privacy
endif

ifdef TARGET_ARCH_COMPAT
   TARGET_ARCH = -mcpu=$(TARGET_ARCH_COMPAT)
else
   ifdef TARGET_ARCH_EXCL
      TARGET_ARCH = -march=$(TARGET_ARCH_EXCL)
   else
      TARGET_ARCH = -mcpu=pentium
   endif
endif

ifndef TARGET_OPTS
   TARGET_OPTS = -O2 -funroll-loops -ffast-math
endif

OFLAGS = $(TARGET_ARCH) $(TARGET_OPTS)

ifdef DEBUGMODE

# -------- debugging build --------
CFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) -g
SFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS)
LFLAGS = -g

else
ifdef PROFILEMODE

# -------- profiling build --------
CFLAGS = $(WFLAGS) $(OFLAGS) -pg
SFLAGS = $(WFLAGS)
LFLAGS = -pg

else

# -------- optimised build --------
CFLAGS = $(WFLAGS) $(OFLAGS) -fomit-frame-pointer -fno-strength-reduce
SFLAGS = $(WFLAGS)
ifndef SYMBOLMODE
   LFLAGS += -s
endif

endif
endif



# -------- list platform specific objects and programs --------

VPATH = src/qnx src/unix src/misc

ifdef ALLEGRO_USE_C

# ------ build a C-only version ------

VPATH += src/c
MY_OBJECTS = $(C_OBJECTS) cmiscs
CFLAGS += -DALLEGRO_USE_C

else

# ------ build the normal asm version ------

VPATH += src/i386
MY_OBJECTS = $(I386_OBJECTS)

endif # ALLEGRO_USE_C

OBJECT_LIST = $(COMMON_OBJECTS) $(I386_OBJECTS) $(basename $(notdir $(ALLEGRO_SRC_QNX_FILES)))

LIBRARIES = -lm -lph -lasound



# -------- rules for installing and removing the library files --------

INSTALL_DIR = /usr

$(INSTALL_DIR)/lib/lib$(VERSION).a: $(LIB_NAME)
	cp $(LIB_NAME) $(INSTALL_DIR)/lib

$(INSTALL_DIR)/include/%: include/%
	cp $< $@

$(INSTALL_DIR)/include/allegro/%.h: include/allegro/%.h $(INSTALL_DIR)/include/allegro
	cp $< $@

$(INSTALL_DIR)/include/allegro:
	mkdir $(INSTALL_DIR)/include/allegro

$(INSTALL_DIR)/include/allegro/internal/%.h: include/allegro/internal/%.h $(INSTALL_DIR)/include/allegro/internal
	cp $< $@

$(INSTALL_DIR)/include/allegro/internal:
	mkdir $(INSTALL_DIR)/include/allegro/internal

$(INSTALL_DIR)/include/allegro/inline/%.inl: include/allegro/inline/%.inl $(INSTALL_DIR)/include/allegro/inline
	cp $< $@

$(INSTALL_DIR)/include/allegro/inline:
	mkdir $(INSTALL_DIR)/include/allegro/inline

$(INSTALL_DIR)/include/allegro/platform/%.h: include/allegro/platform/%.h $(INSTALL_DIR)/include/allegro/platform
	cp $< $@

$(INSTALL_DIR)/include/allegro/platform:
	mkdir $(INSTALL_DIR)/include/allegro/platform

$(INSTALL_DIR)/bin/allegro-config:
	cp misc/allegro-config-qnx.sh $(INSTALL_DIR)/bin/allegro-config
	chmod +x $(INSTALL_DIR)/bin/allegro-config

HEADERS = $(addprefix $(INSTALL_DIR)/include/,$(subst include/,,$(wildcard include/allegro/*.h)))          \
          $(addprefix $(INSTALL_DIR)/include/,$(subst include/,,$(wildcard include/allegro/internal/*.h))) \
          $(addprefix $(INSTALL_DIR)/include/,$(subst include/,,$(wildcard include/allegro/inline/*.inl)))

INSTALL_FILES = $(INSTALL_DIR)/lib/lib$(VERSION).a                 \
		$(INSTALL_DIR)/include/allegro.h                   \
		$(INSTALL_DIR)/include/allegro                     \
		$(INSTALL_DIR)/include/allegro/internal            \
		$(INSTALL_DIR)/include/allegro/inline              \
		$(INSTALL_DIR)/include/allegro/platform            \
		$(INSTALL_DIR)/include/qnxalleg.h                  \
		$(INSTALL_DIR)/include/allegro/platform/aintqnx.h  \
		$(INSTALL_DIR)/include/allegro/platform/al386gcc.h \
		$(INSTALL_DIR)/include/allegro/platform/alqnxcfg.h \
		$(INSTALL_DIR)/include/allegro/platform/alplatf.h  \
		$(INSTALL_DIR)/include/allegro/platform/alqnx.h    \
		$(HEADERS)                                         \
		$(INSTALL_DIR)/bin/allegro-config

install: $(INSTALL_FILES)
	@echo The $(DESCRIPTION) $(PLATFORM) library has been installed.

UNINSTALL_FILES = $(INSTALL_DIR)/lib/liballeg.a               \
		  $(INSTALL_DIR)/lib/liballd.a                \
		  $(INSTALL_DIR)/lib/liballp.a                \
		  $(INSTALL_DIR)/include/allegro.h            \
		  $(INSTALL_DIR)/include/qnxalleg.h           \
		  $(INSTALL_DIR)/include/allegro/*.h          \
		  $(INSTALL_DIR)/include/allegro/internal/*.h \
		  $(INSTALL_DIR)/include/allegro/inline/*.inl \
		  $(INSTALL_DIR)/include/allegro/platform/*.h \
		  $(INSTALL_DIR)/bin/allegro-config

uninstall:
	-rm -fv $(UNINSTALL_FILES)
	-rmdir $(INSTALL_DIR)/include/allegro/platform
	-rmdir $(INSTALL_DIR)/include/allegro/inline
	-rmdir $(INSTALL_DIR)/include/allegro/internal
	-rmdir $(INSTALL_DIR)/include/allegro
	@echo All gone!	


# test assembler capabilities.

include makefile.tst


# -------- finally, we get to the fun part... --------

define MAKE_LIB
   ar rs $(LIB_NAME) $(OBJECTS)
endef

COMPILE_FLAGS = $(subst src/,-DALLEGRO_SRC ,$(findstring src/, $<))$(CFLAGS)

$(OBJ_DIR)/%.o: %.c
	gcc $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<

$(OBJ_DIR)/%.o: %.cpp
	gcc $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<

$(OBJ_DIR)/%.o: %.s
	gcc $(SFLAGS) -I. -I./include -x assembler-with-cpp -o $@ -c $<

*/%: $(OBJ_DIR)/%.o $(LIB_NAME)
	gcc $(LFLAGS) -o $@ $< $(LIB_NAME) $(LIBRARIES)

obj/qnx/asmdef.inc: obj/qnx/asmdef
	obj/qnx/asmdef obj/qnx/asmdef.inc

obj/qnx/asmdef: src/i386/asmdef.c include/*.h include/allegro/*.h obj/qnx/asmcapa.h
	gcc -O $(WFLAGS) -I. -I./include -o obj/qnx/asmdef src/i386/asmdef.c

obj/qnx/setupdat.s: setup/setup.dat tools/dat2s
	tools/dat2s -o obj/qnx/setupdat.s setup/setup.dat

obj/qnx/setupdat.o: obj/qnx/setupdat.s
	gcc -o obj/qnx/setupdat.o -c obj/qnx/setupdat.s

setup/setup: $(OBJ_DIR)/setup.o obj/qnx/setupdat.o $(LIB_NAME)
	gcc $(LFLAGS) -o setup/setup $(OBJ_DIR)/setup.o obj/qnx/setupdat.o $(LIB_NAME) $(LIBRARIES)

PLUGIN_LIB = lib/qnx/lib$(VERY_SHORT_VERSION)dat.a
PLUGINS_H = obj/qnx/plugins.h
PLUGIN_DEPS = $(LIB_NAME) $(PLUGIN_LIB)
PLUGIN_SCR = scr

define GENERATE_PLUGINS_H
   cat tools/plugins/*.inc > obj/qnx/plugins.h
endef

define MAKE_PLUGIN_LIB
   ar rs $(PLUGIN_LIB) $(PLUGIN_OBJS)
endef

define LINK_WITH_PLUGINS
   gcc $(LFLAGS) -o $@ $< $(strip $(PLUGIN_LIB) $(addprefix @,$(PLUGIN_SCRIPTS)) $(LIB_NAME) $(LIBRARIES))
endef



# -------- generate automatic dependencies --------

DEPEND_PARAMS = -MM -MG -I. -I./include -DSCAN_DEPEND -DALLEGRO_QNX

depend:
	gcc $(DEPEND_PARAMS) src/*.c src/qnx/*.c src/unix/*.c src/i386/*.c src/misc/*.c demo/*.c examples/*.c setup/*.c tests/*.c tools/*.c tools/plugins/*.c > _depend.tmp
	gcc $(DEPEND_PARAMS) -x assembler-with-cpp src/i386/*.s src/qnx/*.s src/misc/*.s >> _depend.tmp
	sed -e "s/^[a-zA-Z0-9_\/]*\///" _depend.tmp > _depend2.tmp
	sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/qnx\/alleg\/\1/" _depend2.tmp > obj/qnx/alleg/makefile.dep
	sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/qnx\/alld\/\1/" _depend2.tmp > obj/qnx/alld/makefile.dep
	sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/qnx\/allp\/\1/" _depend2.tmp > obj/qnx/allp/makefile.dep
	rm _depend.tmp _depend2.tmp