|
| 1 | +# Number of cores to use when invoking parallelism |
| 2 | +#ifndef CORES |
| 3 | + CORES := 1 # temporarily set to 1 since I broke threading. :-( |
| 4 | +#endif |
| 5 | +ifndef PAUSE |
| 6 | + PAUSE := 100 |
| 7 | +endif |
| 8 | +# Uncomment either of these to remove them (removing 7 implies removing 8) |
| 9 | +EIGHT := 8 |
| 10 | +SEVEN := 7 |
| 11 | +ifdef NO8 |
| 12 | + EIGHT := |
| 13 | +endif |
| 14 | +ifdef NO7 |
| 15 | + SEVEN := |
| 16 | + EIGHT := # can't have 8 without 7 |
| 17 | +endif |
| 18 | + |
| 19 | +ifdef DEBUG |
| 20 | + ifdef PROFILE |
| 21 | + SPEED=-O0 -ggdb -pg |
| 22 | + LIB_OPT=-g-pg |
| 23 | + else |
| 24 | + SPEED=-O0 -ggdb |
| 25 | + LIB_OPT=-g |
| 26 | + endif |
| 27 | +else |
| 28 | + ifdef PROFILE |
| 29 | + SPEED=-O3 -pg |
| 30 | + LIB_OPT=-pg |
| 31 | + else |
| 32 | + SPEED=-O3 |
| 33 | + LIB_OPT= |
| 34 | + endif |
| 35 | +endif |
| 36 | + |
| 37 | +# Waywe needs gcc-6 on MacOS: |
| 38 | +GCC_VER=$(shell echo $(ARCH) $(HOME) | awk '/Darwin/&&/Users.wayne/{V="-6"}END{if(V)print V;else{printf "using default gcc: " > "/dev/null"; exit 1}}') |
| 39 | +GCC=gcc$(GCC_VER) |
| 40 | +CXX=g++ |
| 41 | + |
| 42 | +# Some architectures, eg CYGWIN 32-bit and MacOS("Darwin") need an 80MB stack. |
| 43 | +export LIBWAYNE_HOME=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/libwayne |
| 44 | +ARCH=$(shell uname -a | awk '{if(/CYGWIN/){V="CYGWIN"}else if(/Darwin/){V="Darwin"}else if(/Linux/){V="Linux"}}END{if(V){print V;exit}else{print "unknown OS" > "/dev/stderr"; exit 1}}') |
| 45 | + |
| 46 | +# Darwin needs gcc-6 ever since a commit on 22 May 2022: |
| 47 | +#GCC= $(shell $(CC) -v 2>&1 | awk '/gcc/{++gcc}{V=$$3}END{if(gcc && (V ~ /[0-9]\.[0-9]\.[0-9]*/))print "$(ARCH).gcc"V; else exit 1}') |
| 48 | +STACKSIZE=$(shell ($(GCC) -v 2>&1; uname -a) | awk '/CYGWIN/{print "-Wl,--stack,83886080"}/gcc-/{actualGCC=1}/Darwin/&&actualGCC{print "-Wl,-stack_size -Wl,0x5000000"}') |
| 49 | +CC=$(GCC) $(SPEED) -Wall -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wshadow $(PG) $(STACKSIZE) |
| 50 | +LIBWAYNE_COMP=-I $(LIBWAYNE_HOME)/include $(STACKSIZE) $(SPEED) |
| 51 | +LIBWAYNE_LINK=-L $(LIBWAYNE_HOME) -lwayne$(LIB_OPT) -lm $(STACKSIZE) $(SPEED) |
| 52 | +LIBWAYNE_BOTH=$(LIBWAYNE_COMP) $(LIBWAYNE_LINK) |
| 53 | + |
| 54 | +# Name of BLANT source directory |
| 55 | +SRCDIR = src |
| 56 | +# Put all c files in SRCDIR below. |
| 57 | +BLANT_SRCS = blant.c \ |
| 58 | + blant-output.c \ |
| 59 | + blant-utils.c |
| 60 | + |
| 61 | +OBJDIR = _objs |
| 62 | +OBJS = $(addprefix $(OBJDIR)/, $(BLANT_SRCS:.c=.o)) |
| 63 | + |
| 64 | +### Generated File Lists ### |
| 65 | +K := 3 4 5 6 $(SEVEN) $(EIGHT) |
| 66 | +canon_txt := canon_maps/canon_map canon_maps/canon_list canon_maps/canon-ordinal-to-signature canon_maps/orbit_map canon_maps/alpha_list_nbe canon_maps/alpha_list_mcmc |
| 67 | +canon_bin := canon_maps/canon_map canon_maps/perm_map |
| 68 | +canon_all := $(foreach k, $(K), $(addsuffix $(k).txt, $(canon_txt)) $(addsuffix $(k).bin, $(canon_bin))) |
| 69 | +subcanon_txts := $(if $(EIGHT),canon_maps/subcanon_map8-7.txt) $(if $(SEVEN),canon_maps/subcanon_map7-6.txt) canon_maps/subcanon_map6-5.txt canon_maps/subcanon_map5-4.txt canon_maps/subcanon_map4-3.txt |
| 70 | + |
| 71 | +#canon_map_bins := $(foreach k,$(K), canon_maps/canon_map$(k).bin) |
| 72 | +#perm_map_bins := $(foreach k,$(K), canon_maps/perm_map$(k).bin) |
| 73 | +#canon_map_txts := $(foreach k,$(K), canon_maps/canon_map$(k).txt) |
| 74 | +#canon_list_txts := $(foreach k,$(K), canon_maps/canon_list$(k).txt) |
| 75 | +#canon_ordinal_to_signature_txts := $(foreach k,$(K), canon_maps/canon-ordinal-to-signature$(k).txt) |
| 76 | +#orbit_map_txts := $(foreach k,$(K), canon_maps/orbit_map$(k).txt) |
| 77 | +#canon_map_files := $(canon_map_bins) $(perm_map_bins) $(canon_map_txts) $(canon_list_txts) $(canon_ordinal_to_signature_txts) $(orbit_map_txts) |
| 78 | + |
| 79 | +# ehd takes up too much space and isn't used anywhere yet |
| 80 | +#ehd_txts := $(foreach k,$(K), canon_maps/EdgeHammingDistance$(k).txt) |
| 81 | +#alpha_nbe_txts := $(foreach k, $(K), canon_maps/alpha_list_nbe$(k).txt) |
| 82 | +#alpha_mcmc_txts := $(foreach k, $(K), canon_maps/alpha_list_mcmc$(k).txt) |
| 83 | +magic_table_txts := $(foreach k,$(K), orca_jesse_blant_table/UpperToLower$(k).txt) |
| 84 | + |
| 85 | +#base: show-gcc-ver ./.notpristine libwayne $(alpha_nbe_txts) $(alpha_mcmc_txts) magic_table $(canon_map_files) blant |
| 86 | +base: show-gcc-ver ./.notpristine libwayne $(canon_all) magic_table blant |
| 87 | + |
| 88 | +show-gcc-ver: |
| 89 | + $(GCC) -v |
| 90 | + |
| 91 | +./.notpristine: |
| 92 | + @echo '****************************************' |
| 93 | + @echo "If you haven't already, you should read the README at" |
| 94 | + @echo " https://github.com/waynebhayes/BLANT#readme" |
| 95 | + @echo "BLANT can sample graphlets of up to k=8 nodes. The lookup table for k=8 can take" |
| 96 | + @echo "up to an hour to generate, but is needed if you want BLANT-seed to work, and so" |
| 97 | + @echo "we make it by default; set NO8=1 to turn it off." |
| 98 | + @echo "The fastest way to get started is to skip k=8 graphlets:" |
| 99 | + @echo " PAUSE=0 NO8=1 make base" |
| 100 | + @echo "which will make everything needed to get started sampling up to k=7 graphlets". |
| 101 | + @echo "You will only see this message once on a 'pristine' repo. Pausing $(PAUSE) seconds..." |
| 102 | + @echo '****************************************' |
| 103 | + sleep $(PAUSE) |
| 104 | + @touch .notpristine |
| 105 | + |
| 106 | +most: base Draw subcanon_maps |
| 107 | + |
| 108 | +all: most $(ehd_txts) |
| 109 | + |
| 110 | +gcc-version: |
| 111 | + @if ls $(SRCDIR)/*.gz | fgrep -q "$(GCC)"; then :; else echo "WARNING: gcc version not supported; prediction disabled" >&2; fi |
| 112 | + |
| 113 | +canon_maps: base $(canon_all) subcanon_maps |
| 114 | + |
| 115 | +.PHONY: all most pristine clean_canon_maps |
| 116 | + |
| 117 | +### Executables ### |
| 118 | + |
| 119 | +fast-canon-map: libwayne $(SRCDIR)/fast-canon-map.c | $(SRCDIR)/blant.h $(OBJDIR)/libblant.o |
| 120 | + $(CC) '-std=c99' -O3 -o $@ $(OBJDIR)/libblant.o $(SRCDIR)/fast-canon-map.c $(LIBWAYNE_BOTH) |
| 121 | + |
| 122 | +slow-canon-maps: libwayne $(SRCDIR)/slow-canon-maps.c | $(SRCDIR)/blant.h $(OBJDIR)/libblant.o |
| 123 | + $(CC) -o $@ $(OBJDIR)/libblant.o $(SRCDIR)/slow-canon-maps.c $(LIBWAYNE_BOTH) |
| 124 | + |
| 125 | +make-orbit-maps: libwayne $(SRCDIR)/make-orbit-maps.c | $(SRCDIR)/blant.h $(OBJDIR)/libblant.o |
| 126 | + $(CC) -o $@ $(OBJDIR)/libblant.o $(SRCDIR)/make-orbit-maps.c $(LIBWAYNE_BOTH) |
| 127 | + |
| 128 | +blant: gcc-version libwayne $(OBJS) $(OBJDIR)/convert.o $(OBJDIR)/libblant.o | $(LIBWAYNE_HOME)/MT19937/mt19937.o |
| 129 | + $(CXX) -o $@ $(OBJDIR)/libblant.o $(OBJS) $(OBJDIR)/convert.o $(LIBWAYNE_HOME)/MT19937/mt19937.o $(LIBWAYNE_LINK) |
| 130 | + |
| 131 | +$(OBJDIR)/%.o: $(SRCDIR)/%.c |
| 132 | + @mkdir -p $(dir $@) |
| 133 | + $(CC) -c -o $@ $< $(LIBWAYNE_COMP) |
| 134 | + |
| 135 | +synthetic: libwayne $(SRCDIR)/synthetic.c $(SRCDIR)/syntheticDS.h $(SRCDIR)/syntheticDS.c | $(OBJDIR)/libblant.o |
| 136 | + $(CC) -c $(SRCDIR)/syntheticDS.c $(SRCDIR)/synthetic.c $(LIBWAYNE_COMP) |
| 137 | + $(CXX) -o $@ syntheticDS.o $(OBJDIR)/libblant.o synthetic.o $(LIBWAYNE_LINK) |
| 138 | + |
| 139 | +CC: libwayne $(SRCDIR)/CC.c $(OBJDIR)/convert.o | $(SRCDIR)/blant.h $(OBJDIR)/libblant.o |
| 140 | + $(CXX) -o $@ $(OBJDIR)/libblant.o $(SRCDIR)/CC.c $(OBJDIR)/convert.o $(LIBWAYNE_LINK) |
| 141 | + |
| 142 | +makeEHD: $(OBJDIR)/makeEHD.o |
| 143 | + $(CXX) -o $@ $(OBJDIR)/libblant.o $(OBJDIR)/makeEHD.o $(LIBWAYNE_LINK) |
| 144 | + |
| 145 | +compute-alphas-NBE: libwayne $(SRCDIR)/compute-alphas-NBE.c | $(OBJDIR)/libblant.o |
| 146 | + $(CC) -Wall -O3 -o $@ $(SRCDIR)/compute-alphas-NBE.c $(OBJDIR)/libblant.o $(LIBWAYNE_BOTH) |
| 147 | + |
| 148 | +compute-alphas-MCMC: libwayne $(SRCDIR)/compute-alphas-MCMC.c | $(OBJDIR)/libblant.o |
| 149 | + $(CC) -Wall -O3 -o $@ $(SRCDIR)/compute-alphas-MCMC.c $(OBJDIR)/libblant.o $(LIBWAYNE_BOTH) |
| 150 | + |
| 151 | +Draw: Draw/graphette2dot |
| 152 | + |
| 153 | +Draw/graphette2dot: libwayne Draw/DrawGraphette.cpp Draw/Graphette.cpp Draw/Graphette.h Draw/graphette2dotutils.cpp Draw/graphette2dotutils.h | $(SRCDIR)/blant.h $(OBJDIR)/libblant.o |
| 154 | + $(CXX) Draw/DrawGraphette.cpp Draw/graphette2dotutils.cpp Draw/Graphette.cpp $(OBJDIR)/libblant.o -o $@ -std=c++11 $(LIBWAYNE_BOTH) |
| 155 | + |
| 156 | +make-subcanon-maps: libwayne $(SRCDIR)/make-subcanon-maps.c | $(OBJDIR)/libblant.o |
| 157 | + $(CC) -Wall -o $@ $(SRCDIR)/make-subcanon-maps.c $(OBJDIR)/libblant.o $(LIBWAYNE_BOTH) |
| 158 | + |
| 159 | +make-orca-jesse-blant-table: libwayne $(SRCDIR)/magictable.cpp | $(OBJDIR)/libblant.o |
| 160 | + $(CXX) -Wall -o $@ $(SRCDIR)/magictable.cpp $(OBJDIR)/libblant.o -std=c++11 $(LIBWAYNE_BOTH) |
| 161 | + |
| 162 | +### Object Files/Prereqs ### |
| 163 | + |
| 164 | +$(OBJDIR)/convert.o: $(SRCDIR)/convert.cpp |
| 165 | + @mkdir -p $(dir $@) |
| 166 | + $(CXX) -c $(SRCDIR)/convert.cpp -o $@ -std=c++11 |
| 167 | + |
| 168 | +$(LIBWAYNE_HOME)/MT19937/mt19937.o: libwayne |
| 169 | + cd $(LIBWAYNE_HOME)/MT19937 && $(MAKE) |
| 170 | + |
| 171 | +$(OBJDIR)/libblant.o: libwayne $(SRCDIR)/libblant.c |
| 172 | + @mkdir -p $(dir $@) |
| 173 | + $(CC) -c $(SRCDIR)/libblant.c -o $@ $(LIBWAYNE_COMP) |
| 174 | + |
| 175 | +$(OBJDIR)/makeEHD.o: libwayne $(SRCDIR)/makeEHD.c | $(OBJDIR)/libblant.o |
| 176 | + @mkdir -p $(dir $@) |
| 177 | + $(CC) -c $(SRCDIR)/makeEHD.c -o $@ $(LIBWAYNE_COMP) |
| 178 | + |
| 179 | +libwayne: $(LIBWAYNE_HOME)/Makefile $(LIBWAYNE_HOME)/made |
| 180 | + |
| 181 | +$(LIBWAYNE_HOME)/made: |
| 182 | + cd $(LIBWAYNE_HOME) && $(MAKE) all |
| 183 | + |
| 184 | +### Generated File Recipes ### |
| 185 | + |
| 186 | +canon_maps/canon_map%.bin canon_maps/perm_map%.bin canon_maps/orbit_map%.txt canon_maps/alpha_list_mcmc%.txt: libwayne $(SRCDIR)/create-bin-data.c | $(OBJDIR)/libblant.o $(SRCDIR)/blant.h canon_maps/canon_list%.txt canon_maps/canon_map%.txt make-orbit-maps compute-alphas-MCMC |
| 187 | + $(CC) '-std=c99' "-Dkk=$*" "-DkString=\"$*\"" -o create-bin-data$* $(SRCDIR)/libblant.c $(SRCDIR)/create-bin-data.c $(LIBWAYNE_BOTH) |
| 188 | + [ -f canon_maps/canon_map$*.bin -a -f canon_maps/perm_map$*.bin ] || ./create-bin-data$* |
| 189 | + ./make-orbit-maps $* > canon_maps/orbit_map$*.txt |
| 190 | + @if [ -f canon_maps.correct/alpha_list_mcmc$*.txt ]; then echo "computing MCMC alphas for k=$* takes days, so just copy it"; cp canon_maps.correct/alpha_list_mcmc$*.txt canon_maps/ && touch $@; else ./compute-alphas-MCMC $* > canon_maps/alpha_list_mcmc$*.txt; fi |
| 191 | + |
| 192 | +canon_maps/canon_map%.txt canon_maps/canon_list%.txt canon_maps/canon-ordinal-to-signature%.txt: fast-canon-map |
| 193 | + mkdir -p canon_maps |
| 194 | + # It's cheap to make all but k=8 canon maps, so make all but skip 8 if it already exists |
| 195 | + [ $* -eq 8 -a '(' -f canon_maps/canon_map$*.txt -o -f canon_maps/canon_map$*.txt.gz ')' ] || ./fast-canon-map $* | tee canon_maps/canon_map$*.txt | awk -F ' ' 'BEGIN{n=0}!seen[$$1]{seen[$$1]=$$0;map[n++]=$$1}END{print n;for(i=0;i<n;i++)print seen[map[i]]}' | cut -f1,3- | tee canon_maps/canon_list$*.txt | awk 'NR>1{print NR-2, $$1}' > canon_maps/canon-ordinal-to-signature$*.txt |
| 196 | + if [ $* -eq 8 -a -f canon_maps/canon_map$*.txt -a ! -f canon_maps/canon_map$*.txt.gz ]; then gzip canon_maps/canon_map$*.txt & fi |
| 197 | + |
| 198 | +canon_maps/EdgeHammingDistance%.txt: makeEHD | canon_maps/canon_list%.txt canon_maps/canon_map%.bin |
| 199 | + @if [ ! -f canon_maps.correct/EdgeHammingDistance$*.txt.xz ]; then ./makeEHD $* > $@; cmp canon_maps.correct/EdgeHammingDistance$*.txt $@; else echo "EdgeHammingDistance8.txt takes weeks to generate; uncompressing instead"; unxz < canon_maps.correct/EdgeHammingDistance$*.txt.xz > $@ && touch $@; fi |
| 200 | + #(cd canon_maps.correct && ls EdgeHammingDistance$*.txt*) | awk '{printf "cmp canon_maps.correct/%s canon_maps/%s\n",$$1,$$1}' | sh |
| 201 | + |
| 202 | +canon_maps/alpha_list_nbe%.txt: compute-alphas-NBE canon_maps/canon_list%.txt |
| 203 | + ./compute-alphas-NBE $* > $@ |
| 204 | + |
| 205 | +.INTERMEDIATE: .created-subcanon-maps |
| 206 | +subcanon_maps: $(subcanon_txts) ; |
| 207 | +$(subcanon_txts): .created-subcanon-maps |
| 208 | +.created-subcanon-maps: make-subcanon-maps | $(canon_all) #$(canon_list_txts) $(canon_map_bins) |
| 209 | + # only do it for k > 3 since it's 4-3, 5-4, etc. |
| 210 | + for k in $(K); do if [ $$k -gt 3 ]; then ./make-subcanon-maps $$k > canon_maps/subcanon_map$$k-$$(($$k-1)).txt; fi; done |
| 211 | + |
| 212 | +magic_table: $(magic_table_txts) ; |
| 213 | +$(magic_table_txts): make-orca-jesse-blant-table | $(canon_all) #$(canon_list_txts) $(canon_map_bins) |
| 214 | + ./make-orca-jesse-blant-table $(if $(EIGHT),8,$(if $(SEVEN),7,6)) |
| 215 | + |
| 216 | +### Cleaning ### |
| 217 | + |
| 218 | +clean: |
| 219 | + @/bin/rm -f *.[oa] blant canon-sift fast-canon-map make-orbit-maps compute-alphas-MCMC compute-alphas-NBE makeEHD make-orca-jesse-blant-table Draw/graphette2dot make-subcanon-maps create-bin-data* |
| 220 | + @/bin/rm -rf $(OBJDIR)/* |
| 221 | + |
| 222 | +pristine: clean clean_canon_maps |
| 223 | + @cd $(LIBWAYNE_HOME); $(MAKE) clean |
| 224 | + @/bin/rm -f canon_maps/* .notpristine .firsttime # .firsttime is the old name but remove it anyway |
| 225 | + |
| 226 | +clean_canon_maps: |
| 227 | + @/bin/rm -f canon_maps/*[3-7].* # don't remove 8 since it takes too long to create |
| 228 | + @/bin/rm -f orca_jesse_blant_table/UpperToLower*.txt |
0 commit comments