]> git.cworth.org Git - fips/blob - Makefile.local
configure: Test whether compiler can create both 32 and 64-bit binaries
[fips] / Makefile.local
1 # -*- makefile -*-
2
3 include Makefile.release
4
5 # Smash together user's values with our extra values
6 FINAL_CFLAGS = -DFIPS_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
7 FINAL_FIPS_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
8 FINAL_LIBFIPS_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS) -ldl
9 FINAL_FIPS_LINKER = CC
10
11 ALL_TARGETS = fips
12
13 ifeq ($(COMPILER_SUPPORTS_32),Yes)
14 ALL_TARGETS += libfips-32.so
15 endif
16
17 ifeq ($(COMPILER_SUPPORTS_64),Yes)
18 ALL_TARGETS += libfips-64.so
19 endif
20
21 .PHONY: all
22 all: $(ALL_TARGETS)
23
24 ifeq ($(MAKECMDGOALS),)
25 ifeq ($(shell cat .first-build-message 2>/dev/null),)
26         @FIPS_FIRST_BUILD=1 $(MAKE) --no-print-directory all
27         @echo ""
28         @echo "Compilation of fips is now complete. You can install fips with:"
29         @echo ""
30         @echo " make install"
31         @echo ""
32         @echo "Note that depending on the prefix to which you are installing"
33         @echo "you may need root permission (such as \"sudo make install\")."
34         @echo "See \"./configure --help\" for help on setting an alternate prefix."
35         @echo Printed > .first-build-message
36 endif
37 endif
38
39 .PHONY: test
40 test:
41         @echo "FIXME: Should consider adding a test suite here."
42
43 # The user has not set any verbosity, default to quiet mode and inform the
44 # user how to enable verbose compiles.
45 ifeq ($(V),)
46 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
47 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
48 endif
49 # The user has explicitly enabled quiet compilation.
50 ifeq ($(V),0)
51 quiet = @printf "$1 $@\n"; $($(shell echo $1 | sed -e s'/ .*//'))
52 endif
53 # Otherwise, print the full command line.
54 quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
55
56 %-32.o: %.c $(global_deps)
57         @mkdir -p .deps/$(@D)
58         $(call quiet,CC $(CFLAGS) -m32) -c $(FINAL_CFLAGS) -m32 $< -o $@ -MD -MP -MF .deps/$*.d
59
60 %-64.o: %.c $(global_deps)
61         @mkdir -p .deps/$(@D)
62         $(call quiet,CC $(CFLAGS) -m64) -c $(FINAL_CFLAGS) -m64 $< -o $@ -MD -MP -MF .deps/$*.d
63
64 %.o: %.c $(global_deps)
65         @mkdir -p .deps/$(@D)
66         $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
67
68 .PHONY : clean
69 clean:
70         rm -rf $(CLEAN); rm -rf .deps
71
72 .PHONY: distclean
73 distclean: clean
74         rm -rf $(DISTCLEAN)
75
76 # Main program, fips
77
78 fips_srcs = \
79         execute.c \
80         fips.c
81
82 fips_modules = $(fips_srcs:.c=.o)
83
84 fips: $(fips_modules)
85         $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS)) $(FINAL_CFLAGS) $^ $(FINAL_FIPS_LDFLAGS) -o $@
86
87 # GL-wrapper library, libfips
88 LIBRARY_LINK_FLAGS = -shared -Wl,--version-script=libfips.sym
89
90 extra_cflags += -I$(srcdir) -fPIC
91
92 libfips_srcs = \
93         dlwrap.c \
94         glwrap.c \
95         glxwrap.c \
96         metrics.c
97
98 ifeq ($(HAVE_EGL),Yes)
99 libfips_srcs += eglwrap.c
100 endif
101
102 libfips.sym: extract-wrapped-symbols $(libfips_srcs)
103         $(call quiet,extract-wrapped-symbols) ./extract-wrapped-symbols $(libfips_srcs) > $@
104
105 libfips_32_modules = $(libfips_srcs:.c=-32.o)
106
107 libfips_64_modules = $(libfips_srcs:.c=-64.o)
108
109 libfips-32.so: $(libfips_32_modules) libfips.sym
110         $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m32) -o $@ $(FINAL_CFLAGS) -m32 $(libfips_32_modules)  $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS)
111
112 libfips-64.so: $(libfips_64_modules) libfips.sym
113         $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m64) -o $@ $(FINAL_CFLAGS) -m64 $(libfips_64_modules) $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS)
114
115 .PHONY: install
116 install: all
117         mkdir -p $(DESTDIR)$(bindir)
118         install fips $(DESTDIR)$(bindir)/fips
119         mkdir -p $(DESTDIR)$(libdir)/fips
120         install -m0644 libfips-32.so $(DESTDIR)$(libdir)/fips/libfips-32.so
121         install -m0644 libfips-64.so $(DESTDIR)$(libdir)/fips/libfips-64.so
122 ifeq ($(MAKECMDGOALS), install)
123         @echo ""
124         @echo "Fips is now installed to $(DESTDIR)$(prefix)"
125         @echo ""
126 endif
127
128 SRCS  := $(SRCS) $(fips_srcs) $(libfips_srcs)
129 CLEAN := $(CLEAN) fips $(fips_modules) $(libfips_32_modules) $(libfips_64_modules) libfips.sym
130
131 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config
132
133 DEPS := $(SRCS:%.c=.deps/%.d)
134 DEPS := $(DEPS:%.cc=.deps/%.d)
135
136 -include $(DEPS)