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