1 # Makefile for building the idl tool. 2 # 3 # Copyright (C) 2019, 2020, 2021 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (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, write to the Free Software 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 # Boston, MA 02110-1301, USA 19 20 # Original sources and final program. 21 22 SOURCES = \ 23 main.c client.c common.c config.c declaration.c dispatch.c includes.c \ 24 interface.c message.c program.c server.c structure.c summary.c \ 25 26 PROGRAM = idl 27 28 # Generated files from flex and bison. 29 30 SCANNER = lex.yy.c 31 PARSER = y.tab.c 32 HEADER = y.tab.h 33 GENERATED = $(SCANNER) $(PARSER) 34 35 # Version-related files. 36 37 VERSION = version.h 38 39 # Computed values. 40 41 ALL_SOURCES = $(SOURCES) $(GENERATED) 42 OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) 43 44 # Flags and options. 45 46 CFLAGS = -D_GNU_SOURCE 47 #DEBUG = -DYYDEBUG=1 48 49 # Rules. 50 51 .PHONY: all clean version 52 53 all: $(PROGRAM) 54 55 $(VERSION): version 56 echo "#define VERSION_INFORMATION \"$(shell hg identify -i)\"" > $(VERSION) 57 58 version: 59 60 clean: 61 $(RM) $(PROGRAM) $(GENERATED) $(HEADER) $(OBJECTS) 62 63 $(PROGRAM): $(GENERATED) $(OBJECTS) 64 $(CC) $(CFLAGS) -o $@ $(GENERATED) $(OBJECTS) -ll 65 66 $(SCANNER): idl.lex 67 flex $< 68 69 $(PARSER): idl.y 70 bison -d -y -t $< 71 72 main.c: $(VERSION) 73 74 .c.o: 75 $(CC) $(CFLAGS) -o $@ -c $<