You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.8KB

  1. # Makefile for the Lambert W function related builds
  2. #
  3. # Copyright (C) 2011 Darko Veberic, darko.veberic@ijs.si
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. CPPFLAGS := -I.
  18. #CXXFLAGS := -Wall -Wextra -ggdb3 -O0 -fno-inline -pipe
  19. CXXFLAGS := -O2
  20. #CXXFLAGS := -Wall -Wextra -ggdb3 -O2 -pipe
  21. #CXXFLAGS := -Wall -Wextra -ggdb3 -march=native -Ofast -pipe
  22. LDFLAGS := $(CXXFLAGS)
  23. SUFFIXES := .o .cc .cxx
  24. EXES := $(basename $(wildcard *.cxx))
  25. OBJS := $(patsubst %.cc, %.o, $(wildcard *.cc))
  26. DEPS := $(patsubst %.o, %.P, $(OBJS)) $(addsuffix .P, $(EXES))
  27. define cxx_compile_with_dependency_creation
  28. $(COMPILE.cc) -MD -o $@ $<
  29. @sed -e 's|.*:|$*.o:|' <$*.d >$*.P
  30. @sed -e 's/.*://' -e 's/\\$$//' <$*.d | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >>$*.P
  31. @rm -f $*.d
  32. endef
  33. define cxx_link_rule
  34. $(CXX) $^ $(LDFLAGS) -o $@
  35. endef
  36. %.o: %.cc
  37. $(call cxx_compile_with_dependency_creation)
  38. %.o: %.cxx
  39. $(call cxx_compile_with_dependency_creation)
  40. %: %.o
  41. $(call cxx_link_rule)
  42. .PHONY: all
  43. all: $(EXES)
  44. lambertw: lambertw.o $(OBJS)
  45. test_accuracy: test_accuracy.o $(OBJS)
  46. .PHONY: check
  47. check: $(basename $(wildcard test_*.cxx))
  48. for t in $^ ; do echo $$t ; ./$$t || exit $$? ; done
  49. .PHONY: clean
  50. clean:
  51. - $(RM) $(OBJS) $(addsuffix .o, $(EXES)) $(EXES) *.P
  52. -include $(DEPS)