improve generation of Darwin libraries
[x262.git] / gtk / Makefile
1
2 include config.mak
3
4 # Architecture dependant stuff
5
6 ifeq ($(SYS),MINGW)
7 datadir="$(HOMEDRIVE)/Documents\ and\ Settings/$(USERNAME)/Application\ Data"
8 X264GTK_O = x264gtk.o
9 TEST_OBJECTS+=$(X264GTK_O)
10 LDFLAGS+=-mwindows
11 ICONV_LIB = -liconv
12 else
13 datadir=${prefix}/share
14 X264GTK_O =
15 ICONV_LIB =
16 endif
17
18 XGETTEXT=xgettext$(EXE)
19 TEST_BIN = test$(EXE)
20 ENCODE_BIN = x264_gtk_encode$(EXE)
21
22 # PO / MO files
23 PO_FILES = $(shell ls *.po)
24 MO_FILES = $(PO_FILES:%.po=%.mo)
25 ALL_LINGUAS = $(PO_FILES:%.po=%)
26
27 # Object files
28 OBJECTS_LIB =      \
29 x264_gtk_bitrate.o \
30 x264_gtk_cqm.o     \
31 x264_gtk_mb.o      \
32 x264_gtk_more.o    \
33 x264_gtk_rc.o      \
34 x264_gtk.o
35
36 OBJECTS_TEST = test.o
37
38 OBJECTS_ENCODE =                \
39 x264_gtk_encode_encode.o        \
40 x264_gtk_encode_main_window.o   \
41 x264_gtk_encode_status_window.o \
42 x264_gtk_encode.o
43
44 OBJECTS_ALL = $(OBJECTS_LIB) $(OBJECTS_TEST) $(OBJECTS_ENCODE)
45 SOURCES_ALL = $(OBJECTS_ALL:%.o=%.c)
46
47 X264GTK_PC = x264gtk.pc
48
49 EXTERNAL_DEPS= ../muxers.o ../matroska.o ../libx264.a
50
51
52 all: $(ENCODE_BIN) $(TEST_BIN) $(MO_FILES) $(X264GTK_PC)
53
54 # Already provides iconv/intl
55 CPPFLAGS = -g `pkg-config --cflags gtk+-2.0 gthread-2.0` -I.. -DX264_DATA_DIR=\"${datadir}\"
56 LDFLAGS += `pkg-config --libs gtk+-2.0 gthread-2.0` ../libx264.a
57
58
59 # gettext rules
60 x264_gtk.pot: $(SOURCES_ALL)
61         @echo "  T: x264_gtk.pot"
62         @$(XGETTEXT) -o x264_gtk.pot -k'_' -s --from-code iso-8859-1 \
63         --default-domain=x264_gtk $(SOURCES_ALL)
64
65 %.mo: %.po x264_gtk.pot
66         @echo "  T: $@"
67         @msgmerge --update $< x264_gtk.pot
68         @msgfmt -o $@ $<
69
70
71 # Compilation rule
72 %.o : %.c
73         @echo "  C: $(@D)/$(<F)"
74         @$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
75
76 ifeq ($(SYS),MINGW)
77 %.o : %.rc
78         @echo "  C: $(@D)/$(<F)"
79         @windres -o $@ -i $<
80 endif
81
82
83 # Creation of the icon pixmap
84 x264_icon.h: x264.ico
85         @gdk-pixbuf-csource --name=x264_icon --stream x264.ico > x264_icon.h
86
87
88 # Linking rule
89 libx264gtk.a: $(OBJECTS_LIB)
90         @echo "  L: $(@F)"
91         @ar rc libx264gtk.a $(OBJECTS_LIB)
92         @ranlib libx264gtk.a
93
94 $(SONAMEGTK): $(OBJECTS_LIB)
95         @echo "  L: $(@F)"
96         @$(CC) -shared -o $@ $(OBJECTS_LIB) $(SOFLAGS) $(LDFLAGS)
97
98 # Program : test
99 $(TEST_BIN): $(OBJECTS_LIB) $(OBJECTS_TEST)
100         @echo "  B: $(@F)"
101 #Needs iconv/intl
102         @$(CC) -o $(TEST_BIN) $(OBJECTS_LIB) $(OBJECTS_TEST) $(LDFLAGS) $(ICONV_LIB)
103
104 # Program : x264_gtk_encode
105 $(ENCODE_BIN): x264_icon.h libx264gtk.a $(SONAMEGTK) $(OBJECTS_ENCODE) $(EXTERNAL_DEPS) $(X264GTK_O)
106         @echo "  B: $(@F)"
107         @$(CC) -o $(ENCODE_BIN) $(OBJECTS_LIB) $(OBJECTS_ENCODE) $(EXTERNAL_DEPS) $(LDFLAGS) $(X264GTK_O)
108
109 # x264gtk.pc file
110 $(X264GTK_PC):
111         @echo "  S: $(X264GTK_PC)"
112         @rm -f $(X264GTK_PC)
113         @echo "prefix=$(DESTDIR)${prefix}" > $(X264GTK_PC)
114         @echo "exec_prefix=$(DESTDIR)${exec_prefix}" >> $(X264GTK_PC)
115         @echo "libdir=$(DESTDIR)${libdir}" >> $(X264GTK_PC)
116         @echo "includedir=$(DESTDIR)${includedir}" >> $(X264GTK_PC)
117         @echo "" >> $(X264GTK_PC)
118         @echo "Name: Gtk+ interface for X264" >> $(X264GTK_PC)
119         @echo "Description: Gtk+ interface to configure X264" >> $(X264GTK_PC)
120         @echo "Requires: x264" >> $(X264GTK_PC)
121         @echo "Version: 0.1" >> $(X264GTK_PC)
122         @echo "Libs: -L$(DESTDIR)$(libdir) -lx264gtk" >> $(X264GTK_PC)
123         @echo "Cflags: -I$(DESTDIR)$(includedir)" >> $(X264GTK_PC)
124
125 # Clean rule
126 clean:
127         @rm -f *.o *.mo x264_gtk.pot $(TEST_BIN) $(ENCODE_BIN) libx264gtk.a $(SONAMEGTK) x264_icon.h
128
129 # Distclean rule
130 distclean:
131         @rm -f config.mak $(X264GTK_PC)
132
133 # Install rule
134 install: $(ENCODE_BIN)
135         @echo "  D: $(DESTDIR)$(includedir)"
136         @install -d "$(DESTDIR)$(includedir)"
137         @echo "  I: $(DESTDIR)$(includedir)/x264_gtk.h"
138         @install -m 644 x264_gtk.h "$(DESTDIR)$(includedir)"
139         @echo "  I: $(DESTDIR)$(includedir)/x264_gtk_enum.h"
140         @install -m 644 x264_gtk_enum.h "$(DESTDIR)$(includedir)"
141         @echo "  D: $(DESTDIR)$(libdir)"
142         @install -d "$(DESTDIR)$(libdir)"
143         @echo "  I: $(DESTDIR)$(libdir)/libx264gtk.a"
144         @install -m 644 libx264gtk.a "$(DESTDIR)$(libdir)"
145         @echo "  I: $(DESTDIR)$(libdir)/libx264gtk.$(SOSUFFIX)"
146         @$(if $(SONAMEGTK), ln -sf $(SONAMEGTK) $(DESTDIR)$(libdir)/libx264gtk.$(SOSUFFIX))
147         @$(if $(SONAMEGTK), install -m 755 $(SONAMEGTK) $(DESTDIR)$(libdir))
148         @echo "  D: $(DESTDIR)$(bindir)"
149         @install -d "$(DESTDIR)$(bindir)"
150         @echo "  I: $(DESTDIR)$(bindir)/$(ENCODE_BIN)"
151         @install $(ENCODE_BIN) "$(DESTDIR)$(bindir)"
152         @echo "  D: $(DESTDIR)${datadir}/x264"
153         @install -d "$(DESTDIR)${datadir}/x264"
154         @echo "  I: $(DESTDIR)${datadir}/x264/x264.png"
155         @install -m 644 x264.png "$(DESTDIR)${datadir}/x264"
156         @for L in $(ALL_LINGUAS); do \
157           echo "  D: $(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES"; \
158           install -d "$(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES"; \
159           echo "  I: $(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES/x264_gtk.mo"; \
160           install -m 644 $$L.mo "$(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES/x264_gtk.mo"; \
161         done
162         @echo "  D: $(DESTDIR)${libdir}/pkgconfig"
163         @install -d "$(DESTDIR)${libdir}/pkgconfig"
164         @echo "  I: $(DESTDIR)${libdir}/pkgconfig/$(X264GTK_PC)"
165         @install -m 644 $(X264GTK_PC) "$(DESTDIR)${libdir}/pkgconfig"
166
167 # Uninstall rule
168 uninstall:
169         @echo "  U: $(DESTDIR)$(includedir)/x264_gtk.h"
170         @rm -f "$(DESTDIR)$(includedir)/x264_gtk.h"
171         @echo "  U: $(DESTDIR)$(includedir)/x264_gtk_enum.h"
172         @rm -f "$(DESTDIR)$(includedir)/x264_gtk_enum.h"
173         @echo "  U: $(DESTDIR)$(libdir)/libx264gtk.a"
174         @rm -f "$(DESTDIR)$(libdir)/libx264gtk.a"
175         @echo "  U: $(DESTDIR)$(libdir)/$(SONAMEGTK)"
176         @$(if $(SONAMEGTK), rm -f "$(DESTDIR)$(libdir)/$(SONAMEGTK)")
177         @rm -f "$(DESTDIR)$(libdir)/libx264gtk.$(SOSUFFIX)"
178         @echo "  U: $(DESTDIR)$(bindir)/$(ENCODE_BIN)"
179         @rm -f "$(DESTDIR)$(bindir)/$(ENCODE_BIN)"
180         @echo "  U: $(DESTDIR)${datadir}/x264"
181         @rm -rf "$(DESTDIR)${datadir}/x264"
182         @for L in $(ALL_LINGUAS); do \
183           echo "  U: $(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES/x264_gtk.mo"; \
184           rm -f "$(DESTDIR)${prefix}/share/locale/$$L/LC_MESSAGES/x264_gtk.mo"; \
185         done
186         @echo "  U: $(DESTDIR)${libdir}/pkgconfig/$(X264GTK_PC)"
187         @rm -f "$(DESTDIR)${libdir}/pkgconfig/$(X264GTK_PC)"
188
189
190 x264_gtk.o: x264_gtk.h x264gtk.rc x264.ico x264_gtk_bitrate.h x264_gtk_bitrate.o x264_gtk_rc.h x264_gtk_rc.o x264_gtk_mb.h x264_gtk_mb.o x264_gtk_more.h x264_gtk_more.o  x264_gtk_cqm.h x264_gtk_cqm.o x264_gtk_i18n.h
191 x264_gtk_bitrate.o: x264_gtk_private.h x264_gtk_enum.h x264_gtk_bitrate.c x264_gtk_i18n.h
192 x264_gtk_rc.o: x264_gtk_private.h x264_gtk_rc.c x264_gtk_i18n.h
193 x264_gtk_mb.o: x264_gtk_private.h x264_gtk_mb.c x264_gtk_i18n.h
194 x264_gtk_more.o: x264_gtk_private.h x264_gtk_more.c x264_gtk_i18n.h
195 x264_gtk_cqm.o: x264_gtk_private.h x264_gtk_cqm.c x264_gtk_i18n.h
196 x264_gtk_encode_encode.o: x264_gtk_encode_private.h x264_gtk_encode_encode.c x264_gtk_i18n.h
197 x264_gtk_encode_status_window.o: x264_gtk_encode_private.h x264_gtk_encode_status_window.c x264_gtk_demuxers.h x264_gtk_i18n.h
198 x264_gtk_encode_main_window.o: x264_gtk_encode_private.h x264_gtk_encode_encode.o x264_gtk_encode_status_window.o x264_gtk.o x264_gtk_encode_main_window.c x264_gtk_demuxers.h x264_gtk_i18n.h
199 x264_gtk_encode.o: x264_gtk_encode_main_window.o x264_gtk_encode.c x264_gtk_i18n.h
200 test.o: x264_gtk.o test.c x264_gtk_i18n.h