VfW: cleaner install on win98.
[x264/x264-sandbox.git] / Makefile
1 # Makefile
2
3 # Uncomment the line for your platform
4 ARCH=X86
5 #ARCH=PPC
6
7 # Uncomment the line for you operating system
8 SYS=LINUX
9 #SYS=MACOSX
10 #SYS=BEOS
11 #SYS=FREEBSD
12
13 SRCS_COMMON= common/mc.c common/predict.c common/pixel.c common/macroblock.c \
14              common/frame.c common/dct.c common/cpu.c common/cabac.c \
15              common/common.c common/mdate.c common/csp.c \
16              encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
17              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 ifdef NDEBUG
24 CFLAGS+=-s -DNDEBUG
25 else
26 CFLAGS+=-g -DDEBUG
27 endif
28 SRCS= $(SRCS_COMMON)
29
30 # MMX/SSE optims
31 ifeq ($(ARCH),X86)
32 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         common/i386/pixel-a.asm common/i386/mc-a.asm \
36         common/i386/mc-a2.asm common/i386/predict-a.asm
37 OBJASM= $(ASMSRC:%.asm=%.o)
38 endif
39
40 # AltiVec optims
41 ifeq ($(ARCH),PPC)
42 ifeq ($(SYS),MACOSX)
43 CFLAGS+=-faltivec
44 else
45 CFLAGS+=-maltivec -mabi=altivec
46 endif
47 SRCS+= common/ppc/mc.c common/ppc/pixel.c
48 endif
49
50 # stdint.h: everyone but BeOS
51 ifneq ($(SYS),BEOS)
52 CFLAGS+=-DHAVE_STDINT_H
53 endif
54
55 # malloc.h: everyone but OS X and FreeBSD
56 ifneq ($(SYS),MACOSX)
57 ifneq ($(SYS),FREEBSD)
58 CFLAGS+=-DHAVE_MALLOC_H
59 endif
60 endif
61
62 # Math libraries we have to link to
63 ifneq ($(SYS),BEOS)
64 MATHLIBS=-lm
65 endif
66 ifeq ($(SYS),MACOSX)
67 MATHLIBS+=-lmx
68 endif
69
70 AS= nasm
71 # for linux
72 ASFLAGS=-f elf $(PFLAGS)
73 # for cygwin
74 #ASFLAGS=-f gnuwin32 -DPREFIX
75
76 OBJS = $(SRCS:%.c=%.o)
77 DEP  = depend
78
79 default: $(DEP) x264
80
81 libx264.a: $(OBJS) $(OBJASM)
82         ar rc libx264.a $(OBJS) $(OBJASM)
83         ranlib libx264.a
84
85 x264: libx264.a x264.o
86         $(CC) $(CFLAGS) -o x264 x264.o libx264.a $(MATHLIBS)
87
88 checkasm: testing/checkasm.c libx264.a
89         $(CC) $(CFLAGS) -o checkasm $< libx264.a $(MATHLIBS)
90
91 %.o: %.asm
92         $(AS) $(ASFLAGS) -o $@ $<
93
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;)
98
99 config.h: $(wildcard .svn/entries */.svn/entries)
100         ./version.sh
101
102 depend: .depend
103 ifneq ($(wildcard .depend),)
104 include .depend
105 endif
106
107 clean:
108         rm -f $(OBJS) $(OBJASM) config.h *.a x264.o .depend x264 TAGS
109
110 distclean: clean
111
112 DIR_INSTALL="/usr/local"
113 install: x264
114         install x264.h $(DIR_INSTALL)/include/
115         install libx264.a $(DIR_INSTALL)/lib/
116         install x264 $(DIR_INSTALL)/bin/
117
118 etags: TAGS
119
120 TAGS:
121         etags $(SRCS)