1 |
#/************************************************************************** |
############################################################################## |
2 |
# * |
# |
3 |
# * linux makefile |
# - Unified Makefile for XviD for *nix environments - |
4 |
# * |
# |
5 |
# * nasm args: |
# Copyright(C) 2003 Edouard Gomez <ed.gomez@free.fr> |
6 |
# * -f fmt elf (linux), coff (djgpp) |
# |
7 |
# * -DPREFIX add '_' prefix to symbol names |
# |
8 |
# * |
# Description: |
9 |
# * libso: |
# This Makefile allows building XviD sources to obtain a shared library |
10 |
# * (-lm not neccessary if using -ffast-math) |
# and a static library. This Makefile uses variables defined in the |
11 |
# * |
# platform.inc file. This platform.inc file is usually created by the |
12 |
# *************************************************************************/ |
# ./configure script whenever a unix shell is available. |
13 |
|
# |
14 |
|
# Makefile functionnal dependencies: |
15 |
include Makefile.inc |
# - echo |
16 |
|
# - rm (with option -r and -f) |
17 |
CC = gcc |
# - cd |
18 |
#CC=icc |
# - make VPATH support (eg: GNU make, solaris 8 make) |
19 |
#CC = /opt/experimental/bin/gcc # that's where SuSE installs gcc3 |
# |
20 |
|
# Building output: |
21 |
CFLAGS = -DARCH_X86 -DLINUX |
# - C means "_C_ompiling" |
22 |
LIBDIR = /usr/local/lib |
# - A means "_A_ssembling" |
23 |
|
# - I means "_I_nstalling" |
24 |
ifeq ($(CC),icc) |
# - D means "creating _D_irectory" |
25 |
CFLAGS+= -O3 -ip -tpp6 -xM # -tpp7 might be faster (P4 optmization)... |
# - Cl means "_Cl_eaning" |
26 |
CFLAGS+= -I/opt/intel/compiler50/ia32/include -I/opt/intel/compiler50/ia32/substitute_headers/ |
# |
27 |
|
# NB: (for mingw32/djgpp users) |
28 |
else |
# These 2 environments do not provide a shell by default. So it's impossible |
29 |
|
# to use the configure script to generate a platform.inc file suitable for |
30 |
# CFLAGS += -funroll-loops -ffast-math -fstrict-aliasing -fomit-frame-pointer |
# your machine. You have two choices: |
31 |
# CFLAGS += -fPIC |
# - install minsys from the mingw project or install cygwin and then use |
32 |
# CFLAGS += -m486 |
# the configure script as on a unix system. |
33 |
# CFLAGS += -march=pentium -mcpu=pentium |
# - write a platform.inc file by hand. |
34 |
# CFLAGS += -march=pentiumpro -mcpu=pentiumpro |
# |
35 |
|
# PS: default build directory is "=build", it fits naming conventions that |
36 |
CFLAGS += -Wall -O3 -funroll-loops -ffast-math -march=pentiumpro -mcpu=pentiumpro |
# make the arch/tla revision control program ignore files contained in |
37 |
CFLAGS += -fstrict-aliasing -fomit-frame-pointer |
# this directory during commits operations. This choice is completly |
38 |
endif |
# arbitrary, but try not to change it. |
39 |
|
# |
40 |
|
############################################################################## |
41 |
|
|
42 |
AS = nasm |
include sources.inc |
43 |
AFLAGS = -f elf |
include platform.inc |
|
|
|
|
%.o: %.asm |
|
|
$(AS) $(AFLAGS) $< -o $@ |
|
44 |
|
|
45 |
RM = rm -rf |
RM = rm -rf |
46 |
|
|
47 |
|
############################################################################## |
48 |
|
# |
49 |
|
# Build rules |
50 |
|
# |
51 |
|
############################################################################## |
52 |
|
|
53 |
|
# Their Objects |
54 |
|
OBJECTS = $(GENERIC_OBJECTS) |
55 |
|
OBJECTS += $(ASSEMBLY_OBJECTS) |
56 |
|
OBJECTS += $(DCT_IA64_OBJECTS) |
57 |
|
|
58 |
|
# The VPATH mecanism could use a "per target" build directory |
59 |
|
# To keep it simple at the moment, the directory is fixed to "build" |
60 |
|
BUILD_DIR = =build |
61 |
|
VPATH = $(SRC_DIR):$(BUILD_DIR) |
62 |
|
|
63 |
|
#----------------------------------------------------------------------------- |
64 |
|
# The default rule |
65 |
|
#----------------------------------------------------------------------------- |
66 |
|
|
67 |
|
.SUFFIXES: .$(OBJECT_EXTENSION) .$(ASSEMBLY_EXTENSION) .c |
68 |
|
|
69 |
|
all: $(STATIC_LIB) $(SHARED_LIB) |
70 |
|
@echo |
71 |
|
@echo "---------------------------------------------------------------" |
72 |
|
@echo " XviD has been successfully built." |
73 |
|
@echo |
74 |
|
@echo " * Binaries are currently located in the '$(BUILD_DIR)' directory" |
75 |
|
@echo " * To install them on your system, you can run '# make install'" |
76 |
|
@echo " as root." |
77 |
|
@echo "---------------------------------------------------------------" |
78 |
|
@echo |
79 |
|
|
80 |
|
$(OBJECTS): platform.inc |
81 |
|
|
82 |
|
$(BUILD_DIR): |
83 |
|
@echo " D: $(BUILD_DIR)" |
84 |
|
@$(INSTALL) -d $(BUILD_DIR) |
85 |
|
|
86 |
|
#----------------------------------------------------------------------------- |
87 |
|
# Generic assembly rule |
88 |
|
#----------------------------------------------------------------------------- |
89 |
|
|
90 |
|
.$(ASSEMBLY_EXTENSION).$(OBJECT_EXTENSION): |
91 |
|
@echo " A: $(@D)/$(<F)" |
92 |
|
@$(INSTALL) -d $(BUILD_DIR)/$(@D) |
93 |
|
@$(AS) $(AFLAGS) $< -o $(BUILD_DIR)/$@ |
94 |
|
|
95 |
|
#----------------------------------------------------------------------------- |
96 |
|
# Generic C rule |
97 |
|
#----------------------------------------------------------------------------- |
98 |
|
|
99 |
|
.c.$(OBJECT_EXTENSION): |
100 |
|
@echo " C: $(@D)/$(<F)" |
101 |
|
@$(INSTALL) -d $(BUILD_DIR)/$(@D) |
102 |
|
@$(CC) -c $(ARCHITECTURE) $(BUS) $(ENDIANNESS) $(FEATURES) $(SPECIFIC_CFLAGS) $(CFLAGS) $< -o $(BUILD_DIR)/$@ |
103 |
|
|
104 |
|
#----------------------------------------------------------------------------- |
105 |
|
# Static Library |
106 |
|
#----------------------------------------------------------------------------- |
107 |
|
|
108 |
|
$(STATIC_LIB): $(BUILD_DIR) $(OBJECTS) |
109 |
|
@echo " L: $(@F)" |
110 |
|
@cd $(BUILD_DIR) && ar rc $(@F) $(OBJECTS) && $(RANLIB) $(@F) |
111 |
|
|
112 |
|
#----------------------------------------------------------------------------- |
113 |
|
# Shared Library |
114 |
|
# |
115 |
|
# NB: This rule is used a nasty way by the MacOSX module build process |
116 |
|
# In this only case, it uses the SPECIFIC_LDFLAGS to append an additionnal |
117 |
|
# linking step: |
118 |
|
# 1/ it links a pre shared lib (libxvidcore.so-temp.4) |
119 |
|
# 2/ it links that pre shared lib outputing the real shared lib (module) |
120 |
|
# In all other cases this rule is straight forward and simple. |
121 |
|
# PRE_SHARED_LIB == SHARED_LIB and no nasty command appending. |
122 |
|
# |
123 |
|
# NB': we copy the def file for the win32 target, the file is unused on other |
124 |
|
# platforms |
125 |
|
#----------------------------------------------------------------------------- |
126 |
|
|
127 |
|
$(SHARED_LIB): $(BUILD_DIR) $(OBJECTS) |
128 |
|
@echo " L: $(@F)" |
129 |
|
@$(INSTALL) -m 644 libxvidcore.def $(BUILD_DIR)/libxvidcore.def |
130 |
|
@cd $(BUILD_DIR) && $(CC) $(LDFLAGS) $(OBJECTS) -o $(PRE_SHARED_LIB) $(SPECIFIC_LDFLAGS) |
131 |
|
|
132 |
|
#----------------------------------------------------------------------------- |
133 |
|
# Installation |
134 |
|
#----------------------------------------------------------------------------- |
135 |
|
|
136 |
|
install: $(BUILD_DIR)/$(STATIC_LIB) $(BUILD_DIR)/$(SHARED_LIB) |
137 |
|
@echo " D: $(libdir)" |
138 |
|
@$(INSTALL) -d $(libdir) |
139 |
|
@echo " I: $(libdir)/$(SHARED_LIB)" |
140 |
|
@$(INSTALL) -m 755 $(BUILD_DIR)/$(SHARED_LIB) $(libdir)/$(SHARED_LIB) |
141 |
|
@echo " I: $(libdir)/$(STATIC_LIB)" |
142 |
|
@$(INSTALL) -m 755 $(BUILD_DIR)/$(STATIC_LIB) $(libdir)/$(STATIC_LIB) |
143 |
|
@echo " D: $(includedir)" |
144 |
|
@$(INSTALL) -d $(includedir) |
145 |
|
@echo " I: $(includedir)/xvid.h" |
146 |
|
@$(INSTALL) -m 644 $(SRC_DIR)/xvid.h $(includedir)/xvid.h |
147 |
|
|
148 |
|
#----------------------------------------------------------------------------- |
149 |
|
# Platorm specific file -- dumb rules for people executing make before |
150 |
|
# ./configure or even ./bootstrap.sh |
151 |
|
#----------------------------------------------------------------------------- |
152 |
|
|
153 |
|
platform.inc: configure platform.inc.in |
154 |
|
./configure |
155 |
|
|
156 |
|
configure: |
157 |
|
./bootstrap.sh |
158 |
|
|
159 |
|
#----------------------------------------------------------------------------- |
160 |
|
# .PHONY targets |
161 |
|
#----------------------------------------------------------------------------- |
162 |
|
|
163 |
all: $(LIB) $(LIBSO) |
.PHONY: mrproper distclean clean info \ |
164 |
|
list-objects list-targets list-install-path list-cflags |
|
|
|
|
$(LIB): $(SRC:.c=.o) $(SRC_INTEL:.asm=.o) |
|
|
ar rcs $@ $^ |
|
|
|
|
|
|
|
|
$(LIBSO): $(SRC:.c=.o) $(SRC_INTEL:.asm=.o) |
|
|
$(CC) $(CFLAGS) $^ -shared -lc -lm -o $@ |
|
|
|
|
165 |
|
|
166 |
clean: |
clean: |
167 |
$(RM) `find $(SRCDIR) -name "*.o"` |
@echo " Cl: Build directory" |
168 |
|
@$(RM) $(BUILD_DIR) |
169 |
|
|
170 |
|
distclean: clean |
171 |
|
@echo " Cl: Generated build files" |
172 |
|
@$(RM) platform.inc |
173 |
|
@$(RM) config.log |
174 |
|
@$(RM) config.status |
175 |
|
@$(RM) autom4te.cache |
176 |
|
|
177 |
|
mrproper: distclean |
178 |
|
@echo " Cl: Boostrapped build files" |
179 |
|
@$(RM) configure |
180 |
|
@$(RM) install-sh |
181 |
|
@$(RM) missing |
182 |
|
@$(RM) config.guess |
183 |
|
@$(RM) mkinstalldirs |
184 |
|
@$(RM) config.sub |
185 |
|
|
186 |
|
list-objects: |
187 |
|
@echo |
188 |
|
@echo "---------------------------------------------------------------" |
189 |
|
@echo "Object files used for this build" |
190 |
|
@echo "---------------------------------------------------------------" |
191 |
|
@echo |
192 |
|
@echo $(OBJECTS) |
193 |
|
@echo |
194 |
|
|
195 |
|
list-targets: |
196 |
|
@echo |
197 |
|
@echo "---------------------------------------------------------------" |
198 |
|
@echo "Target Libraries" |
199 |
|
@echo "---------------------------------------------------------------" |
200 |
|
@echo |
201 |
|
@echo Shared library: $(SHARED_LIB) |
202 |
|
@echo Static library: $(STATIC_LIB) |
203 |
|
@echo |
204 |
|
|
205 |
|
list-install-path: |
206 |
|
@echo |
207 |
|
@echo "---------------------------------------------------------------" |
208 |
|
@echo "Install Paths" |
209 |
|
@echo "---------------------------------------------------------------" |
210 |
|
@echo |
211 |
|
@echo Include Directory: $(includedir) |
212 |
|
@echo Library Directory: $(libdir) |
213 |
|
@echo |
214 |
|
|
215 |
|
list-cflags: |
216 |
|
@echo |
217 |
|
@echo "---------------------------------------------------------------" |
218 |
|
@echo "Using CFLAGS" |
219 |
|
@echo "---------------------------------------------------------------" |
220 |
|
@echo |
221 |
|
@echo CFLAGS=$(CFLAGS) |
222 |
|
@echo |
223 |
|
|
224 |
remove-all: |
info: list-objects list-cflags list-targets list-install-path |
|
$(RM) $(DIRS) |
|
|
$(RM) $(DIRS_INTEL) |
|
|
$(RM) $(LIB) |
|
|
$(RM) $(LIBSO) |
|
|
|
|
|
|
|
|
install: libxvidcore.so |
|
|
cp libxvidcore.so $(LIBDIR) # you have to bee root for this |
|
|
/sbin/ldconfig |
|
|
|
|
|
install-test: libxvidcore.so # if you don't want to overwrite previous compile |
|
|
cp libxvidcore.so $(LIBDIR)/libtestcore.so |
|
|
/sbin/ldconfig |
|