# # Copyright © 2011-2016 Samuel Lidén Borell # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # CFLAGS ?= -O2 -g CFLAGS += -std=c89 -Wall -Wextra -Wmissing-prototypes -Wswitch-enum -Wcast-align -Wdate-time -Wnested-externs -Wshadow -Wbad-function-cast -Wpointer-arith -Wstrict-prototypes -Wfloat-equal -Wredundant-decls -Wold-style-definition -pedantic -D_FILE_OFFSET_BITS=64 OBJECTS = backend.o backend/ctrans.o backend/minicg.o backend/null.o builtins.o configfile.o constexpr.o context.o display.o filesys.o identifier.o interop.o interop/c_builtin.o main.o misc.o parser.o platform.o string.o tokenizer.o verify.o UNIT_TEST_OBJECTS = unittest/testmain.o unittest/test_constexpr.o unittest/test_misc.o UNTESTED_OBJECTS = backend.o backend/ctrans.o backend/minicg.o backend/null.o builtins.o configfile.o context.o display.o filesys.o identifier.o interop.o interop/c_builtin.o parser.o platform.o string.o tokenizer.o verify.o RUNTESTS = tests/runtests.sh INSTALL_PROGRAM ?= install MKDIR_P ?= mkdir -p CLANG_TIDY ?= clang-tidy # Default paths prefix ?= /usr/local exec_prefix ?= $(prefix) bindir ?= $(exec_prefix)/bin datarootdir ?= $(prefix)/share datadir ?= $(datarootdir) lrl_includedir ?= $(datadir)/lrl-includes all: lrlc .c.o: $(CC) $(CFLAGS) -c $< -o $@ backend.o: backend.h backend/ctrans.o: backend.h constexpr.h context.h identifier.h misc.h parser.h platform.h string.h tokenizer.h verify.h backend/minicg.o: backend.h context.h identifier.h misc.h parser.h platform.h string.h tokenizer.h verify.h backend/null.o: backend.h builtins.o: builtins.h identifier.h misc.h parser.h tokenizer.h configfile.o: configfile.h identifier.h misc.h parser.h platform.h constexpr.o: builtins.h constexpr.h context.h context_errors.h context_private.h identifier.h misc.h parser.h tokenizer.h context.o: context.h context_errors.h context_private.h interop.h misc.h tokenizer.h verify.h display.o: builtins.h context.h display.h identifier.h misc.h parser.h tokenizer.h filesys.o: context.h display.h filesys.h identifier.h misc.h parser.h tokenizer.h identifier.o: builtins.h context.h context_errors.h context_private.h filesys.h identifier.h misc.h tokenizer.h interop.o: interop.h interop/c_builtin.o: configfile.h context.h context_private.h interop.h misc.h parser.h platform.h verify.h main.o: backend.h configfile.h context.h context_private.h display.h filesys.h identifier.h misc.h parser.h platform.h tokenizer.h verify.h misc.o: context.h misc.h parser.o: context.h context_errors.h context_private.h identifier.h misc.h parser.h tokenizer.h platform.o: misc.h platform.h string.o: context.h context_errors.h string.h tokenizer.o: context.h context_errors.h context_private.h misc.h string.h tokenizer.h verify.o: builtins.h constexpr.h context.h context_errors.h context_private.h identifier.h interop.h misc.h parser.h tokenizer.h verify.h lrlc: $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) -o $@ check: check-tokenizer check-parser check-verifier check-backend check-interop check-runtime check-unit check-tokenizer: lrlc $(RUNTESTS) tokenizer check-parser: lrlc $(RUNTESTS) parser check-verifier: lrlc $(RUNTESTS) verifier check-backend: lrlc $(RUNTESTS) backend check-interop: lrlc $(RUNTESTS) interop $(RUNTESTS) interop/c check-runtime: lrlc $(RUNTESTS) runtime unittest/testmain.o: unittest/alltests.h unittest/unittest.h unittest/test_constexpr.o: constexpr.o unittest/test_misc.o: misc.o unittest/unittest: $(UNIT_TEST_OBJECTS) $(UNTESTED_OBJECTS) $(CC) $(CFLAGS) $(UNIT_TEST_OBJECTS) $(UNTESTED_OBJECTS) -o $@ check-unit: unittest/unittest -unittest/unittest lint: # Tested with clang-tidy-5.0 $(CLANG_TIDY) -checks="bugprone-*,clang-analyzer-core.*,clang-analyzer-nullability.*,clang-analyzer-optin.portability.*,clang-analyzer-security.*,-clang-analyzer-security.insecureAPI.strcpy,clang-analyzer-unix.*,clang-analyzer-valist.*,misc-*,readability-identifier-naming,readability-inconsistent-declaration-parameter-name,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-redundant-*,readability-simplify-boolean-expr" -header-filter='.*' *.c backend/*.c interop/*.c install: install-compiler install-stdlib install-compiler: lrlc $(MKDIR_P) $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) lrlc $(DESTDIR)$(bindir)/lrlc install-stdlib: $(MKDIR_P) $(DESTDIR)$(lrl_includedir) cp -r ../stdlib/base.lh ../stdlib/c89 $(DESTDIR)$(lrl_includedir) uninstall: uninstall-compiler uninstall-stdlib uninstall-compiler: rm -f $(DESTDIR)$(bindir)/lrlc uninstall-stdlib: rm -rf $(DESTDIR)$(lrl_includedir)/base.lh $(DESTDIR)$(lrl_includedir)/c89 rmdir $(DESTDIR)$(lrl_includedir) 2>/dev/null || true .PHONY: all clean distclean mostlyclean maintainer-clean install install-compiler install-stdlib uninstall uninstall-compiler uninstall-stdlib check check-tokenizer check-parser check-verifier check-backend check-runtime check-unit clean: rm -f $(OBJECTS) lrlc $(UNIT_TEST_OBJECTS) unittest/unittest mostlyclean: clean distclean: clean maintainer-clean: distclean