
# dep/Makefile
# Copyright 2022 Matthew Rickard
# This file is part of dep

# dep is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

WARNINGS := -Wno-unused-variable -Wno-unused-parameter -Wno-misleading-indentation -Wno-parentheses

CXX := g++ -Os -Wall -Wextra -Werror $(WARNINGS)

all: dep

depparse.cpp: depparse.y
	bison -t -v -o depparse.cpp --defines=depparse.h depparse.y
depparse.h: depparse.cpp
deplex.cpp: deplex.l
	flex -o deplex.cpp deplex.l

%.o: %.cpp
	$(CXX) -c -o $@ $<

DepTree.o: depparse.h

# code-generator: makeincludes
stringify.o: stringify.cpp precomp.h stringify.h cross_platform.h
AbstractProcess.o: AbstractProcess.cpp precomp.h AbstractProcess.h File.h cross_platform.h logMsg.h Utils.h Integer.h stringify.h MacroNames.h
CmdLine.o: CmdLine.cpp precomp.h CmdLine.h matches.h stringify.h ParseTree.h logMsg.h Utils.h cross_platform.h Integer.h
Decimal.o: Decimal.cpp precomp.h Decimal.h Integer.h cross_platform.h logMsg.h Utils.h stringify.h
DepTree.o: DepTree.cpp precomp.h DepTree.h ParseTree.h quote.h stringify.h dep.h AbstractProcess.h File.h CmdLine.h matches.h depparse.h logMsg.h Utils.h cross_platform.h Integer.h MacroNames.h clockwork.h Decimal.h
File.o: File.cpp precomp.h File.h logMsg.h Utils.h cross_platform.h Integer.h stringify.h MacroNames.h
Integer.o: Integer.cpp precomp.h Integer.h logMsg.h Utils.h cross_platform.h stringify.h Decimal.h
LinuxMacroNames.o: LinuxMacroNames.cpp precomp.h MacroNames.h
ParseTree.o: ParseTree.cpp precomp.h ParseTree.h cross_platform.h Utils.h Integer.h stringify.h logMsg.h quote.h
Utils.o: Utils.cpp precomp.h Utils.h cross_platform.h Integer.h stringify.h logMsg.h matches.h MacroNames.h
clockwork.o: clockwork.cpp precomp.h clockwork.h Decimal.h Integer.h logMsg.h Utils.h cross_platform.h stringify.h matches.h
dep.o: dep.cpp precomp.h dep.h AbstractProcess.h File.h CmdLine.h matches.h stringify.h ParseTree.h logMsg.h Utils.h cross_platform.h Integer.h MacroNames.h clockwork.h Decimal.h stream_vector.h argv.h quote.h interproc.h DepTree.h
deplex.o: deplex.cpp DepTree.h ParseTree.h quote.h stringify.h dep.h AbstractProcess.h File.h CmdLine.h matches.h depparse.h logMsg.h Utils.h cross_platform.h Integer.h
depmain.o: depmain.cpp precomp.h logMsg.h Utils.h cross_platform.h Integer.h stringify.h dep.h AbstractProcess.h File.h CmdLine.h matches.h ParseTree.h MacroNames.h DepTree.h quote.h argv.h
depparse.o: depparse.cpp DepTree.h ParseTree.h quote.h stringify.h dep.h AbstractProcess.h File.h CmdLine.h matches.h logMsg.h Utils.h cross_platform.h Integer.h depparse.h
interproc.o: interproc.cpp precomp.h interproc.h logMsg.h Utils.h cross_platform.h Integer.h stringify.h MacroNames.h argv.h
logMsg.o: logMsg.cpp precomp.h logMsg.h Utils.h cross_platform.h Integer.h stringify.h
matches.o: matches.cpp precomp.h matches.h cross_platform.h logMsg.h Utils.h Integer.h stringify.h quote.h
quote.o: quote.cpp precomp.h quote.h stringify.h logMsg.h Utils.h cross_platform.h Integer.h
# end code-generator

OBJECTFILES := depmain.o dep.o stringify.o File.o logMsg.o cross_platform.o Utils.o LinuxMacroNames.o \
  depparse.o DepTree.o Decimal.o Integer.o clockwork.o CmdLine.o matches.o ParseTree.o \
  AbstractProcess.o deplex.o quote.o argv.o interproc.o

dep: $(OBJECTFILES)
	$(CXX) $(OBJECTFILES) -lgmpxx -lgmp -o dep

install: dep
	cp dep /usr/local/bin
	mkdir -p /usr/local/man/man1
	cp dep.1 /usr/local/man/man1
	cp -i depsyntax /etc/depsyntax

