Commit | Line | Data |
---|---|---|
ba147940 MW |
1 | ### -*-makefile-*- |
2 | ### | |
3 | ### Build management | |
4 | ### | |
5 | ### (c) 2017 Mark Wooding | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
10 | ### This file is part of Rhodes, a distributed discrete-log finder. | |
11 | ### | |
12 | ### Rhodes is free software; you can redistribute it and/or modify | |
13 | ### it under the terms of the GNU General Public License as published by | |
14 | ### the Free Software Foundation; either version 2 of the License, or | |
15 | ### (at your option) any later version. | |
16 | ### | |
17 | ### Rhodes is distributed in the hope that it will be useful, | |
18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ### GNU General Public License for more details. | |
21 | ### | |
22 | ### You should have received a copy of the GNU General Public License | |
23 | ### along with Rhodes; if not, write to the Free Software Foundation, | |
24 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
25 | ||
a78da4e7 MW |
26 | all:: |
27 | ||
ba147940 MW |
28 | ###-------------------------------------------------------------------------- |
29 | ### What needs building. | |
30 | ||
a78da4e7 MW |
31 | PROGS += rho |
32 | rho_SRCS = rho.cc | |
33 | rho_LIBS = -lntl | |
34 | ||
35 | PROGS += factor | |
36 | factor_SRCS = factor.c | |
37 | factor_LIBS = -lpari | |
38 | ||
ba147940 MW |
39 | ###-------------------------------------------------------------------------- |
40 | ### Common machinery. | |
41 | ||
a78da4e7 MW |
42 | TARGETS = |
43 | CLEAN += $(TARGETS) | |
44 | .SECONDEXPANSION: | |
45 | ||
46 | V = 0 | |
47 | v_tag = $(call v_tag_$V,$1) | |
48 | v_tag_0 = @printf " %-6s %s\n" $1 $@; | |
49 | V_AT = $(V_AT_$V) | |
50 | V_AT_0 = @ | |
51 | ||
52 | CC = gcc | |
53 | CFLAGS = -O2 -g -Wall -Werror | |
54 | CCLD = $(CC) | |
55 | LDFLAGS = | |
56 | CCLINK = $(call v_tag,CCLD)$(CCLD) $(LDFLAGS) | |
57 | ||
58 | AS = $(CC) | |
59 | ||
60 | CXX = g++ | |
61 | CXXFLAGS = $(CFLAGS) -std=gnu++11 | |
62 | CXXLD = $(CXX) | |
63 | CXXLINK = $(call v_tag,CXXLD)$(CXXLD) $(LDFLAGS) | |
64 | ||
65 | CLEAN += *.o *.d | |
66 | ||
67 | %.o: %.c | |
68 | $(call v_tag,CC)$(CC) -c $(CFLAGS) -MD -o$@ $< | |
69 | ||
70 | %.o: %.cc | |
71 | $(call v_tag,CXX)$(CXX) -c $(CXXFLAGS) -MD -o$@ $< | |
72 | ||
73 | objify = \ | |
74 | $(patsubst %.c,%.o, \ | |
75 | $(patsubst %.cc,%.o, \ | |
76 | $(patsubst %.s,%.o, $(patsubst %.S,%.o, \ | |
77 | $1)))) | |
78 | ||
79 | TARGETS += $(PROGS) | |
80 | ||
81 | $(PROGS): %: $$(call objify,$$($$*_SRCS)) | |
82 | $(or $(and $(filter %.cc,$($*_SRCS)),$(CXXLINK)),$(CCLINK)) -o$@ \ | |
83 | $($*_LDFLAGS) $^ $($*_LIBS) $(LIBS) | |
84 | ||
85 | clean:: | |
86 | rm -f $(CLEAN) | |
87 | .PHONY: clean | |
88 | ||
89 | all:: $(TARGETS) | |
90 | .PHONY: all |