Makefile 2.31 KB
Newer Older
1
# Makefile
2

3
4
5
# Uncomment the line for your platform
ARCH=X86
#ARCH=PPC
Laurent Aimar's avatar
Laurent Aimar committed
6

7
8
9
10
11
# Uncomment the line for you operating system
SYS=LINUX
#SYS=MACOSX
#SYS=BEOS
#SYS=FREEBSD
12

13
14
15
SRCS_COMMON= common/mc.c common/predict.c common/pixel.c common/macroblock.c \
             common/frame.c common/dct.c common/cpu.c common/cabac.c \
             common/common.c common/mdate.c common/csp.c \
Eric Petit's avatar
Typo    
Eric Petit committed
16
17
             encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
             encoder/set.c encoder/macroblock.c encoder/cabac.c \
18
             encoder/cavlc.c encoder/encoder.c encoder/eval.c
19

20
# Compiler, global flags
21
CC=gcc
22
CFLAGS=-Wall -I. -O4 -funroll-loops -D__X264__ -DARCH_$(ARCH) -DSYS_$(SYS)
23
24
25
26
27
ifdef NDEBUG
CFLAGS+=-s -DNDEBUG
else
CFLAGS+=-g -DDEBUG
endif
Laurent Aimar's avatar
Laurent Aimar committed
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
# MMX/SSE optims
ifeq ($(ARCH),X86)
CFLAGS+=-DHAVE_MMXEXT -DHAVE_SSE2
SRCS= $(SRCS_COMMON) common/i386/mc-c.c common/i386/dct-c.c \
      common/i386/predict.c
ASMSRC= common/i386/dct-a.asm common/i386/cpu-a.asm \
        common/i386/pixel-a.asm common/i386/mc-a.asm
OBJASM= $(ASMSRC:%.asm=%.o)
endif

# AltiVec optims
ifeq ($(ARCH),PPC)
ifeq ($(SYS),MACOSX)
CFLAGS+=-faltivec
else
CFLAGS+=-maltivec -mabi=altivec
endif
SRCS= $(SRCS_COMMON) common/ppc/mc.c common/ppc/pixel.c
endif

# stdint.h: everyone but BeOS
ifneq ($(SYS),BEOS)
CFLAGS+=-DHAVE_STDINT_H
endif

# malloc.h: everyone but OS X and FreeBSD
ifneq ($(SYS),MACOSX)
ifneq ($(SYS),FREEBSD)
CFLAGS+=-DHAVE_MALLOC_H
endif
endif

# Math libraries we have to link to
ifneq ($(SYS),BEOS)
MATHLIBS=-lm
endif
ifeq ($(SYS),MACOSX)
MATHLIBS+=-lmx
endif

Laurent Aimar's avatar
Laurent Aimar committed
69
70
AS= nasm
# for linux
Min Chen's avatar
Min Chen committed
71
ASFLAGS=-f elf $(PFLAGS)
Laurent Aimar's avatar
Laurent Aimar committed
72
73
74
75
76
77
78
79
80
81
# for cygwin
#ASFLAGS=-f gnuwin32 -DPREFIX

OBJS = $(SRCS:%.c=%.o)
DEP  = depend

default: $(DEP) x264

libx264.a: $(OBJS) $(OBJASM)
	ar rc libx264.a $(OBJS) $(OBJASM)
82
	ranlib libx264.a
Laurent Aimar's avatar
Laurent Aimar committed
83
84

x264: libx264.a x264.o
85
	$(CC) $(CFLAGS) -o x264 x264.o libx264.a $(MATHLIBS)
Laurent Aimar's avatar
Laurent Aimar committed
86
87

checkasm: testing/checkasm.c libx264.a
88
	$(CC) $(CFLAGS) -o checkasm $< libx264.a $(MATHLIBS)
Laurent Aimar's avatar
Laurent Aimar committed
89
90
91
92
93

%.o: %.asm
	$(AS) $(ASFLAGS) -o $@ $<

.depend: $(SRCS) x264.c
94
	rm -f .depend
95
96
# Hacky - because gcc 2.9x doesn't have -MT
	$(foreach SRC, $(SRCS) x264.c, ( echo -n "`dirname $(SRC)`/" && $(CC) $(CFLAGS) $(SRC) -MM ) 1>> .depend;)
Laurent Aimar's avatar
Laurent Aimar committed
97
98
99
100
101
102
103

depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

clean:
Måns Rullgård's avatar
Måns Rullgård committed
104
	rm -f $(OBJS) $(OBJASM) *.a x264.o .depend x264 TAGS
Laurent Aimar's avatar
Laurent Aimar committed
105

Måns Rullgård's avatar
Måns Rullgård committed
106
distclean: clean
Laurent Aimar's avatar
Laurent Aimar committed
107

Måns Rullgård's avatar
Måns Rullgård committed
108
109
110
111
etags: TAGS

TAGS:
	etags $(SRCS)