Fix x86_64 CFLAGS detection.
[thrasher.git] / Makefile
bloba762511ffed0d672ad07502374ef5e8a6d798dff
1 ### "config" options
2 PERL = /usr/bin/perl
3 GLIB_PREFIX = /usr
4 PURPLE_PREFIX = /usr
5 ### end of build config
7 PERL_CFLAGS := $(shell PERL5LIB= $(PERL) -MExtUtils::Embed -e ccopts)
8 PERL_CFLAGS := $(subst -Wdeclaration-after-statement,,$(PERL_CFLAGS))
10 ifeq ($(PERL_CFLAGS),)
11 $(error "Cannot find PERL_CFLAGS. Do you have ExtUtils::Embed?")
12 endif
14 PERL_LIBS := \
15 $(shell PERL5LIB= $(PERL) -MExtUtils::Embed -e ldopts) \
16 $(shell PERL5LIB= $(PERL) -MConfig -e'print "-L$$Config::Config{archlibexp}/CORE";')
18 GLIB_CFLAGS = $(shell pkg-config --cflags glib-2.0) \
19 -I$(PURPLE_PREFIX)/include/libpurple \
20 -DPURPLE_DISABLE_DEPRECATED \
21 $(PERL_CFLAGS)
23 GLIB_LIBS := -L$(GLIB_PREFIX)/lib \
24 -lpurple \
25 -lgobject-2.0 \
26 -lgmodule-2.0 \
27 -lgthread-2.0 \
28 -lglib-2.0 \
29 -lrt
31 CFLAGS = -Wall \
32 -Waggregate-return \
33 -Wcast-align \
34 -Werror-implicit-function-declaration \
35 -Wmissing-declarations \
36 -Wmissing-prototypes \
37 -Wnested-externs \
38 -Wpointer-arith \
39 -Wundef \
40 -O2
42 DEBUG_CFLAGS = -DTH_DEBUG \
43 -DERROR_DEBUG
45 DEBUG_GLIB = -g \
46 -ggdb
48 DEPDIR = .deps
49 OBJS = thperl.o \
50 thblist.o \
51 thrasher.o \
52 thpresence.o \
53 thconnection.o \
54 threquest.o \
55 thconversations.o \
56 thft.o
58 COMPILE = gcc -DHAVE_CONFIG_H -I. $(GLIB_CFLAGS) $(DEBUG_CFLAGS) $(CFLAGS)
59 WRAPPER = THPPW
60 WRAPPER_PATH = perl/lib
62 ifeq ($(shell uname -m), x86_64)
63 COMPILE := $(COMPILE) -fPIC
64 endif
66 .PHONY: clean again
68 all: $(DEPDIR) $(OBJS) thperl_wrap.c wrapper
70 wrapper: $(WRAPPER_PATH)/$(WRAPPER).pm thperl_wrap.o $(WRAPPER).so
72 thperl_wrap.o: thperl_wrap.c
73 $(CC) $(DEBUG_CFLAGS) $(DEBUG_GLIB) -fPIC -c thperl.c thperl_wrap.c $(GLIB_CFLAGS)
75 $(WRAPPER).so: $(OBJS) thperl_wrap.o
76 $(CC) -shared $(GLIB_LIBS) $(PERL_LIBS) $(OBJS) thperl_wrap.o -o $(WRAPPER).so
78 thperl_wrap.c $(WRAPPER_PATH)/$(WRAPPER).pm: thperl.h
79 swig -I$(PURPLE_PREFIX)/include $(DEBUG_CFLAGS) -perl -outdir $(WRAPPER_PATH) thperl.h
81 $(DEPDIR):
82 if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi
84 .c.o:
85 $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
86 mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
88 again: clean all
90 clean:
91 $(RM) -f $(OBJS)
92 $(RM) -rf $(DEPDIR)
93 $(RM) -f thperl_wrap.*
94 $(RM) -f $(WRAPPER).so
95 $(RM) -f $(WRAPPER_PATH)/$(WRAPPER).pm $(WRAPPER).pm