Makefile 2.6 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
28
SRCS= $(SRCS_COMMON)
Laurent Aimar's avatar
Laurent Aimar committed
29

30 31 32
# MMX/SSE optims
ifeq ($(ARCH),X86)
CFLAGS+=-DHAVE_MMXEXT -DHAVE_SSE2
33
SRCS+= common/i386/mc-c.c common/i386/dct-c.c common/i386/predict.c
34
ASMSRC= common/i386/dct-a.asm common/i386/cpu-a.asm \
35 36
        common/i386/pixel-a.asm common/i386/mc-a.asm \
        common/i386/mc-a2.asm common/i386/predict-a.asm
37 38 39 40 41 42 43 44 45 46
OBJASM= $(ASMSRC:%.asm=%.o)
endif

# AltiVec optims
ifeq ($(ARCH),PPC)
ifeq ($(SYS),MACOSX)
CFLAGS+=-faltivec
else
CFLAGS+=-maltivec -mabi=altivec
endif
47
SRCS+= common/ppc/mc.c common/ppc/pixel.c
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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
70 71
AS= nasm
# for linux
Min Chen's avatar
Min Chen committed
72
ASFLAGS=-f elf $(PFLAGS)
Laurent Aimar's avatar
Laurent Aimar committed
73 74 75 76 77 78 79 80 81 82
# 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)
83
	ranlib libx264.a
Laurent Aimar's avatar
Laurent Aimar committed
84 85

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

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

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

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

99
config.h: $(wildcard .svn/entries */.svn/entries */*/.svn/entries)
100 101
	./version.sh

Laurent Aimar's avatar
Laurent Aimar committed
102 103 104 105 106 107
depend: .depend
ifneq ($(wildcard .depend),)
include .depend
endif

clean:
108
	rm -f $(OBJS) $(OBJASM) config.h *.a x264.o .depend x264 TAGS
Laurent Aimar's avatar
Laurent Aimar committed
109

Måns Rullgård's avatar
Måns Rullgård committed
110
distclean: clean
Laurent Aimar's avatar
Laurent Aimar committed
111

Loren Merritt's avatar
Loren Merritt committed
112 113 114 115 116 117
DIR_INSTALL="/usr/local"
install: x264
	install x264.h $(DIR_INSTALL)/include/
	install libx264.a $(DIR_INSTALL)/lib/
	install x264 $(DIR_INSTALL)/bin/

Måns Rullgård's avatar
Måns Rullgård committed
118 119 120 121
etags: TAGS

TAGS:
	etags $(SRCS)